|
| 1 | +name: Acceptance Tests (GKE) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + region: |
| 7 | + description: The GKE region |
| 8 | + default: us-east1 |
| 9 | + kubernetesVersion: |
| 10 | + description: The GKE kubernetes version |
| 11 | + default: 1.23 |
| 12 | + workersCount: |
| 13 | + description: The number of cluster nodes to provision |
| 14 | + default: 2 |
| 15 | + nodeMachineType: |
| 16 | + description: The type of GKE instance to use for cluster nodes |
| 17 | + default: e2-standard-2 |
| 18 | + runTests: |
| 19 | + description: The regex passed to the -run option of `go test` |
| 20 | + default: ".*" |
| 21 | + terraformVersion: |
| 22 | + description: Terraform version |
| 23 | + default: 1.2.4 |
| 24 | + |
| 25 | +env: |
| 26 | + GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} |
| 27 | + GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }} |
| 28 | + GOOGLE_REGION: ${{ github.event.inputs.region }} |
| 29 | + |
| 30 | +jobs: |
| 31 | + acceptance_tests: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v3 |
| 35 | + - name: Read go-version |
| 36 | + id: go-version |
| 37 | + uses: juliangruber/read-file-action@v1 |
| 38 | + with: |
| 39 | + path: ./.go-version |
| 40 | + - name: Set up Go |
| 41 | + uses: actions/setup-go@v2 |
| 42 | + with: |
| 43 | + go-version: ${{ steps.go-version.outputs.content }} |
| 44 | + - name: Authenticate to Google Cloud |
| 45 | + uses: "google-github-actions/auth@v0" |
| 46 | + with: |
| 47 | + credentials_json: ${{ secrets.GKE_SA_KEY }} |
| 48 | + - name: Install Terraform |
| 49 | + uses: hashicorp/setup-terraform@v1 |
| 50 | + with: |
| 51 | + terraform_version: ${{ github.event.inputs.terraformVersion }} |
| 52 | + - name: "Set up Cloud SDK" |
| 53 | + uses: "google-github-actions/setup-gcloud@v0" |
| 54 | + - name: "Initialize gcloud SDK" |
| 55 | + run: "gcloud init" |
| 56 | + - name: Provision GKE Cluster |
| 57 | + working-directory: ./kubernetes/test-infra/gke |
| 58 | + env: |
| 59 | + TF_VAR_kubernetes_version: ${{ github.event.inputs.kubernetesVersion }} |
| 60 | + TF_VAR_workers_count: ${{ github.event.inputs.workersCount }} |
| 61 | + TF_VAR_node_machine_type: ${{ github.event.inputs.nodeMachineType }} |
| 62 | + run: | |
| 63 | + env |
| 64 | + terraform init |
| 65 | + terraform apply -auto-approve |
| 66 | + - name: Run Acceptance Test Suite |
| 67 | + env: |
| 68 | + TF_ACC_TERRAFORM_VERSION: ${{ github.event.inputs.terraformVersion }} |
| 69 | + TESTARGS: -run '${{ github.event.inputs.runTests }}' |
| 70 | + KUBE_CONFIG_PATH: ${{ github.workspace }}/kubernetes/test-infra/gke/kubeconfig |
| 71 | + run: | |
| 72 | + make testacc |
| 73 | + - name: Destroy GKE cluster |
| 74 | + if: always() # we should destroy the cluster even if the tests fail |
| 75 | + working-directory: ./kubernetes/test-infra/gke |
| 76 | + run: | |
| 77 | + terraform destroy --auto-approve |
0 commit comments