| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- # Run secret-dependent e2e tests only after /ok-to-test approval
- on:
- pull_request:
- repository_dispatch:
- types: [ok-to-test-command]
- env:
- # Common versions
- GO_VERSION: '1.17'
- GOLANGCI_VERSION: 'v1.33'
- GINKGO_VERSION: 'v2.1.4'
- DOCKER_BUILDX_VERSION: 'v0.4.2'
- KIND_VERSION: 'v0.11.1'
- KIND_IMAGE: 'kindest/node:v1.23.3'
- # Common users. We can't run a step 'if secrets.GHCR_USERNAME != ""' but we can run
- # a step 'if env.GHCR_USERNAME' != ""', so we copy these to succinctly test whether
- # credentials have been provided before trying to run steps that need them.
- GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
- GCP_SM_SA_JSON: ${{ secrets.GCP_SM_SA_JSON}}
- GCP_GKE_ZONE: ${{ secrets.GCP_GKE_ZONE}}
- GCP_GSA_NAME: ${{ secrets.GCP_GSA_NAME}} # Goolge Service Account
- GCP_KSA_NAME: ${{ secrets.GCP_KSA_NAME}} # Kubernetes Service Account
- GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID}}
- AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
- AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID}}
- AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET}}
- TENANT_ID: ${{ secrets.TENANT_ID}}
- VAULT_URL: ${{ secrets.VAULT_URL}}
- name: e2e tests
- jobs:
- # Branch-based pull request
- integration-trusted:
- runs-on: ubuntu-latest
- if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor !='dependabot[bot]'
- steps:
- - name: Branch based PR checkout
- uses: actions/checkout@v3
- # <insert integration tests needing secrets>
- - name: Fetch History
- run: git fetch --prune --unshallow
- - name: Setup Go
- uses: actions/setup-go@v3
- with:
- go-version: ${{ env.GO_VERSION }}
- - name: Find the Go Cache
- id: go
- run: |
- echo "::set-output name=build-cache::$(go env GOCACHE)"
- echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
- - name: Cache the Go Build Cache
- uses: actions/cache@v3
- with:
- path: ${{ steps.go.outputs.build-cache }}
- key: ${{ runner.os }}-build-unit-tests-${{ hashFiles('**/go.sum') }}
- restore-keys: ${{ runner.os }}-build-unit-tests-
- - name: Cache Go Dependencies
- uses: actions/cache@v3
- with:
- path: ${{ steps.go.outputs.mod-cache }}
- key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
- restore-keys: ${{ runner.os }}-pkg-
- - name: Setup kind
- uses: engineerd/setup-kind@v0.5.0
- with:
- version: ${{env.KIND_VERSION}}
- wait: 10m
- node_image: ${{env.KIND_IMAGE}}
- name: external-secrets
- - name: Setup Docker Buildx
- uses: docker/setup-buildx-action@v2
- with:
- version: ${{ env.DOCKER_BUILDX_VERSION }}
- install: true
- - name: Run e2e Tests
- env:
- BUILD_ARGS: "--load"
- run: |
- export PATH=$PATH:$(go env GOPATH)/bin
- go install github.com/onsi/ginkgo/v2/ginkgo@${{env.GINKGO_VERSION}}
- make test.e2e
- # Repo owner has commented /ok-to-test on a (fork-based) pull request
- integration-fork:
- runs-on: ubuntu-latest
- if:
- github.event_name == 'repository_dispatch'
- steps:
- # Check out merge commit
- - name: Fork based /ok-to-test checkout
- uses: actions/checkout@v3
- with:
- ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
- - name: Fetch History
- run: git fetch --prune --unshallow
- - name: Setup Go
- uses: actions/setup-go@v3
- with:
- go-version: ${{ env.GO_VERSION }}
- - name: Find the Go Cache
- id: go
- run: |
- echo "::set-output name=build-cache::$(go env GOCACHE)"
- echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
- - name: Cache the Go Build Cache
- uses: actions/cache@v3
- with:
- path: ${{ steps.go.outputs.build-cache }}
- key: ${{ runner.os }}-build-unit-tests-${{ hashFiles('**/go.sum') }}
- restore-keys: ${{ runner.os }}-build-unit-tests-
- - name: Cache Go Dependencies
- uses: actions/cache@v3
- with:
- path: ${{ steps.go.outputs.mod-cache }}
- key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
- restore-keys: ${{ runner.os }}-pkg-
- - name: Setup kind
- uses: engineerd/setup-kind@v0.5.0
- with:
- version: ${{env.KIND_VERSION}}
- wait: 10m
- node_image: ${{env.KIND_IMAGE}}
- name: external-secrets
- - name: Setup Docker Buildx
- uses: docker/setup-buildx-action@v2
- with:
- version: ${{ env.DOCKER_BUILDX_VERSION }}
- install: true
- - name: Run e2e Tests
- env:
- BUILD_ARGS: "--load"
- run: |
- export PATH=$PATH:$(go env GOPATH)/bin
- go install github.com/onsi/ginkgo/v2/ginkgo@${{env.GINKGO_VERSION}}
- make test.e2e
- # Update check run called "integration-fork"
- - uses: actions/github-script@v6
- id: update-check-run
- if: ${{ always() }}
- env:
- number: ${{ github.event.client_payload.pull_request.number }}
- job: ${{ github.job }}
- # Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
- conclusion: ${{ job.status }}
- with:
- github-token: ${{ secrets.GITHUB_TOKEN }}
- script: |
- const { data: pull } = await github.rest.pulls.get({
- ...context.repo,
- pull_number: process.env.number
- });
- const ref = pull.head.sha;
- console.log("\n\nPR sha: " + ref)
- const { data: checks } = await github.rest.checks.listForRef({
- ...context.repo,
- ref
- });
- console.log("\n\nPR CHECKS: " + checks)
- const check = checks.check_runs.filter(c => c.name === process.env.job);
- console.log("\n\nPR Filtered CHECK: " + check)
- console.log(check)
- const { data: result } = await github.rest.checks.update({
- ...context.repo,
- check_run_id: check[0].id,
- status: 'completed',
- conclusion: process.env.conclusion
- });
- return result;
|