e2e.yml 5.8 KB

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