forked from hashicorp/terraform-provider-kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 1
91 lines (88 loc) · 3.64 KB
/
acceptance_tests_gke.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Acceptance Tests (GKE)
on:
workflow_dispatch:
inputs:
region:
description: The GKE region
default: us-west1
zone:
description: The GKE zone
default: us-west1-c
clusterVersion:
description: The GKE cluster version
default: 1.27
nodeCount:
description: The number of cluster nodes to provision
default: 1
instanceType:
description: The type of GKE instance to use for cluster nodes
default: e2-standard-2
parallelRuns:
description: The maximum number of tests to run simultaneously
default: 8
runTests:
description: The regex passed to the -run option of `go test`
default: ".*"
terraformVersion:
description: Terraform version
default: 1.5.6
schedule:
- cron: '0 23 * * *'
env:
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
GOOGLE_REGION: ${{ github.event.inputs.region || vars.GOOGLE_REGION }}
GOOGLE_ZONE: ${{github.event.inputs.zone || vars.GOOGLE_ZONE }}
USE_GKE_GCLOUD_AUTH_PLUGIN: True
KUBE_CONFIG_PATH: ${{ github.workspace }}/kubernetes/test-infra/gke/kubeconfig
PARALLEL_RUNS: ${{ github.event.inputs.parallelRuns || vars.PARALLEL_RUNS }}
TERRAFORM_VERSION: ${{ github.event.inputs.terraformVersion || vars.TERRAFORM_VERSION }}
TF_VAR_cluster_version: ${{ github.event.inputs.clusterVersion || vars.CLUSTER_VERSION }}
TF_VAR_node_count: ${{ github.event.inputs.nodeCount || vars.GOOGLE_NODE_COUNT }}
TF_VAR_instance_type: ${{ github.event.inputs.instanceType || vars.GOOGLE_INSTANCE_TYPE }}
jobs:
acceptance_tests_gke:
runs-on: [custom, linux, medium]
steps:
- name: Checkout repository
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Set up Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@35b0e87d162680511bf346c299f71c9c5c379033 # v1.1.1
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
access_token_lifetime: '14400s'
- name: Set up gcloud SDK
uses: google-github-actions/setup-gcloud@e30db14379863a8c79331b04a9969f4c1e225e0b # v1.1.1
with:
install_components: 'beta,gke-gcloud-auth-plugin'
- name: Initialize gcloud SDK
run: |
gcloud init
gcloud info
- name: Install Terraform
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}
terraform_wrapper: false
- name: Provision GKE Cluster
working-directory: ${{ github.workspace }}/kubernetes/test-infra/gke
run: |
terraform init
terraform apply -auto-approve
- name: Run Acceptance Test Suite
env:
TESTARGS: -run '${{ github.event.inputs.runTests }}'
# Do not set TF_ACC_TERRAFORM_PATH or TF_ACC_TERRAFORM_VERSION.
# In this case, the framework will search for the Terraform CLI binary based on the operating system PATH.
# Eventually, it will use the one we set up.
# More information: https://developer.hashicorp.com/terraform/plugin/sdkv2/testing/acceptance-tests#terraform-cli-installation-behaviors
run: |
make testacc
- name: Destroy GKE cluster
if: always() # we should destroy the cluster even if the tests fail
working-directory: ${{ github.workspace }}/kubernetes/test-infra/gke
run: |
terraform destroy -auto-approve