e2e.yml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. issues: write
  9. pull-requests: write
  10. name: e2e tests
  11. env:
  12. # Common versions
  13. GO_VERSION: '1.21'
  14. GINKGO_VERSION: 'v2.8.0'
  15. DOCKER_BUILDX_VERSION: 'v0.4.2'
  16. KIND_VERSION: 'v0.17.0'
  17. KIND_IMAGE: 'kindest/node:v1.26.0'
  18. # Common users. We can't run a step 'if secrets.GHCR_USERNAME != ""' but we can run
  19. # a step 'if env.GHCR_USERNAME' != ""', so we copy these to succinctly test whether
  20. # credentials have been provided before trying to run steps that need them.
  21. TARGET_SHA: ${{ github.event.client_payload.slash_command.args.named.sha }}
  22. GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
  23. GCP_SM_SA_JSON: ${{ secrets.GCP_SM_SA_JSON}}
  24. GCP_GKE_ZONE: ${{ secrets.GCP_GKE_ZONE}}
  25. GCP_GSA_NAME: ${{ secrets.GCP_GSA_NAME}} # Goolge Service Account
  26. GCP_KSA_NAME: ${{ secrets.GCP_KSA_NAME}} # Kubernetes Service Account
  27. GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID}}
  28. AWS_REGION: "eu-central-1"
  29. AWS_OIDC_ROLE_ARN: ${{ secrets.AWS_OIDC_ROLE_ARN }}
  30. TFC_AZURE_CLIENT_ID: ${{ secrets.TFC_AZURE_CLIENT_ID}}
  31. TFC_AZURE_CLIENT_SECRET: ${{ secrets.TFC_AZURE_CLIENT_SECRET }}
  32. TFC_AZURE_TENANT_ID: ${{ secrets.TFC_AZURE_TENANT_ID}}
  33. TFC_AZURE_SUBSCRIPTION_ID: ${{ secrets.TFC_AZURE_SUBSCRIPTION_ID }}
  34. TFC_VAULT_URL: ${{ secrets.TFC_VAULT_URL}}
  35. SCALEWAY_API_URL: ${{ secrets.SCALEWAY_API_URL }}
  36. SCALEWAY_REGION: ${{ secrets.SCALEWAY_REGION }}
  37. SCALEWAY_PROJECT_ID: ${{ secrets.SCALEWAY_PROJECT_ID }}
  38. SCALEWAY_ACCESS_KEY: ${{ secrets.SCALEWAY_ACCESS_KEY }}
  39. SCALEWAY_SECRET_KEY: ${{ secrets.SCALEWAY_SECRET_KEY }}
  40. DELINEA_TLD: ${{ secrets.DELINEA_TLD }}
  41. DELINEA_URL_TEMPLATE: ${{ secrets.DELINEA_URL_TEMPLATE }}
  42. DELINEA_TENANT: ${{ secrets.DELINEA_TENANT }}
  43. DELINEA_CLIENT_ID: ${{ secrets.DELINEA_CLIENT_ID }}
  44. DELINEA_CLIENT_SECRET: ${{ secrets.DELINEA_CLIENT_SECRET }}
  45. SECRETSERVER_USERNAME: ${{ secrets.SECRETSERVER_USERNAME }}
  46. SECRETSERVER_PASSWORD: ${{ secrets.SECRETSERVER_PASSWORD }}
  47. SECRETSERVER_URL: ${{ secrets.SECRETSERVER_URL }}
  48. jobs:
  49. integration-trusted:
  50. runs-on: ubuntu-latest
  51. permissions:
  52. id-token: write
  53. checks: write
  54. contents: read
  55. if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor !='dependabot[bot]'
  56. steps:
  57. - name: Branch based PR checkout
  58. uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  59. - name: Fetch History
  60. run: git fetch --prune --unshallow
  61. - uses: ./.github/actions/e2e
  62. # Repo owner has commented /ok-to-test on a (fork-based) pull request
  63. integration-fork:
  64. runs-on: ubuntu-latest
  65. permissions:
  66. id-token: write
  67. checks: write
  68. contents: read
  69. if: github.event_name == 'repository_dispatch'
  70. steps:
  71. # Check out merge commit
  72. - name: Fork based /ok-to-test checkout
  73. uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  74. with:
  75. ref: '${{ env.TARGET_SHA }}'
  76. - name: Fetch History
  77. run: git fetch --prune --unshallow
  78. - id: e2e
  79. uses: ./.github/actions/e2e
  80. # Update check run called "integration-fork"
  81. - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
  82. id: update-check-run
  83. if: ${{ always() }}
  84. env:
  85. number: ${{ github.event.client_payload.pull_request.number }}
  86. job: ${{ github.job }}
  87. # Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
  88. conclusion: ${{ job.status }}
  89. with:
  90. github-token: ${{ secrets.TEST_GITHUB_TOKEN }}
  91. script: |
  92. const { data: pull } = await github.rest.pulls.get({
  93. ...context.repo,
  94. pull_number: process.env.number
  95. });
  96. const ref = pull.head.sha;
  97. console.log("\n\nPR sha: " + ref)
  98. const { data: checks } = await github.rest.checks.listForRef({
  99. ...context.repo,
  100. ref
  101. });
  102. console.log("\n\nPR CHECKS: " + checks)
  103. const check = checks.check_runs.filter(c => c.name === process.env.job);
  104. console.log("\n\nPR Filtered CHECK: " + check)
  105. console.log(check)
  106. const { data: result } = await github.rest.checks.update({
  107. ...context.repo,
  108. check_run_id: check[0].id,
  109. status: 'completed',
  110. conclusion: process.env.conclusion
  111. });
  112. return result;
  113. - name: Find Comment
  114. if: always()
  115. uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
  116. id: fc
  117. with:
  118. token: ${{ secrets.TEST_GITHUB_TOKEN }}
  119. issue-number: ${{ github.event.client_payload.pull_request.number }}
  120. body-includes: /ok-to-test sha=${{ env.TARGET_SHA }}
  121. - name: Update on Succeess
  122. if: always() && steps.fc.outputs.comment-id != '' && steps.e2e.conclusion == 'success'
  123. uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
  124. with:
  125. token: ${{ secrets.TEST_GITHUB_TOKEN }}
  126. issue-number: ${{ github.event.client_payload.pull_request.number }}
  127. body: |
  128. [Bot] - :white_check_mark: [e2e tests pass](https://github.com/external-secrets/external-secrets/actions/runs/${{ steps.update-check-run.outputs.result.id }})
  129. reactions: +1
  130. edit-mode: append
  131. - name: Update on Failure
  132. if: always() && steps.fc.outputs.comment-id != '' && steps.e2e.conclusion != 'success'
  133. uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
  134. with:
  135. token: ${{ secrets.TEST_GITHUB_TOKEN }}
  136. issue-number: ${{ github.event.client_payload.pull_request.number }}
  137. body: |
  138. [Bot] - :x: [e2e tests failed](https://github.com/external-secrets/external-secrets/actions/runs/${{ steps.update-check-run.outputs.result.id }})
  139. reactions: -1
  140. edit-mode: append