e2e.yml 6.0 KB

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