From 59e3fc5cebd8b4886882d6760ed4c4a1eb927992 Mon Sep 17 00:00:00 2001 From: Derek Nola Date: Fri, 7 Jun 2024 09:21:25 -0700 Subject: [PATCH] Build and Run Arm64 K3s Integration Tests Signed-off-by: Derek Nola Co-Authored-By: ErikJang <81848652+erikjang@users.noreply.github.com> --- .github/workflows/arm_test.yaml | 37 ---------------------- .github/workflows/build-k3s.yaml | 50 +++++++----------------------- .github/workflows/integration.yaml | 37 +++++++++++++++++++++- 3 files changed, 48 insertions(+), 76 deletions(-) delete mode 100644 .github/workflows/arm_test.yaml diff --git a/.github/workflows/arm_test.yaml b/.github/workflows/arm_test.yaml deleted file mode 100644 index 5fa80c154bca..000000000000 --- a/.github/workflows/arm_test.yaml +++ /dev/null @@ -1,37 +0,0 @@ -name: Integration Test Coverage -on: - workflow_dispatch: {} - -permissions: - contents: read - -env: - GOCOVERDIR: /tmp/k3scov - -jobs: - build: - uses: ./.github/workflows/build-k3s.yaml - with: - arch: arm64 - itest: - needs: build - name: Integration Tests - runs-on: ubuntu-latest - timeout-minutes: 45 - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - name: Install Go - uses: ./.github/actions/setup-go - - name: "Download k3s binary" - uses: actions/download-artifact@v4 - with: - name: k3s - path: ./dist/artifacts - - name: Launch Debug Session - uses: dereknola/action-upterm@v1.1 - with: - ## If no one connects after 5 minutes, shut down server. - wait-timeout-minutes: 5 \ No newline at end of file diff --git a/.github/workflows/build-k3s.yaml b/.github/workflows/build-k3s.yaml index 54dd557a61bb..4bfb3979c413 100644 --- a/.github/workflows/build-k3s.yaml +++ b/.github/workflows/build-k3s.yaml @@ -6,7 +6,7 @@ on: arch: type: string description: 'Architecture to build' - default: 'amd64' + default: 'ubuntu-latest' upload-repo: type: boolean required: false @@ -20,14 +20,18 @@ permissions: contents: read jobs: - build-amd64: + build: name: Build - if: inputs.arch == 'amd64' - 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 @@ -49,47 +53,17 @@ 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* - build-arm64: - # Build using CNCF arm64 custom runners - name: Build Arm - if: github.repository == 'k3s-io/k3s' && inputs.arch == 'arm64' - runs-on: oracle-aarch64-4cpu-16gb - timeout-minutes: 20 - steps: - - name: Checkout K3s - uses: actions/checkout@v4 - - name: Build K3s binary - run: | - DOCKER_BUILDKIT=1 SKIP_IMAGE=1 SKIP_AIRGAP=1 SKIP_VALIDATE=1 GOCOVER=1 make - sha256sum dist/artifacts/k3s | sed 's|dist/artifacts/||' > dist/artifacts/k3s.sha256sum - - name: Build K3s image - if: inputs.upload-image == true - run: make package-image - - name: bundle repo - if: inputs.upload-repo == true - run: | - tar -czvf ../k3s-repo.tar.gz . - mv ../k3s-repo.tar.gz . - - name: "Upload K3s directory" - if: inputs.upload-repo == true - uses: actions/upload-artifact@v4 - with: - name: k3s-repo.tar.gz - path: k3s-repo.tar.gz - - 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" - if: inputs.upload-repo == false + - name: "Upload K3s Arm64 Artifacts" + if: contains(inputs.arch, 'aarch64') uses: actions/upload-artifact@v4 with: - name: k3s + name: k3s-arm64 path: dist/artifacts/k3s* - name: On Failure, Launch Debug Session uses: dereknola/action-upterm@v1.1 diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 66a8dc1f22d5..09ac0a3a3a47 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -30,7 +30,42 @@ env: jobs: build: uses: ./.github/workflows/build-k3s.yaml - itest: + 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-arm + path: ./dist/artifacts + - name: Run Integration Tests + run: | + 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-amd64: needs: build name: Integration Tests runs-on: ubuntu-latest