action.yml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. name: "e2e"
  2. description: "runs our e2e test suite"
  3. runs:
  4. using: composite
  5. steps:
  6. # create new status check for this specific provider
  7. - uses: actions/github-script@v6
  8. with:
  9. github-token: ${{ env.GITHUB_TOKEN }}
  10. script: |
  11. const { data: pull } = await github.rest.pulls.get({
  12. ...context.repo,
  13. pull_number: process.env.GITHUB_PR_NUMBER
  14. });
  15. const ref = pull.head.sha;
  16. const { data: checks } = await github.rest.checks.listForRef({
  17. ...context.repo,
  18. ref
  19. });
  20. const job_name = "e2e-managed-" + process.env.CLOUD_PROVIDER
  21. const check = checks.check_runs.filter(c => c.name === job_name);
  22. if(check && check.length > 0){
  23. const { data: result } = await github.rest.checks.update({
  24. ...context.repo,
  25. check_run_id: check[0].id,
  26. status: 'in_progress',
  27. });
  28. return result;
  29. }
  30. const { data: result } = await github.rest.checks.create({
  31. ...context.repo,
  32. name: job_name,
  33. head_sha: pull.head.sha,
  34. status: 'in_progress',
  35. });
  36. return result;
  37. - name: Setup Go
  38. uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
  39. with:
  40. go-version-file: go.mod
  41. - name: Find the Go Cache
  42. id: go
  43. shell: bash
  44. run: |
  45. echo "build-cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT
  46. echo "mod-cache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
  47. - name: Cache the Go Build Cache
  48. uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
  49. with:
  50. path: ${{ steps.go.outputs.build-cache }}
  51. key: ${{ runner.os }}-build-unit-tests-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
  52. restore-keys: ${{ runner.os }}-build-unit-tests-${{ github.sha }}-
  53. - name: Cache Go Dependencies
  54. uses: actions/cache@v3
  55. with:
  56. path: ${{ steps.go.outputs.mod-cache }}
  57. key: ${{ runner.os }}-pkg-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
  58. restore-keys: ${{ runner.os }}-pkg-${{ github.sha }}-
  59. - uses: hashicorp/setup-terraform@v3
  60. - name: Setup TFLint
  61. uses: terraform-linters/setup-tflint@v2
  62. with:
  63. tflint_version: v0.28.0 # Must be specified. See: https://github.com/terraform-linters/tflint/releases for latest versions
  64. - name: Run TFLint
  65. shell: bash
  66. run: find ${{ github.workspace }} | grep tf$ | xargs -n1 dirname | xargs -IXXX -n1 /bin/sh -c 'set -o errexit; cd XXX; pwd; tflint --loglevel=info .; cd - >/dev/null'
  67. - name: Configure AWS Credentials
  68. if: env.CLOUD_PROVIDER == 'aws'
  69. uses: aws-actions/configure-aws-credentials@v1
  70. with:
  71. role-to-assume: ${{ env.AWS_OIDC_ROLE_ARN }}
  72. aws-region: ${{ env.AWS_REGION }}
  73. - name: Setup TF Gcloud Provider
  74. shell: bash
  75. if: env.CLOUD_PROVIDER == 'gcp'
  76. env:
  77. GCP_SM_SA_GKE_JSON: ${{ env.GCP_SM_SA_GKE_JSON }}
  78. run: |-
  79. mkdir -p terraform/gcp/secrets
  80. echo ${GCP_SM_SA_GKE_JSON} > terraform/gcp/secrets/gcloud-service-account-key.json
  81. - name: 'Az CLI login'
  82. uses: azure/login@v1
  83. if: env.CLOUD_PROVIDER == 'azure'
  84. with:
  85. client-id: ${{ env.TFC_AZURE_CLIENT_ID }}
  86. tenant-id: ${{ env.TFC_AZURE_TENANT_ID }}
  87. subscription-id: ${{ env.TFC_AZURE_SUBSCRIPTION_ID }}
  88. - name: Show TF
  89. shell: bash
  90. env:
  91. ARM_CLIENT_ID: "${{ env.TFC_AZURE_CLIENT_ID }}"
  92. ARM_SUBSCRIPTION_ID: "${{ env.TFC_AZURE_SUBSCRIPTION_ID }}"
  93. ARM_TENANT_ID: "${{ env.TFC_AZURE_TENANT_ID }}"
  94. run: |-
  95. PROVIDER=${{env.CLOUD_PROVIDER}}
  96. make tf.show.${PROVIDER}
  97. - name: Apply TF
  98. shell: bash
  99. env:
  100. ARM_CLIENT_ID: "${{ env.TFC_AZURE_CLIENT_ID }}"
  101. ARM_SUBSCRIPTION_ID: "${{ env.TFC_AZURE_SUBSCRIPTION_ID }}"
  102. ARM_TENANT_ID: "${{ env.TFC_AZURE_TENANT_ID }}"
  103. run: |-
  104. PROVIDER=${{env.CLOUD_PROVIDER}}
  105. make tf.apply.${PROVIDER}
  106. - name: Setup gcloud CLI
  107. if: env.CLOUD_PROVIDER == 'gcp'
  108. uses: google-github-actions/setup-gcloud@v0
  109. with:
  110. service_account_key: ${{ env.GCP_SM_SA_GKE_JSON }}
  111. project_id: ${{ env.GCP_PROJECT_ID }}
  112. install_components: 'gke-gcloud-auth-plugin'
  113. - name: Get the GKE credentials
  114. shell: bash
  115. if: env.CLOUD_PROVIDER == 'gcp'
  116. run: |-
  117. gcloud container clusters get-credentials "$GCP_GKE_CLUSTER" --zone "$GCP_GKE_ZONE" --project "$GCP_PROJECT_ID"
  118. - name: Get the AWS credentials
  119. shell: bash
  120. if: env.CLOUD_PROVIDER == 'aws'
  121. run: |-
  122. aws --region $AWS_REGION eks update-kubeconfig --name $AWS_CLUSTER_NAME
  123. - name: Get AKS credentials
  124. if: env.CLOUD_PROVIDER == 'azure'
  125. shell: bash
  126. run: |-
  127. az aks get-credentials --admin --name eso-cluster --resource-group external-secrets-operator
  128. - name: Login to Docker
  129. uses: docker/login-action@v2
  130. if: env.GHCR_USERNAME != ''
  131. with:
  132. registry: ghcr.io
  133. username: ${{ github.actor }}
  134. password: ${{ github.token }}
  135. - name: Run managed e2e Tests
  136. shell: bash
  137. env:
  138. GCP_SM_SA_JSON: ${{ env.GCP_SM_SA_JSON }}
  139. run: |
  140. export PATH=$PATH:$(go env GOPATH)/bin
  141. PROVIDER=${{env.CLOUD_PROVIDER}}
  142. go install github.com/onsi/ginkgo/v2/ginkgo@v2.1.6
  143. make test.e2e.managed GINKGO_LABELS="${PROVIDER} && managed" TEST_SUITES="provider"
  144. - name: Destroy TF
  145. shell: bash
  146. if: always()
  147. env:
  148. ARM_CLIENT_ID: "${{ env.TFC_AZURE_CLIENT_ID }}"
  149. ARM_SUBSCRIPTION_ID: "${{ env.TFC_AZURE_SUBSCRIPTION_ID }}"
  150. ARM_TENANT_ID: "${{ env.TFC_AZURE_TENANT_ID }}"
  151. run: |-
  152. PROVIDER=${{env.CLOUD_PROVIDER}}
  153. make tf.destroy.${PROVIDER}