e2e.yml 5.1 KB

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