From b15f47d42240f9aafa0512b4573cb951dca3e5c3 Mon Sep 17 00:00:00 2001 From: Derek Nola Date: Fri, 7 Jun 2024 09:20:10 -0700 Subject: [PATCH] Build and Run Arm64 K3s Integration Tests Signed-off-by: Derek Nola --- .github/workflows/build-k3s.yaml | 19 +++++++++++++-- .github/workflows/integration.yaml | 38 +++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-k3s.yaml b/.github/workflows/build-k3s.yaml index 47ba18e247ee..8da596bc4b1b 100644 --- a/.github/workflows/build-k3s.yaml +++ b/.github/workflows/build-k3s.yaml @@ -3,6 +3,10 @@ name: Build K3s on: workflow_call: inputs: + arch: + type: string + description: 'Architecture to build' + default: 'ubuntu-latest' upload-repo: type: boolean required: false @@ -18,11 +22,16 @@ permissions: jobs: build: name: Build - runs-on: ubuntu-latest + runs-on: ${{ inputs.arch }} # defaults to ubuntu-latest, for arm64 use oracle-aarch64-4cpu-16gb timeout-minutes: 20 steps: - name: Checkout K3s uses: actions/checkout@v4 + - name: Setup Arm64 Runner + if: contains(inputs.arch, 'aarch64') + run: | + sudo apt-get update + sudo apt-get install -y make - name: Build K3s binary run: | DOCKER_BUILDKIT=1 SKIP_IMAGE=1 SKIP_AIRGAP=1 SKIP_VALIDATE=1 GOCOVER=1 make @@ -44,9 +53,15 @@ jobs: - name: "Save K3s image" if: inputs.upload-image == true run: docker image save rancher/k3s -o ./dist/artifacts/k3s-image.tar - - name: "Upload K3s binary" + - name: "Upload K3s Artifacts" if: inputs.upload-repo == false uses: actions/upload-artifact@v4 with: name: k3s + path: dist/artifacts/k3s* + - name: "Upload K3s Arm64 Artifacts" + if: contains(inputs.arch, 'aarch64') + uses: actions/upload-artifact@v4 + with: + name: k3s-arm64 path: dist/artifacts/k3s* \ No newline at end of file diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 2cde5fc0a9c1..23f803944c4b 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -30,6 +30,42 @@ env: jobs: build: uses: ./.github/workflows/build-k3s.yaml + build-arm64: + if : github.repository == 'k3s-io/k3s' + uses: ./.github/workflows/build-k3s.yaml + with: + arch: oracle-aarch64-4cpu-16gb + itest-arm64: + needs: build-arm64 + name: Integration Tests Arm64 + if: github.repository == 'k3s-io/k3s' + runs-on: oracle-aarch64-4cpu-16gb + strategy: + fail-fast: false + matrix: + itest: [certrotation, etcdrestore, localstorage, startup, custometcdargs, etcdsnapshot, kubeflags, longhorn, secretsencryption, flannelnone] + max-parallel: 3 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + cache: false + - name: "Download k3s binary" + uses: actions/download-artifact@v4 + with: + name: k3s-arm64 + path: ./dist/artifacts + - name: Run Integration Tests + run: | + mv ./dist/artifacts/k3s-arm64 ./dist/artifacts/k3s + chmod +x ./dist/artifacts/k3s + mkdir -p $GOCOVERDIR + sudo -E env "PATH=$PATH" go test -v -timeout=45m ./tests/integration/${{ matrix.itest }}/... -run Integration itest: needs: build name: Integration Tests @@ -58,7 +94,7 @@ jobs: mkdir -p $GOCOVERDIR sudo -E env "PATH=$PATH" go test -v -timeout=45m ./tests/integration/${{ matrix.itest }}/... -run Integration - name: On Failure, Launch Debug Session - uses: lhotari/action-upterm@v1 + uses: dereknola/action-upterm@v1.1 if: ${{ failure() }} with: ## If no one connects after 5 minutes, shut down server.