e2e.yml 5.9 KB

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