From f0fc81487184749ee2b43bf335b580b4eea93516 Mon Sep 17 00:00:00 2001 From: Shiming Zhang Date: Sat, 7 Oct 2023 12:54:19 +0800 Subject: [PATCH] Test --- .github/workflows/test-action.yaml | 12 ++++++++--- actions/create-cluster/action.yaml | 2 +- actions/kwok/action.yaml | 34 +++++++++++++++++++----------- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test-action.yaml b/.github/workflows/test-action.yaml index 2a195a02ba..9278042e09 100644 --- a/.github/workflows/test-action.yaml +++ b/.github/workflows/test-action.yaml @@ -9,8 +9,14 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Create kwok cluster - uses: ./actions/create-cluster # kubernetes-sigs/kwok/actions/create-cluster@main +# - name: Create kwok cluster +# uses: ./actions/create-cluster # kubernetes-sigs/kwok/actions/create-cluster@main + - name: Install kwokctl + uses: ./actions/kwok # kubernetes-sigs/kwok/actions/kwok@main + with: + command: kwokctl - name: Test kwokctl shell: bash - run: kubectl version + run: | + kwokctl create cluster --name kwok --wait 120s + kubectl version diff --git a/actions/create-cluster/action.yaml b/actions/create-cluster/action.yaml index 870bf2ad27..118ca96759 100644 --- a/actions/create-cluster/action.yaml +++ b/actions/create-cluster/action.yaml @@ -21,7 +21,7 @@ runs: uses: ./actions/kwok with: command: kwokctl - args: create cluster --name ${{ inputs.cluster-name }} + args: create cluster --name ${{ inputs.cluster-name }} --wait 120s kwok-version: ${{ inputs.kwok-version }} env: KWOK_KUBE_VERSION: ${{ inputs.kube-version }} diff --git a/actions/kwok/action.yaml b/actions/kwok/action.yaml index 6d2c220a45..cf79160578 100644 --- a/actions/kwok/action.yaml +++ b/actions/kwok/action.yaml @@ -4,7 +4,7 @@ description: This action runs kwok inputs: args: - required: true + required: false description: Arguments passed to `kwok` or `kwokctl` kwok-version: required: false @@ -23,17 +23,27 @@ runs: KWOK_REPO: ${{ github.repository }} KWOK_VERSION: ${{ inputs.kwok-version }} run: | - if [[ -z "${KWOK_VERSION}" ]]; then - echo "Fetching latest version..." - KWOK_VERSION="$(curl "https://api.github.com/repos/${KWOK_REPO}/releases/latest" | jq -r '.tag_name')" - fi - - if [[ ! -f ~/.kwok/bin/${{ inputs.command }}-${KWOK_VERSION} ]]; then + if [[ ! -f /usr/local/bin/${{ inputs.command }}-${KWOK_VERSION} ]]; then + if [[ -z "${KWOK_VERSION}" ]]; then + echo "Fetching latest version..." + KWOK_VERSION="$(curl "https://api.github.com/repos/${KWOK_REPO}/releases/latest" | jq -r '.tag_name')" + fi echo "Installing ${{ inputs.command }} ${KWOK_VERSION}..." - mkdir -p ~/.kwok/bin/ - curl -o ~/.kwok/bin/${{ inputs.command }}-${KWOK_VERSION} "https://github.com/${KWOK_REPO}/releases/download/${KWOK_VERSION}/${{ inputs.command }}-$(go env GOOS)-$(go env GOARCH)" - chmod +x ~/.kwok/bin/${{ inputs.command }}-${KWOK_VERSION} + curl -o ${{ inputs.command }}-${KWOK_VERSION} "https://github.com/${KWOK_REPO}/releases/download/${KWOK_VERSION}/${{ inputs.command }}-$(go env GOOS)-$(go env GOARCH)" + chmod +x ${{ inputs.command }}-${KWOK_VERSION} + sudo mv ${{ inputs.command }}-${KWOK_VERSION} /usr/local/bin/ + sudo ln -sf /usr/local/bin/${{ inputs.command }}-${KWOK_VERSION} /usr/local/bin/${{ inputs.command }} + if ! ${{ inputs.command }} --version; then + echo "Failed to run ${{ inputs.command }} --version" + exit 1 + fi fi - echo "Running ${{ inputs.command }} ${{ inputs.args }}" - ~/.kwok/bin/${{ inputs.command }}-${KWOK_VERSION} ${{ inputs.args }} + if [[ -n "${{ inputs.args }}" ]]; then + echo "Running ${{ inputs.command }} ${{ inputs.args }}" + if ! ${{ inputs.command }} ${{ inputs.args }}; then + echo "Failed to run ${{ inputs.command }} ${{ inputs.args }}" + exit 1 + fi + echo "Done!" + fi