From 6ea8cbcb09feafeda56b20fd183b3f11312f70ce Mon Sep 17 00:00:00 2001 From: Noah Campbell Date: Mon, 13 Oct 2025 13:00:59 -0500 Subject: [PATCH] creates clusters for tests via replicated actions --- .github/workflows/affected-tests.yml | 28 ++++++++++++++++++++++++---- scripts/run-affected.sh | 10 +++++++--- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/affected-tests.yml b/.github/workflows/affected-tests.yml index 3cdc969e..ad19206e 100644 --- a/.github/workflows/affected-tests.yml +++ b/.github/workflows/affected-tests.yml @@ -86,12 +86,23 @@ jobs: fi; } | tee -a "$GITHUB_STEP_SUMMARY" - # Provision a Kubernetes cluster for e2e that depend on it (safe no-op for kind-based Go e2e) - - name: Setup K3s + # Provision a Kubernetes cluster for e2e using Replicated compatibility actions + - name: Create k3s cluster + id: create-cluster if: steps.affected_e2e.outputs.has_changes == 'true' - uses: replicatedhq/action-k3s@main + uses: replicatedhq/compatibility-actions/create-cluster@v1 with: - version: v1.31.2-k3s1 + api-token: ${{ secrets.REPLICATED_API_TOKEN }} + kubernetes-distribution: k3s + cluster-name: pr-${{ github.run_id }}-${{ github.run_attempt }} + ttl: 25m + timeout-minutes: 5 + + - name: Configure kubeconfig + if: steps.affected_e2e.outputs.has_changes == 'true' + run: | + echo "${{ steps.create-cluster.outputs.cluster-kubeconfig }}" > $GITHUB_WORKSPACE/kubeconfig.yaml + echo "KUBECONFIG=$GITHUB_WORKSPACE/kubeconfig.yaml" >> $GITHUB_ENV # 3) Run filtered tests only - name: Run unit tests for affected packages @@ -142,4 +153,13 @@ jobs: if: steps.affected.outputs.has_changes != 'true' run: echo "No Go packages affected by this PR; skipping tests." + # Cleanup cluster + - name: Remove cluster + if: always() && steps.affected_e2e.outputs.has_changes == 'true' + uses: replicatedhq/compatibility-actions/remove-cluster@v1 + continue-on-error: true + with: + api-token: ${{ secrets.REPLICATED_API_TOKEN }} + cluster-id: ${{ steps.create-cluster.outputs.cluster-id }} + diff --git a/scripts/run-affected.sh b/scripts/run-affected.sh index f3c1b450..5ad762d4 100755 --- a/scripts/run-affected.sh +++ b/scripts/run-affected.sh @@ -53,11 +53,15 @@ SB="$( echo "${E2E_OUT}" | awk -F: '$1=="support-bundle"{print $2}' | paste -sd' # Use direct go test with the same build tags as the Makefile to avoid RUN quoting issues locally BUILD_TAGS='netgo containers_image_ostree_stub exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp' +overall=0 + if [ -n "${PRE}" ]; then echo "Running preflight e2e: ${PRE}" - go test -tags "${BUILD_TAGS}" -installsuffix netgo -v -count=1 ./test/e2e/preflight -run "^(${PRE})$" || true + go test -tags "${BUILD_TAGS}" -installsuffix netgo -v -count=1 ./test/e2e/preflight -run "^(${PRE})$" || overall=1 fi if [ -n "${SB}" ]; then echo "Running support-bundle e2e: ${SB}" - go test -tags "${BUILD_TAGS}" -installsuffix netgo -v -count=1 ./test/e2e/support-bundle -run "^(${SB})$" || true -fi \ No newline at end of file + go test -tags "${BUILD_TAGS}" -installsuffix netgo -v -count=1 ./test/e2e/support-bundle -run "^(${SB})$" || overall=1 +fi + +exit $overall \ No newline at end of file