2021-06-13 13:28:52 +00:00
|
|
|
# Run secret-dependent e2e tests only after /ok-to-test approval
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
repository_dispatch:
|
|
|
|
types: [ok-to-test-command]
|
|
|
|
|
|
|
|
env:
|
|
|
|
# Common versions
|
2022-09-06 17:46:36 +00:00
|
|
|
GO_VERSION: '1.19'
|
|
|
|
GINKGO_VERSION: 'v2.1.6'
|
2021-06-13 13:28:52 +00:00
|
|
|
DOCKER_BUILDX_VERSION: 'v0.4.2'
|
2022-08-19 15:32:06 +00:00
|
|
|
KIND_VERSION: 'v0.14.0'
|
|
|
|
KIND_IMAGE: 'kindest/node:v1.24.2'
|
2021-06-13 13:28:52 +00:00
|
|
|
|
|
|
|
# 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 }}
|
2021-06-18 10:14:48 +00:00
|
|
|
GCP_SM_SA_JSON: ${{ secrets.GCP_SM_SA_JSON}}
|
2021-12-29 12:02:56 +00:00
|
|
|
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
|
2021-07-12 18:27:48 +00:00
|
|
|
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID}}
|
2022-01-21 20:05:37 +00:00
|
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
2021-06-29 12:48:49 +00:00
|
|
|
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID}}
|
|
|
|
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET}}
|
|
|
|
TENANT_ID: ${{ secrets.TENANT_ID}}
|
|
|
|
VAULT_URL: ${{ secrets.VAULT_URL}}
|
2021-06-13 13:28:52 +00:00
|
|
|
|
|
|
|
name: e2e tests
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
# Branch-based pull request
|
|
|
|
integration-trusted:
|
|
|
|
runs-on: ubuntu-latest
|
2022-08-03 13:30:08 +00:00
|
|
|
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor !='dependabot[bot]'
|
2021-06-13 13:28:52 +00:00
|
|
|
steps:
|
|
|
|
|
|
|
|
- name: Branch based PR checkout
|
2022-03-07 08:06:46 +00:00
|
|
|
uses: actions/checkout@v3
|
2021-06-13 13:28:52 +00:00
|
|
|
|
|
|
|
# <insert integration tests needing secrets>
|
|
|
|
|
|
|
|
- name: Fetch History
|
|
|
|
run: git fetch --prune --unshallow
|
|
|
|
|
|
|
|
- name: Setup Go
|
2022-04-11 08:06:16 +00:00
|
|
|
uses: actions/setup-go@v3
|
2021-06-13 13:28:52 +00:00
|
|
|
with:
|
2022-09-15 15:17:52 +00:00
|
|
|
go-version-file: "go.mod"
|
2021-06-13 13:28:52 +00:00
|
|
|
|
|
|
|
- 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
|
2022-03-28 08:07:03 +00:00
|
|
|
uses: actions/cache@v3
|
2021-06-13 13:28:52 +00:00
|
|
|
with:
|
|
|
|
path: ${{ steps.go.outputs.build-cache }}
|
2022-09-06 17:46:36 +00:00
|
|
|
key: ${{ runner.os }}-build-unit-tests-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: ${{ runner.os }}-build-unit-tests-${{ github.sha }}-
|
2021-06-13 13:28:52 +00:00
|
|
|
|
|
|
|
- name: Cache Go Dependencies
|
2022-03-28 08:07:03 +00:00
|
|
|
uses: actions/cache@v3
|
2021-06-13 13:28:52 +00:00
|
|
|
with:
|
|
|
|
path: ${{ steps.go.outputs.mod-cache }}
|
2022-09-06 17:46:36 +00:00
|
|
|
key: ${{ runner.os }}-pkg-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: ${{ runner.os }}-pkg-${{ github.sha }}-
|
2021-06-13 13:28:52 +00:00
|
|
|
|
|
|
|
- name: Setup kind
|
|
|
|
uses: engineerd/setup-kind@v0.5.0
|
|
|
|
with:
|
2022-01-28 18:51:07 +00:00
|
|
|
version: ${{env.KIND_VERSION}}
|
2021-07-02 09:56:10 +00:00
|
|
|
wait: 10m
|
2022-01-28 18:51:07 +00:00
|
|
|
node_image: ${{env.KIND_IMAGE}}
|
2021-06-13 13:28:52 +00:00
|
|
|
name: external-secrets
|
|
|
|
|
2021-07-21 15:00:43 +00:00
|
|
|
- name: Setup Docker Buildx
|
2022-05-09 08:05:33 +00:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2021-07-21 15:00:43 +00:00
|
|
|
with:
|
|
|
|
version: ${{ env.DOCKER_BUILDX_VERSION }}
|
|
|
|
install: true
|
|
|
|
|
2021-06-13 13:28:52 +00:00
|
|
|
- name: Run e2e Tests
|
2021-07-21 15:00:43 +00:00
|
|
|
env:
|
|
|
|
BUILD_ARGS: "--load"
|
2021-06-13 13:28:52 +00:00
|
|
|
run: |
|
|
|
|
export PATH=$PATH:$(go env GOPATH)/bin
|
2022-04-27 18:31:14 +00:00
|
|
|
go install github.com/onsi/ginkgo/v2/ginkgo@${{env.GINKGO_VERSION}}
|
2021-06-13 13:28:52 +00:00
|
|
|
make test.e2e
|
|
|
|
|
|
|
|
# Repo owner has commented /ok-to-test on a (fork-based) pull request
|
|
|
|
integration-fork:
|
|
|
|
runs-on: ubuntu-latest
|
2021-06-25 23:56:42 +00:00
|
|
|
if:
|
2021-09-22 21:50:33 +00:00
|
|
|
github.event_name == 'repository_dispatch'
|
2021-06-13 13:28:52 +00:00
|
|
|
steps:
|
|
|
|
|
|
|
|
# Check out merge commit
|
|
|
|
- name: Fork based /ok-to-test checkout
|
2022-03-07 08:06:46 +00:00
|
|
|
uses: actions/checkout@v3
|
2021-06-13 13:28:52 +00:00
|
|
|
with:
|
|
|
|
ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
|
|
|
|
|
|
|
|
- name: Fetch History
|
|
|
|
run: git fetch --prune --unshallow
|
|
|
|
|
|
|
|
- name: Setup Go
|
2022-04-11 08:06:16 +00:00
|
|
|
uses: actions/setup-go@v3
|
2021-06-13 13:28:52 +00:00
|
|
|
with:
|
2022-09-15 15:17:52 +00:00
|
|
|
go-version-file: "go.mod"
|
2021-06-13 13:28:52 +00:00
|
|
|
|
|
|
|
- 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
|
2022-03-28 08:07:03 +00:00
|
|
|
uses: actions/cache@v3
|
2021-06-13 13:28:52 +00:00
|
|
|
with:
|
|
|
|
path: ${{ steps.go.outputs.build-cache }}
|
2022-09-06 17:46:36 +00:00
|
|
|
key: ${{ runner.os }}-build-unit-tests-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: ${{ runner.os }}-build-unit-tests-${{ github.sha }}-
|
2021-06-13 13:28:52 +00:00
|
|
|
|
|
|
|
- name: Cache Go Dependencies
|
2022-03-28 08:07:03 +00:00
|
|
|
uses: actions/cache@v3
|
2021-06-13 13:28:52 +00:00
|
|
|
with:
|
|
|
|
path: ${{ steps.go.outputs.mod-cache }}
|
2022-09-06 17:46:36 +00:00
|
|
|
key: ${{ runner.os }}-pkg-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: ${{ runner.os }}-pkg-${{ github.sha }}-
|
2021-06-13 13:28:52 +00:00
|
|
|
|
|
|
|
- name: Setup kind
|
|
|
|
uses: engineerd/setup-kind@v0.5.0
|
|
|
|
with:
|
2022-01-28 18:51:07 +00:00
|
|
|
version: ${{env.KIND_VERSION}}
|
2021-07-02 09:56:10 +00:00
|
|
|
wait: 10m
|
2022-01-28 18:51:07 +00:00
|
|
|
node_image: ${{env.KIND_IMAGE}}
|
2021-06-13 13:28:52 +00:00
|
|
|
name: external-secrets
|
|
|
|
|
2021-07-21 15:00:43 +00:00
|
|
|
- name: Setup Docker Buildx
|
2022-05-09 08:05:33 +00:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2021-07-21 15:00:43 +00:00
|
|
|
with:
|
|
|
|
version: ${{ env.DOCKER_BUILDX_VERSION }}
|
|
|
|
install: true
|
|
|
|
|
2021-06-13 13:28:52 +00:00
|
|
|
- name: Run e2e Tests
|
2021-07-21 15:00:43 +00:00
|
|
|
env:
|
|
|
|
BUILD_ARGS: "--load"
|
2021-06-13 13:28:52 +00:00
|
|
|
run: |
|
|
|
|
export PATH=$PATH:$(go env GOPATH)/bin
|
2022-04-27 18:31:14 +00:00
|
|
|
go install github.com/onsi/ginkgo/v2/ginkgo@${{env.GINKGO_VERSION}}
|
2021-06-13 13:28:52 +00:00
|
|
|
make test.e2e
|
|
|
|
|
|
|
|
# Update check run called "integration-fork"
|
2022-02-14 08:05:09 +00:00
|
|
|
- uses: actions/github-script@v6
|
2021-06-13 13:28:52 +00:00
|
|
|
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
|
2021-06-25 23:56:42 +00:00
|
|
|
conclusion: ${{ job.status }}
|
2021-06-13 13:28:52 +00:00
|
|
|
with:
|
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
script: |
|
2022-02-15 15:08:41 +00:00
|
|
|
const { data: pull } = await github.rest.pulls.get({
|
2021-06-13 13:28:52 +00:00
|
|
|
...context.repo,
|
|
|
|
pull_number: process.env.number
|
|
|
|
});
|
|
|
|
const ref = pull.head.sha;
|
2021-11-15 15:47:09 +00:00
|
|
|
console.log("\n\nPR sha: " + ref)
|
2022-02-15 15:08:41 +00:00
|
|
|
const { data: checks } = await github.rest.checks.listForRef({
|
2021-06-13 13:28:52 +00:00
|
|
|
...context.repo,
|
|
|
|
ref
|
|
|
|
});
|
2021-11-15 15:47:09 +00:00
|
|
|
console.log("\n\nPR CHECKS: " + checks)
|
2021-06-13 13:28:52 +00:00
|
|
|
const check = checks.check_runs.filter(c => c.name === process.env.job);
|
2021-11-15 15:47:09 +00:00
|
|
|
console.log("\n\nPR Filtered CHECK: " + check)
|
|
|
|
console.log(check)
|
2022-02-15 15:08:41 +00:00
|
|
|
const { data: result } = await github.rest.checks.update({
|
2021-06-13 13:28:52 +00:00
|
|
|
...context.repo,
|
2021-11-15 15:47:09 +00:00
|
|
|
check_run_id: check[0].id,
|
2021-06-13 13:28:52 +00:00
|
|
|
status: 'completed',
|
|
|
|
conclusion: process.env.conclusion
|
|
|
|
});
|
|
|
|
return result;
|