e2e.yml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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.15'
  9. GOLANGCI_VERSION: 'v1.33'
  10. KUBEBUILDER_VERSION: '2.3.1'
  11. DOCKER_BUILDX_VERSION: 'v0.4.2'
  12. # Common users. We can't run a step 'if secrets.GHCR_USERNAME != ""' but we can run
  13. # a step 'if env.GHCR_USERNAME' != ""', so we copy these to succinctly test whether
  14. # credentials have been provided before trying to run steps that need them.
  15. GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
  16. GCP_SM_SA_JSON: ${{ secrets.GCP_SM_SA_JSON}}
  17. name: e2e tests
  18. jobs:
  19. # Branch-based pull request
  20. integration-trusted:
  21. runs-on: ubuntu-latest
  22. if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
  23. steps:
  24. - name: Branch based PR checkout
  25. uses: actions/checkout@v2
  26. # <insert integration tests needing secrets>
  27. - name: Fetch History
  28. run: git fetch --prune --unshallow
  29. - name: Setup Go
  30. uses: actions/setup-go@v2
  31. with:
  32. go-version: ${{ env.GO_VERSION }}
  33. - name: Find the Go Cache
  34. id: go
  35. run: |
  36. echo "::set-output name=build-cache::$(go env GOCACHE)"
  37. echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
  38. - name: Cache the Go Build Cache
  39. uses: actions/cache@v2.1.6
  40. with:
  41. path: ${{ steps.go.outputs.build-cache }}
  42. key: ${{ runner.os }}-build-unit-tests-${{ hashFiles('**/go.sum') }}
  43. restore-keys: ${{ runner.os }}-build-unit-tests-
  44. - name: Cache Go Dependencies
  45. uses: actions/cache@v2.1.6
  46. with:
  47. path: ${{ steps.go.outputs.mod-cache }}
  48. key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
  49. restore-keys: ${{ runner.os }}-pkg-
  50. - name: Add kubebuilder
  51. run: |
  52. curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${{env.KUBEBUILDER_VERSION}}/kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz > kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
  53. tar -xvf kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
  54. sudo mv kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64 /usr/local/kubebuilder
  55. - name: Cache kubebuilder
  56. uses: actions/cache@v2.1.6
  57. with:
  58. path: /usr/local/kubebuilder
  59. key: ${{ runner.os }}-kubebuilder-${{env.KUBEBUILDER_VERSION}}
  60. restore-keys: ${{ runner.os }}-kubebuilder-
  61. - name: Setup kind
  62. uses: engineerd/setup-kind@v0.5.0
  63. with:
  64. version: "v0.10.0"
  65. node_image: kindest/node:v1.20.2
  66. name: external-secrets
  67. - name: Run e2e Tests
  68. run: |
  69. export PATH=$PATH:$(go env GOPATH)/bin
  70. go get github.com/onsi/ginkgo/ginkgo
  71. make test.e2e
  72. # Repo owner has commented /ok-to-test on a (fork-based) pull request
  73. integration-fork:
  74. runs-on: ubuntu-latest
  75. if:
  76. github.event_name == 'repository_dispatch' &&
  77. github.event.client_payload.slash_command.sha != '' &&
  78. contains(github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.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: Add kubebuilder
  109. run: |
  110. curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${{env.KUBEBUILDER_VERSION}}/kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz > kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
  111. tar -xvf kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
  112. sudo mv kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64 /usr/local/kubebuilder
  113. - name: Cache kubebuilder
  114. uses: actions/cache@v2.1.6
  115. with:
  116. path: /usr/local/kubebuilder
  117. key: ${{ runner.os }}-kubebuilder-${{env.KUBEBUILDER_VERSION}}
  118. restore-keys: ${{ runner.os }}-kubebuilder-
  119. - name: Setup kind
  120. uses: engineerd/setup-kind@v0.5.0
  121. with:
  122. version: "v0.10.0"
  123. node_image: kindest/node:v1.20.2
  124. name: external-secrets
  125. - name: Run e2e Tests
  126. run: |
  127. export PATH=$PATH:$(go env GOPATH)/bin
  128. go get github.com/onsi/ginkgo/ginkgo
  129. make test.e2e
  130. # Update check run called "integration-fork"
  131. - uses: actions/github-script@v1
  132. id: update-check-run
  133. if: ${{ always() }}
  134. env:
  135. number: ${{ github.event.client_payload.pull_request.number }}
  136. job: ${{ github.job }}
  137. # Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
  138. conclusion: ${{ job.status }}
  139. with:
  140. github-token: ${{ secrets.GITHUB_TOKEN }}
  141. script: |
  142. const { data: pull } = await github.pulls.get({
  143. ...context.repo,
  144. pull_number: process.env.number
  145. });
  146. const ref = pull.head.sha;
  147. const { data: checks } = await github.checks.listForRef({
  148. ...context.repo,
  149. ref
  150. });
  151. const check = checks.check_runs.filter(c => c.name === process.env.job);
  152. const { data: result } = await github.checks.update({
  153. ...context.repo,
  154. check_run_id: check[0].id,
  155. status: 'completed',
  156. conclusion: process.env.conclusion
  157. });
  158. return result;