action.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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: Configure AWS Credentials
  38. uses: aws-actions/configure-aws-credentials@v1
  39. with:
  40. role-to-assume: ${{ env.AWS_OIDC_ROLE_ARN }}
  41. aws-region: ${{ env.AWS_REGION }}
  42. - name: Setup Go
  43. uses: actions/setup-go@v3
  44. with:
  45. go-version: "1.21"
  46. - name: Find the Go Cache
  47. id: go
  48. shell: bash
  49. run: |
  50. echo "::set-output name=build-cache::$(go env GOCACHE)"
  51. echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
  52. - name: Cache the Go Build Cache
  53. uses: actions/cache@v3
  54. with:
  55. path: ${{ steps.go.outputs.build-cache }}
  56. key: ${{ runner.os }}-build-unit-tests-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
  57. restore-keys: ${{ runner.os }}-build-unit-tests-${{ github.sha }}-
  58. - name: Cache Go Dependencies
  59. uses: actions/cache@v3
  60. with:
  61. path: ${{ steps.go.outputs.mod-cache }}
  62. key: ${{ runner.os }}-pkg-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
  63. restore-keys: ${{ runner.os }}-pkg-${{ github.sha }}-
  64. - name: Setup TFLint
  65. uses: terraform-linters/setup-tflint@v2
  66. with:
  67. tflint_version: v0.28.0 # Must be specified. See: https://github.com/terraform-linters/tflint/releases for latest versions
  68. - name: Run TFLint
  69. shell: bash
  70. 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'
  71. - name: Setup TF Gcloud Provider
  72. shell: bash
  73. if: env.CLOUD_PROVIDER == 'gcp'
  74. env:
  75. GCP_SM_SA_GKE_JSON: ${{ env.GCP_SM_SA_GKE_JSON }}
  76. run: |-
  77. mkdir -p terraform/gcp/secrets
  78. echo ${GCP_SM_SA_GKE_JSON} > terraform/gcp/secrets/gcloud-service-account-key.json
  79. - name: Show TF
  80. shell: bash
  81. run: |-
  82. PROVIDER=${{env.CLOUD_PROVIDER}}
  83. make tf.show.${PROVIDER}
  84. - name: Apply TF
  85. shell: bash
  86. env:
  87. TF_VAR_OIDC_TOKEN: "${{steps.fetch-token.outputs.result}}"
  88. run: |-
  89. PROVIDER=${{env.CLOUD_PROVIDER}}
  90. make tf.apply.${PROVIDER}
  91. - name: Setup gcloud CLI
  92. if: env.CLOUD_PROVIDER == 'gcp'
  93. uses: google-github-actions/setup-gcloud@v0
  94. with:
  95. service_account_key: ${{ env.GCP_SM_SA_GKE_JSON }}
  96. project_id: ${{ env.GCP_PROJECT_ID }}
  97. install_components: 'gke-gcloud-auth-plugin'
  98. - name: Get the GKE credentials
  99. shell: bash
  100. if: env.CLOUD_PROVIDER == 'gcp'
  101. run: |-
  102. gcloud container clusters get-credentials "$GCP_GKE_CLUSTER" --zone "$GCP_GKE_ZONE" --project "$GCP_PROJECT_ID"
  103. - name: Get the AWS credentials
  104. shell: bash
  105. if: env.CLOUD_PROVIDER == 'aws'
  106. run: |-
  107. aws --region $AWS_REGION eks update-kubeconfig --name $AWS_CLUSTER_NAME
  108. - name: Login to Docker
  109. uses: docker/login-action@v2
  110. if: env.GHCR_USERNAME != ''
  111. with:
  112. registry: ghcr.io
  113. username: ${{ env.GHCR_USERNAME }}
  114. password: ${{ env.GHCR_TOKEN }}
  115. - name: Run managed e2e Tests
  116. shell: bash
  117. env:
  118. GCP_SM_SA_JSON: ${{ env.GCP_SM_SA_JSON }}
  119. run: |
  120. export PATH=$PATH:$(go env GOPATH)/bin
  121. PROVIDER=${{env.CLOUD_PROVIDER}}
  122. go install github.com/onsi/ginkgo/v2/ginkgo@v2.1.6
  123. make test.e2e.managed GINKGO_LABELS="${PROVIDER}" TEST_SUITES="provider"
  124. - name: Destroy TF
  125. shell: bash
  126. if: always()
  127. run: |-
  128. PROVIDER=${{env.CLOUD_PROVIDER}}
  129. make tf.destroy.${PROVIDER}