e2e.yml 5.7 KB

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