e2e.yml 4.9 KB

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