e2e.yml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. # Run secret-dependent e2e tests only after /ok-to-test approval
  2. on:
  3. pull_request:
  4. repository_dispatch:
  5. types: [ok-to-test-command]
  6. env:
  7. # Common versions
  8. GO_VERSION: '1.16'
  9. GOLANGCI_VERSION: 'v1.33'
  10. DOCKER_BUILDX_VERSION: 'v0.4.2'
  11. # Common users. We can't run a step 'if secrets.GHCR_USERNAME != ""' but we can run
  12. # a step 'if env.GHCR_USERNAME' != ""', so we copy these to succinctly test whether
  13. # credentials have been provided before trying to run steps that need them.
  14. GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
  15. GCP_SM_SA_JSON: ${{ secrets.GCP_SM_SA_JSON}}
  16. GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID}}
  17. AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID}}
  18. AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET}}
  19. TENANT_ID: ${{ secrets.TENANT_ID}}
  20. VAULT_URL: ${{ secrets.VAULT_URL}}
  21. name: e2e tests
  22. jobs:
  23. # Branch-based pull request
  24. integration-trusted:
  25. runs-on: ubuntu-latest
  26. if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
  27. steps:
  28. - name: Branch based PR checkout
  29. uses: actions/checkout@v2
  30. # <insert integration tests needing secrets>
  31. - name: Fetch History
  32. run: git fetch --prune --unshallow
  33. - name: Setup Go
  34. uses: actions/setup-go@v2
  35. with:
  36. go-version: ${{ env.GO_VERSION }}
  37. - name: Find the Go Cache
  38. id: go
  39. run: |
  40. echo "::set-output name=build-cache::$(go env GOCACHE)"
  41. echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
  42. - name: Cache the Go Build Cache
  43. uses: actions/cache@v2.1.6
  44. with:
  45. path: ${{ steps.go.outputs.build-cache }}
  46. key: ${{ runner.os }}-build-unit-tests-${{ hashFiles('**/go.sum') }}
  47. restore-keys: ${{ runner.os }}-build-unit-tests-
  48. - name: Cache Go Dependencies
  49. uses: actions/cache@v2.1.6
  50. with:
  51. path: ${{ steps.go.outputs.mod-cache }}
  52. key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
  53. restore-keys: ${{ runner.os }}-pkg-
  54. - name: Setup kind
  55. uses: engineerd/setup-kind@v0.5.0
  56. with:
  57. version: "v0.11.1"
  58. wait: 10m
  59. node_image: kindest/node:v1.20.7
  60. name: external-secrets
  61. - name: Setup Docker Buildx
  62. uses: docker/setup-buildx-action@v1
  63. with:
  64. version: ${{ env.DOCKER_BUILDX_VERSION }}
  65. install: true
  66. - name: Run e2e Tests
  67. env:
  68. BUILD_ARGS: "--load"
  69. run: |
  70. export PATH=$PATH:$(go env GOPATH)/bin
  71. go get github.com/onsi/ginkgo/ginkgo
  72. make test.e2e
  73. # Repo owner has commented /ok-to-test on a (fork-based) pull request
  74. integration-fork:
  75. runs-on: ubuntu-latest
  76. if:
  77. github.event_name == 'repository_dispatch' &&
  78. github.event.client_payload.slash_command.args.named.sha != ''
  79. steps:
  80. # Check out merge commit
  81. - name: Fork based /ok-to-test checkout
  82. uses: actions/checkout@v2
  83. with:
  84. ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
  85. - name: Fetch History
  86. run: git fetch --prune --unshallow
  87. - name: Setup Go
  88. uses: actions/setup-go@v2
  89. with:
  90. go-version: ${{ env.GO_VERSION }}
  91. - name: Find the Go Cache
  92. id: go
  93. run: |
  94. echo "::set-output name=build-cache::$(go env GOCACHE)"
  95. echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
  96. - name: Cache the Go Build Cache
  97. uses: actions/cache@v2.1.6
  98. with:
  99. path: ${{ steps.go.outputs.build-cache }}
  100. key: ${{ runner.os }}-build-unit-tests-${{ hashFiles('**/go.sum') }}
  101. restore-keys: ${{ runner.os }}-build-unit-tests-
  102. - name: Cache Go Dependencies
  103. uses: actions/cache@v2.1.6
  104. with:
  105. path: ${{ steps.go.outputs.mod-cache }}
  106. key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
  107. restore-keys: ${{ runner.os }}-pkg-
  108. - name: Setup kind
  109. uses: engineerd/setup-kind@v0.5.0
  110. with:
  111. version: "v0.11.1"
  112. wait: 10m
  113. node_image: kindest/node:v1.20.7
  114. name: external-secrets
  115. - name: Setup Docker Buildx
  116. uses: docker/setup-buildx-action@v1
  117. with:
  118. version: ${{ env.DOCKER_BUILDX_VERSION }}
  119. install: true
  120. - name: Run e2e Tests
  121. env:
  122. BUILD_ARGS: "--load"
  123. run: |
  124. export PATH=$PATH:$(go env GOPATH)/bin
  125. go get github.com/onsi/ginkgo/ginkgo
  126. make test.e2e
  127. # Update check run called "integration-fork"
  128. - uses: actions/github-script@v4.1
  129. id: update-check-run
  130. if: ${{ always() }}
  131. env:
  132. number: ${{ github.event.client_payload.pull_request.number }}
  133. job: ${{ github.job }}
  134. # Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
  135. conclusion: ${{ job.status }}
  136. with:
  137. github-token: ${{ secrets.GITHUB_TOKEN }}
  138. script: |
  139. const { data: pull } = await github.pulls.get({
  140. ...context.repo,
  141. pull_number: process.env.number
  142. });
  143. const ref = pull.head.sha;
  144. const { data: checks } = await github.checks.listForRef({
  145. ...context.repo,
  146. ref
  147. });
  148. const check = checks.check_runs.filter(c => c.name === process.env.job);
  149. const { data: result } = await github.checks.update({
  150. ...context.repo,
  151. check_run_id: check[0].id,
  152. status: 'completed',
  153. conclusion: process.env.conclusion
  154. });
  155. return result;