e2e.yml 5.1 KB

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