e2e.yml 5.2 KB

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