From a6216b5c0745fc98c26013861033287bf43bc198 Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Tue, 5 Nov 2024 14:50:01 +0100 Subject: [PATCH 1/7] let smoke test provision its own cluster --- .github/workflows/smoke-test.yaml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/smoke-test.yaml b/.github/workflows/smoke-test.yaml index 131f85517..fa9126631 100644 --- a/.github/workflows/smoke-test.yaml +++ b/.github/workflows/smoke-test.yaml @@ -27,8 +27,26 @@ jobs: echo "Cluster: ${{ inputs.cluster }}" echo "Prefix: ${{ inputs.prefix }}" + create-cluster: + runs-on: ubuntu-latest + outputs: + cluster-name: ${{ steps.determine-cluster-name.outputs.cluster-name }} + steps: + - name: Determine cluster name + id: determine-cluster-name + run: | + echo "cluster-name=daily-smoke-test-$(date +%s)" >> ${GITHUB_OUTPUT} + + - uses: ./.actions/infra/create-cluster + with: + token: ${{ secrets.INFRA_TOKEN }} + flavor: gke-default + name: ${{ steps.determine-cluster-name.outputs.cluster-name }} + lifespan: 8h + smoke-test: runs-on: ubuntu-latest + needs: [create-cluster] env: KUBECONFIG: /home/runner/artifacts/kubeconfig INFRA_TOKEN_PROD: ${{ secrets.INFRA_TOKEN }} @@ -68,12 +86,12 @@ jobs: - name: Download production infractl uses: stackrox/actions/infra/install-infractl@v1 - - name: Download artifacts for cluster ${{ inputs.cluster }} + - name: Download artifacts for cluster ${{ needs.create-cluster.outputs.cluster-name }} env: INFRA_TOKEN: ${{ env.INFRA_TOKEN_PROD }} run: | set -uo pipefail - infractl artifacts "${{ inputs.cluster }}" -d "/home/runner/artifacts" >> "$GITHUB_STEP_SUMMARY" + infractl artifacts "${{ needs.create-cluster.outputs.cluster-name }}" -d "/home/runner/artifacts" >> "$GITHUB_STEP_SUMMARY" kubectl -n infra port-forward svc/infra-server-service 8443:8443 & sleep 10 @@ -88,3 +106,4 @@ jobs: endpoint: localhost:8443 insecure: true args: ${{ matrix.flavors.args }} + no-slack: true From 13f01717c19502d7373ee460917c0fcafba28e4d Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Tue, 5 Nov 2024 14:59:07 +0100 Subject: [PATCH 2/7] ifx action --- .github/workflows/smoke-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/smoke-test.yaml b/.github/workflows/smoke-test.yaml index fa9126631..03a97835a 100644 --- a/.github/workflows/smoke-test.yaml +++ b/.github/workflows/smoke-test.yaml @@ -37,7 +37,7 @@ jobs: run: | echo "cluster-name=daily-smoke-test-$(date +%s)" >> ${GITHUB_OUTPUT} - - uses: ./.actions/infra/create-cluster + - uses: stackrox/actions/infra/create-cluster@v1 with: token: ${{ secrets.INFRA_TOKEN }} flavor: gke-default From a64a7f958a47ad1be8987f52cf24815fa17cc923 Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Tue, 5 Nov 2024 15:15:20 +0100 Subject: [PATCH 3/7] fix wait --- .github/workflows/smoke-test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/smoke-test.yaml b/.github/workflows/smoke-test.yaml index 03a97835a..b90799e90 100644 --- a/.github/workflows/smoke-test.yaml +++ b/.github/workflows/smoke-test.yaml @@ -43,6 +43,7 @@ jobs: flavor: gke-default name: ${{ steps.determine-cluster-name.outputs.cluster-name }} lifespan: 8h + wait: true smoke-test: runs-on: ubuntu-latest From 1369ba3ca89398b616fb59602a97dc1a73c40710 Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Tue, 5 Nov 2024 15:31:53 +0100 Subject: [PATCH 4/7] deploy infra to the cluster --- .github/workflows/smoke-test.yaml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/smoke-test.yaml b/.github/workflows/smoke-test.yaml index b90799e90..9c96462ac 100644 --- a/.github/workflows/smoke-test.yaml +++ b/.github/workflows/smoke-test.yaml @@ -45,6 +45,35 @@ jobs: lifespan: 8h wait: true + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} + path: go/src/github.com/stackrox/infra + + - name: Authenticate to GCloud + uses: google-github-actions/auth@v2 + with: + credentials_json: ${{ secrets.INFRA_CI_AUTOMATION_GCP_SA }} + + - name: Set up Cloud SDK + uses: "google-github-actions/setup-gcloud@v2" + with: + install_components: "gke-gcloud-auth-plugin" + + - name: Download production infractl + uses: stackrox/actions/infra/install-infractl@v1 + + - name: Download artifacts + run: | + /github/home/.local/bin/infractl artifacts "${{ steps.determine-cluster-name.outputs.cluster-name }}" -d /github/home/artifacts >> "$GITHUB_STEP_SUMMARY" + kubectl get nodes -o wide || true + + - name: Deploy infra to smoke test cluster + run: | + ENVIRONMENT=development TEST_MODE=true make install-argo clean-argo-config install-monitoring helm-deploy + smoke-test: runs-on: ubuntu-latest needs: [create-cluster] From cceb0093f3952d7304742437e60f358f070bbdef Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Tue, 5 Nov 2024 15:48:32 +0100 Subject: [PATCH 5/7] fix home location --- .github/workflows/smoke-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/smoke-test.yaml b/.github/workflows/smoke-test.yaml index 9c96462ac..28a0c3e37 100644 --- a/.github/workflows/smoke-test.yaml +++ b/.github/workflows/smoke-test.yaml @@ -67,7 +67,7 @@ jobs: - name: Download artifacts run: | - /github/home/.local/bin/infractl artifacts "${{ steps.determine-cluster-name.outputs.cluster-name }}" -d /github/home/artifacts >> "$GITHUB_STEP_SUMMARY" + /home/runner/.local/bin/infractl artifacts "${{ steps.determine-cluster-name.outputs.cluster-name }}" -d /home/runner/artifacts >> "$GITHUB_STEP_SUMMARY" kubectl get nodes -o wide || true - name: Deploy infra to smoke test cluster From 9d09f2c64886507cf3bb6b48b2dd227ea32bc896 Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Tue, 5 Nov 2024 16:02:06 +0100 Subject: [PATCH 6/7] fix missing infra token --- .github/workflows/smoke-test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/smoke-test.yaml b/.github/workflows/smoke-test.yaml index 28a0c3e37..4f427062f 100644 --- a/.github/workflows/smoke-test.yaml +++ b/.github/workflows/smoke-test.yaml @@ -66,6 +66,8 @@ jobs: uses: stackrox/actions/infra/install-infractl@v1 - name: Download artifacts + env: + INFRA_TOKEN: ${{ secrets.INFRA_TOKEN }} run: | /home/runner/.local/bin/infractl artifacts "${{ steps.determine-cluster-name.outputs.cluster-name }}" -d /home/runner/artifacts >> "$GITHUB_STEP_SUMMARY" kubectl get nodes -o wide || true From 624accab66cd0f43f3077362c691a280d71d7d68 Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Tue, 5 Nov 2024 16:19:53 +0100 Subject: [PATCH 7/7] fix --- .github/workflows/smoke-test.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/smoke-test.yaml b/.github/workflows/smoke-test.yaml index 4f427062f..c273f5d6b 100644 --- a/.github/workflows/smoke-test.yaml +++ b/.github/workflows/smoke-test.yaml @@ -50,7 +50,6 @@ jobs: with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} - path: go/src/github.com/stackrox/infra - name: Authenticate to GCloud uses: google-github-actions/auth@v2 @@ -70,7 +69,6 @@ jobs: INFRA_TOKEN: ${{ secrets.INFRA_TOKEN }} run: | /home/runner/.local/bin/infractl artifacts "${{ steps.determine-cluster-name.outputs.cluster-name }}" -d /home/runner/artifacts >> "$GITHUB_STEP_SUMMARY" - kubectl get nodes -o wide || true - name: Deploy infra to smoke test cluster run: |