e2e.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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. permissions:
  7. contents: read
  8. name: e2e tests
  9. env:
  10. # Common versions
  11. KIND_VERSION: 'v0.30.0'
  12. KIND_IMAGE: 'kindest/node:v1.33.4'
  13. # SHA under test on the fork path. Two dispatchers populate it: an explicit
  14. # `/ok-to-test sha=<sha>` comment (ok-to-test.yml) or a PR review whose body
  15. # carries /ok-to-test (ok-to-test-review.yml, pinned to the reviewed
  16. # commit_id). A bare comment leaves it empty and guard-fork rejects the run
  17. # rather than testing the PR head or main. Also empty on the trusted
  18. # pull_request path, where the checkout falls back to github.sha.
  19. TARGET_SHA: ${{ github.event.client_payload.slash_command.args.named.sha }}
  20. AWS_REGION: "eu-central-1"
  21. jobs:
  22. # Same-repo pull request: build and test run as two jobs on separate runners.
  23. integration-trusted:
  24. permissions:
  25. id-token: write # for oidc auth with aws/gcp/azure
  26. contents: read # for checkout
  27. if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor !='dependabot[bot]'
  28. uses: ./.github/workflows/e2e-reusable.yml
  29. secrets:
  30. GCP_SERVICE_ACCOUNT_KEY: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
  31. GCP_FED_REGION: ${{ secrets.GCP_FED_REGION }}
  32. GCP_GSA_NAME: ${{ secrets.GCP_GSA_NAME }}
  33. GCP_KSA_NAME: ${{ secrets.GCP_KSA_NAME }}
  34. GCP_FED_PROJECT_ID: ${{ secrets.GCP_FED_PROJECT_ID }}
  35. AWS_OIDC_ROLE_ARN: ${{ secrets.AWS_OIDC_ROLE_ARN }}
  36. AWS_SA_NAME: ${{ secrets.AWS_SA_NAME }}
  37. AWS_SA_NAMESPACE: ${{ secrets.AWS_SA_NAMESPACE }}
  38. TFC_AZURE_CLIENT_ID: ${{ secrets.TFC_AZURE_CLIENT_ID }}
  39. TFC_AZURE_CLIENT_SECRET: ${{ secrets.TFC_AZURE_CLIENT_SECRET }}
  40. TFC_AZURE_TENANT_ID: ${{ secrets.TFC_AZURE_TENANT_ID }}
  41. TFC_AZURE_SUBSCRIPTION_ID: ${{ secrets.TFC_AZURE_SUBSCRIPTION_ID }}
  42. TFC_VAULT_URL: ${{ secrets.TFC_VAULT_URL }}
  43. SCALEWAY_API_URL: ${{ secrets.SCALEWAY_API_URL }}
  44. SCALEWAY_REGION: ${{ secrets.SCALEWAY_REGION }}
  45. SCALEWAY_PROJECT_ID: ${{ secrets.SCALEWAY_PROJECT_ID }}
  46. SCALEWAY_ACCESS_KEY: ${{ secrets.SCALEWAY_ACCESS_KEY }}
  47. SCALEWAY_SECRET_KEY: ${{ secrets.SCALEWAY_SECRET_KEY }}
  48. DELINEA_TLD: ${{ secrets.DELINEA_TLD }}
  49. DELINEA_URL_TEMPLATE: ${{ secrets.DELINEA_URL_TEMPLATE }}
  50. DELINEA_TENANT: ${{ secrets.DELINEA_TENANT }}
  51. DELINEA_CLIENT_ID: ${{ secrets.DELINEA_CLIENT_ID }}
  52. DELINEA_CLIENT_SECRET: ${{ secrets.DELINEA_CLIENT_SECRET }}
  53. SECRETSERVER_USERNAME: ${{ secrets.SECRETSERVER_USERNAME }}
  54. SECRETSERVER_PASSWORD: ${{ secrets.SECRETSERVER_PASSWORD }}
  55. SECRETSERVER_URL: ${{ secrets.SECRETSERVER_URL }}
  56. GRAFANA_URL: ${{ secrets.GRAFANA_URL }}
  57. GRAFANA_TOKEN: ${{ secrets.GRAFANA_TOKEN }}
  58. AKEYLESS_ACCESS_ID: ${{ secrets.AKEYLESS_ACCESS_ID }}
  59. AKEYLESS_ACCESS_TYPE: ${{ secrets.AKEYLESS_ACCESS_TYPE }}
  60. AKEYLESS_ACCESS_TYPE_PARAM: ${{ secrets.AKEYLESS_ACCESS_TYPE_PARAM }}
  61. GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
  62. GITLAB_PROJECT_ID: ${{ secrets.GITLAB_PROJECT_ID }}
  63. GITLAB_ENVIRONMENT: ${{ secrets.GITLAB_ENVIRONMENT }}
  64. ORACLE_USER_OCID: ${{ secrets.ORACLE_USER_OCID }}
  65. ORACLE_TENANCY_OCID: ${{ secrets.ORACLE_TENANCY_OCID }}
  66. ORACLE_REGION: ${{ secrets.ORACLE_REGION }}
  67. ORACLE_FINGERPRINT: ${{ secrets.ORACLE_FINGERPRINT }}
  68. ORACLE_KEY: ${{ secrets.ORACLE_KEY }}
  69. ORACLE_VAULT_OCID: ${{ secrets.ORACLE_VAULT_OCID }}
  70. ORACLE_COMPARTMENT_OCID: ${{ secrets.ORACLE_COMPARTMENT_OCID }}
  71. ORACLE_ENCRYPTION_KEY_OCID: ${{ secrets.ORACLE_ENCRYPTION_KEY_OCID }}
  72. # A /ok-to-test *comment* must carry an explicit sha=. A bare comment has no
  73. # trustworthy pinned commit (the dispatch would otherwise read the live PR
  74. # head, which a later push can move), so reject it here instead of testing the
  75. # wrong code. Reviews carry commit_id and arrive already pinned via
  76. # ok-to-test-review.yml, so this guard never fires for them.
  77. guard-fork:
  78. if: github.event_name == 'repository_dispatch'
  79. runs-on: ubuntu-latest
  80. permissions:
  81. pull-requests: write # to explain a rejected /ok-to-test on the PR
  82. contents: read
  83. steps:
  84. - uses: step-security/harden-runner@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
  85. with:
  86. egress-policy: audit
  87. # Require a full 40-char commit SHA. This rejects a bare /ok-to-test (empty
  88. # TARGET_SHA) and a malformed sha= (e.g. a branch name like `main`, a short
  89. # SHA, or a flag), so the checkout ref is always a pinned commit. The review
  90. # path supplies review.commit_id, which is always a full SHA.
  91. - name: Validate the target sha
  92. id: check
  93. run: |
  94. if printf '%s' "$TARGET_SHA" | grep -qE '^[0-9a-fA-F]{40}$'; then
  95. echo "valid=true" >> "$GITHUB_OUTPUT"
  96. echo "target sha $TARGET_SHA"
  97. else
  98. echo "valid=false" >> "$GITHUB_OUTPUT"
  99. fi
  100. - name: Generate token
  101. id: create_token
  102. if: steps.check.outputs.valid == 'false'
  103. uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
  104. env:
  105. APP_ID: ${{ secrets.APP_ID }}
  106. with:
  107. app-id: ${{ env.APP_ID }}
  108. private-key: ${{ secrets.PRIVATE_KEY }}
  109. owner: ${{ github.repository_owner }}
  110. repositories: ${{ github.event.repository.name }}
  111. permission-issues: write
  112. permission-pull-requests: write
  113. - name: Explain the rejection on the PR
  114. if: steps.check.outputs.valid == 'false'
  115. uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
  116. with:
  117. token: ${{ steps.create_token.outputs.token }}
  118. issue-number: ${{ github.event.client_payload.pull_request.number }}
  119. body: |
  120. [Bot] - :warning: A `/ok-to-test` comment needs an explicit full commit SHA: `/ok-to-test sha=<40-char-sha>`. Alternatively submit a PR review (Approve or Comment) whose body contains `/ok-to-test` to test the exact commit you reviewed.
  121. - name: Fail without a valid target sha
  122. if: steps.check.outputs.valid == 'false'
  123. run: |
  124. echo "::error::/ok-to-test needs sha=<full 40-char commit SHA>; refusing to fall back to the PR head or main"
  125. exit 1
  126. # Repo owner approved a fork PR via /ok-to-test (comment with sha= or review).
  127. integration-fork:
  128. permissions:
  129. id-token: write # for oidc auth with aws/gcp/azure
  130. contents: read # for checkout
  131. needs: guard-fork
  132. if: github.event_name == 'repository_dispatch'
  133. uses: ./.github/workflows/e2e-reusable.yml
  134. secrets:
  135. GCP_SERVICE_ACCOUNT_KEY: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
  136. GCP_FED_REGION: ${{ secrets.GCP_FED_REGION }}
  137. GCP_GSA_NAME: ${{ secrets.GCP_GSA_NAME }}
  138. GCP_KSA_NAME: ${{ secrets.GCP_KSA_NAME }}
  139. GCP_FED_PROJECT_ID: ${{ secrets.GCP_FED_PROJECT_ID }}
  140. AWS_OIDC_ROLE_ARN: ${{ secrets.AWS_OIDC_ROLE_ARN }}
  141. AWS_SA_NAME: ${{ secrets.AWS_SA_NAME }}
  142. AWS_SA_NAMESPACE: ${{ secrets.AWS_SA_NAMESPACE }}
  143. TFC_AZURE_CLIENT_ID: ${{ secrets.TFC_AZURE_CLIENT_ID }}
  144. TFC_AZURE_CLIENT_SECRET: ${{ secrets.TFC_AZURE_CLIENT_SECRET }}
  145. TFC_AZURE_TENANT_ID: ${{ secrets.TFC_AZURE_TENANT_ID }}
  146. TFC_AZURE_SUBSCRIPTION_ID: ${{ secrets.TFC_AZURE_SUBSCRIPTION_ID }}
  147. TFC_VAULT_URL: ${{ secrets.TFC_VAULT_URL }}
  148. SCALEWAY_API_URL: ${{ secrets.SCALEWAY_API_URL }}
  149. SCALEWAY_REGION: ${{ secrets.SCALEWAY_REGION }}
  150. SCALEWAY_PROJECT_ID: ${{ secrets.SCALEWAY_PROJECT_ID }}
  151. SCALEWAY_ACCESS_KEY: ${{ secrets.SCALEWAY_ACCESS_KEY }}
  152. SCALEWAY_SECRET_KEY: ${{ secrets.SCALEWAY_SECRET_KEY }}
  153. DELINEA_TLD: ${{ secrets.DELINEA_TLD }}
  154. DELINEA_URL_TEMPLATE: ${{ secrets.DELINEA_URL_TEMPLATE }}
  155. DELINEA_TENANT: ${{ secrets.DELINEA_TENANT }}
  156. DELINEA_CLIENT_ID: ${{ secrets.DELINEA_CLIENT_ID }}
  157. DELINEA_CLIENT_SECRET: ${{ secrets.DELINEA_CLIENT_SECRET }}
  158. SECRETSERVER_USERNAME: ${{ secrets.SECRETSERVER_USERNAME }}
  159. SECRETSERVER_PASSWORD: ${{ secrets.SECRETSERVER_PASSWORD }}
  160. SECRETSERVER_URL: ${{ secrets.SECRETSERVER_URL }}
  161. GRAFANA_URL: ${{ secrets.GRAFANA_URL }}
  162. GRAFANA_TOKEN: ${{ secrets.GRAFANA_TOKEN }}
  163. AKEYLESS_ACCESS_ID: ${{ secrets.AKEYLESS_ACCESS_ID }}
  164. AKEYLESS_ACCESS_TYPE: ${{ secrets.AKEYLESS_ACCESS_TYPE }}
  165. AKEYLESS_ACCESS_TYPE_PARAM: ${{ secrets.AKEYLESS_ACCESS_TYPE_PARAM }}
  166. GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
  167. GITLAB_PROJECT_ID: ${{ secrets.GITLAB_PROJECT_ID }}
  168. GITLAB_ENVIRONMENT: ${{ secrets.GITLAB_ENVIRONMENT }}
  169. ORACLE_USER_OCID: ${{ secrets.ORACLE_USER_OCID }}
  170. ORACLE_TENANCY_OCID: ${{ secrets.ORACLE_TENANCY_OCID }}
  171. ORACLE_REGION: ${{ secrets.ORACLE_REGION }}
  172. ORACLE_FINGERPRINT: ${{ secrets.ORACLE_FINGERPRINT }}
  173. ORACLE_KEY: ${{ secrets.ORACLE_KEY }}
  174. ORACLE_VAULT_OCID: ${{ secrets.ORACLE_VAULT_OCID }}
  175. ORACLE_COMPARTMENT_OCID: ${{ secrets.ORACLE_COMPARTMENT_OCID }}
  176. ORACLE_ENCRYPTION_KEY_OCID: ${{ secrets.ORACLE_ENCRYPTION_KEY_OCID }}
  177. # Report the fork run result back onto the originating pull request.
  178. report-fork:
  179. if: ${{ always() && github.event_name == 'repository_dispatch' && needs.integration-fork.result != 'skipped' }}
  180. needs: integration-fork
  181. runs-on: ubuntu-latest
  182. permissions:
  183. pull-requests: write # to publish the status as comments
  184. contents: read
  185. steps:
  186. - uses: step-security/harden-runner@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
  187. with:
  188. egress-policy: audit
  189. - id: create_token
  190. uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
  191. env:
  192. APP_ID: ${{ secrets.APP_ID }}
  193. with:
  194. app-id: ${{ env.APP_ID }}
  195. private-key: ${{ secrets.PRIVATE_KEY }}
  196. owner: ${{ github.repository_owner }}
  197. repositories: ${{ github.event.repository.name }}
  198. permission-issues: write
  199. permission-pull-requests: write
  200. - name: Update on Success
  201. if: needs.integration-fork.result == 'success'
  202. uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
  203. with:
  204. token: ${{ steps.create_token.outputs.token }}
  205. issue-number: ${{ github.event.client_payload.pull_request.number }}
  206. body: |
  207. [Bot] - :white_check_mark: [e2e for ${{ env.TARGET_SHA }} passed](https://github.com/external-secrets/external-secrets/actions/runs/${{ github.run_id }})
  208. - name: Update on Failure
  209. if: needs.integration-fork.result != 'success'
  210. uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
  211. with:
  212. token: ${{ steps.create_token.outputs.token }}
  213. issue-number: ${{ github.event.client_payload.pull_request.number }}
  214. body: |
  215. [Bot] - :x: [e2e for ${{ env.TARGET_SHA }} failed](https://github.com/external-secrets/external-secrets/actions/runs/${{ github.run_id }})
  216. # Single stable status to point branch protection at. The individual matrix
  217. # legs (and their names) change as e2e/matrix.yaml grows, but this gate does
  218. # not. It passes when the e2e path that ran for this event succeeded; the
  219. # other path is skipped and does not count against it, and a genuinely failed
  220. # leg propagates up through its caller job and fails this gate.
  221. e2e-required:
  222. if: always()
  223. needs: [integration-trusted, integration-fork]
  224. runs-on: ubuntu-latest
  225. permissions:
  226. contents: read
  227. steps:
  228. - uses: step-security/harden-runner@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
  229. with:
  230. egress-policy: audit
  231. - name: Require the e2e path to have passed
  232. env:
  233. TRUSTED: ${{ needs.integration-trusted.result }}
  234. FORK: ${{ needs.integration-fork.result }}
  235. run: |
  236. echo "integration-trusted=${TRUSTED} integration-fork=${FORK}"
  237. for r in "${TRUSTED}" "${FORK}"; do
  238. case "$r" in
  239. failure|cancelled)
  240. echo "::error::an e2e path did not pass (${r})"
  241. exit 1
  242. ;;
  243. esac
  244. done
  245. echo "e2e ok (success or skipped on both paths)"