diff --git a/.github/actions/smoke-tests/action.yaml b/.github/actions/smoke-tests/action.yaml index 92c5d75bf3..c5086a0273 100644 --- a/.github/actions/smoke-tests/action.yaml +++ b/.github/actions/smoke-tests/action.yaml @@ -16,6 +16,10 @@ inputs: description: Docker image to use default: debian required: false + test-image: + description: Test Docker image to use + default: gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/dev/test-runner:latest + required: false marker: description: Marker to use required: false @@ -77,16 +81,6 @@ runs: ${{ contains(inputs.image, 'plus') && format('"nginx-repo.key={0}"', inputs.nginx-key) || '' }} ${{ contains(inputs.image, 'ubi') && format('"rhel_license={0}"', inputs.rhel-license) || '' }} - - name: Build Test-Runner Container - uses: docker/build-push-action@v3 - with: - file: tests/Dockerfile - context: "." - cache-from: type=gha,scope=test-runner - tags: test-runner:${{ github.sha }} - pull: true - load: true - - name: Deploy Kubernetes id: k8s run: | @@ -105,14 +99,47 @@ runs: sed -i 's|server:.*|server: https://${{ steps.k8s.outputs.cluster_ip }}:6443|' ~/.kube/kind/config shell: bash + - name: Authenticate to Google Cloud + id: auth + uses: google-github-actions/auth@v2 + with: + token_format: access_token + workload_identity_provider: ${{ secrets.GCR_WORKLOAD_IDENTITY }} + service_account: ${{ secrets.GCR_SERVICE_ACCOUNT }} + + - name: Login to GCR + uses: docker/login-action@v3 + with: + registry: gcr.io + username: oauth2accesstoken + password: ${{ steps.auth.outputs.access_token }} + + - name: Check if image exists + id: check-image + run: | + docker inspect ${{ inputs.test-image }} + continue-on-error: true + + - name: Build Test-Runner Container + uses: docker/build-push-action@v3 + with: + file: tests/Dockerfile + context: "." + cache-from: type=gha,scope=test-runner + tags: ${{ inputs.test-image }} + pull: true + load: true + push: true + if: steps.check-image.outcome == 'failure' + - name: Run Smoke Tests run: | touch tests-${{ steps.k8s.outputs.cluster }}.html docker run --rm \ --name test-runner-${{ github.run_id }} \ --network=kind \ - -v ${{ github.workspace }}/tests/tests-${{ steps.k8s.outputs.cluster }}.html:/workspace/tests/tests-${{ steps.k8s.outputs.cluster }}.html \ - -v ~/.kube/kind/config:/root/.kube/config test-runner:${{ github.sha }} \ + -v ${{ github.workspace }}/tests:/workspace/tests \ + -v ~/.kube/kind/config:/root/.kube/config ${{ inputs.test-image }} \ --context=kind-${{ github.run_id }} \ --image=docker.io/nginx/${{ steps.ingress-type.outputs.name }}:${{ steps.ingress-type.outputs.tag }} \ --image-pull-policy=Never \ diff --git a/.github/workflows/build-test-image.yml b/.github/workflows/build-test-image.yml new file mode 100644 index 0000000000..fcd5a9a555 --- /dev/null +++ b/.github/workflows/build-test-image.yml @@ -0,0 +1,64 @@ +name: Build Test Image + +on: + schedule: + - cron: "0 03 * * *" # run every day at 03:00 UTC + workflow_dispatch: + inputs: + force: + description: "Force rebuild of test image" + required: false + default: "false" + push: + branches: + - mount-test-dir-on-smoke-tests + +defaults: + run: + shell: bash + +concurrency: + group: ${{ github.ref_name }}-ci + cancel-in-progress: true + +permissions: + contents: read + +jobs: + build: + name: Build test image + runs-on: ubuntu-22.04 + steps: + - name: Checkout Repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Docker Buildx + uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 + + - name: Authenticate to Google Cloud + id: auth + uses: google-github-actions/auth@f6de81663f7788d05bd15bcce18f0e57f23f0846 # v2.0.1 + with: + token_format: access_token + workload_identity_provider: ${{ secrets.GCR_WORKLOAD_IDENTITY }} + service_account: ${{ secrets.GCR_SERVICE_ACCOUNT }} + + - name: Login to GCR + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + with: + registry: gcr.io + username: oauth2accesstoken + password: ${{ steps.auth.outputs.access_token }} + + - name: Build Test-Runner Container + uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0 + with: + file: tests/Dockerfile + context: "." + cache-from: type=gha,scope=test-runner + tags: | + gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/dev/test-runner:${{ hashFiles('./tests/requirements.txt') }} + gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/dev/test-runner:latest + load: true + pull: true + push: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dcc8bbc051..802acce835 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -361,6 +361,7 @@ jobs: azure-ad-secret: ${{ secrets.AZURE_AD_AUTOMATION }} rhel-license: ${{ contains(matrix.images.image, 'ubi') && secrets.RHEL_LICENSE || '' }} go-md5: ${{ needs.checks.outputs.go_code_md5 }} + test-image: "gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/dev/test-runner:${{ hashFiles('./tests/requirements.txt') || 'latest' }}" - name: Upload Test Results uses: actions/upload-artifact@1eb3cb2b3e0f29609092a73eb033bb759a334595 # v4.1.0