action.yml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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@v3
  39. with:
  40. go-version: "1.21"
  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@v3
  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. - name: Setup TFLint
  60. uses: terraform-linters/setup-tflint@v2
  61. with:
  62. tflint_version: v0.28.0 # Must be specified. See: https://github.com/terraform-linters/tflint/releases for latest versions
  63. - name: Run TFLint
  64. shell: bash
  65. 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'
  66. - name: Configure AWS Credentials
  67. if: env.CLOUD_PROVIDER == 'aws'
  68. uses: aws-actions/configure-aws-credentials@v1
  69. with:
  70. role-to-assume: ${{ env.AWS_OIDC_ROLE_ARN }}
  71. aws-region: ${{ env.AWS_REGION }}
  72. - name: Setup TF Gcloud Provider
  73. shell: bash
  74. if: env.CLOUD_PROVIDER == 'gcp'
  75. env:
  76. GCP_SM_SA_GKE_JSON: ${{ env.GCP_SM_SA_GKE_JSON }}
  77. run: |-
  78. mkdir -p terraform/gcp/secrets
  79. echo ${GCP_SM_SA_GKE_JSON} > terraform/gcp/secrets/gcloud-service-account-key.json
  80. - name: 'Az CLI login'
  81. uses: azure/login@v1
  82. if: env.CLOUD_PROVIDER == 'azure'
  83. with:
  84. client-id: ${{ env.TFC_AZURE_CLIENT_ID }}
  85. tenant-id: ${{ env.TFC_AZURE_TENANT_ID }}
  86. subscription-id: ${{ env.TFC_AZURE_SUBSCRIPTION_ID }}
  87. - name: Show TF
  88. shell: bash
  89. env:
  90. ARM_CLIENT_ID: "${{ env.TFC_AZURE_CLIENT_ID }}"
  91. ARM_SUBSCRIPTION_ID: "${{ env.TFC_AZURE_SUBSCRIPTION_ID }}"
  92. ARM_TENANT_ID: "${{ env.TFC_AZURE_TENANT_ID }}"
  93. run: |-
  94. PROVIDER=${{env.CLOUD_PROVIDER}}
  95. make tf.show.${PROVIDER}
  96. - name: Apply TF
  97. shell: bash
  98. env:
  99. ARM_CLIENT_ID: "${{ env.TFC_AZURE_CLIENT_ID }}"
  100. ARM_SUBSCRIPTION_ID: "${{ env.TFC_AZURE_SUBSCRIPTION_ID }}"
  101. ARM_TENANT_ID: "${{ env.TFC_AZURE_TENANT_ID }}"
  102. run: |-
  103. PROVIDER=${{env.CLOUD_PROVIDER}}
  104. make tf.apply.${PROVIDER}
  105. - name: Setup gcloud CLI
  106. if: env.CLOUD_PROVIDER == 'gcp'
  107. uses: google-github-actions/setup-gcloud@v0
  108. with:
  109. service_account_key: ${{ env.GCP_SM_SA_GKE_JSON }}
  110. project_id: ${{ env.GCP_PROJECT_ID }}
  111. install_components: 'gke-gcloud-auth-plugin'
  112. - name: Get the GKE credentials
  113. shell: bash
  114. if: env.CLOUD_PROVIDER == 'gcp'
  115. run: |-
  116. gcloud container clusters get-credentials "$GCP_GKE_CLUSTER" --zone "$GCP_GKE_ZONE" --project "$GCP_PROJECT_ID"
  117. - name: Get the AWS credentials
  118. shell: bash
  119. if: env.CLOUD_PROVIDER == 'aws'
  120. run: |-
  121. aws --region $AWS_REGION eks update-kubeconfig --name $AWS_CLUSTER_NAME
  122. - name: Get AKS credentials
  123. if: env.CLOUD_PROVIDER == 'azure'
  124. shell: bash
  125. run: |-
  126. az aks get-credentials --admin --name eso-cluster --resource-group external-secrets-operator
  127. - name: Login to Docker
  128. uses: docker/login-action@v2
  129. if: env.GHCR_USERNAME != ''
  130. with:
  131. registry: ghcr.io
  132. username: ${{ env.GHCR_USERNAME }}
  133. password: ${{ env.GHCR_TOKEN }}
  134. - name: Run managed e2e Tests
  135. shell: bash
  136. env:
  137. GCP_SM_SA_JSON: ${{ env.GCP_SM_SA_JSON }}
  138. run: |
  139. export PATH=$PATH:$(go env GOPATH)/bin
  140. PROVIDER=${{env.CLOUD_PROVIDER}}
  141. go install github.com/onsi/ginkgo/v2/ginkgo@v2.1.6
  142. make test.e2e.managed GINKGO_LABELS="${PROVIDER} && managed" TEST_SUITES="provider"
  143. - name: Destroy TF
  144. shell: bash
  145. if: always()
  146. env:
  147. ARM_CLIENT_ID: "${{ env.TFC_AZURE_CLIENT_ID }}"
  148. ARM_SUBSCRIPTION_ID: "${{ env.TFC_AZURE_SUBSCRIPTION_ID }}"
  149. ARM_TENANT_ID: "${{ env.TFC_AZURE_TENANT_ID }}"
  150. run: |-
  151. PROVIDER=${{env.CLOUD_PROVIDER}}
  152. make tf.destroy.${PROVIDER}