Skip to content

Commit cfe074d

Browse files
authored
Add GKE acceptance tests to Github Actions (#1771)
1 parent 3ee6a00 commit cfe074d

File tree

3 files changed

+83
-2
lines changed

3 files changed

+83
-2
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.13.0
2+
3+
* Add Acceptance Tests (GKE) to Github Actions
4+
15
## 2.12.1 (July 6, 2022)
26

37
IMPROVEMENTS:

kubernetes/test-infra/gke/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ variable "kubernetes_version" {
33
}
44

55
variable "workers_count" {
6-
default = "1"
6+
default = "2"
77
}
88

99
variable "node_machine_type" {
10-
default = "e2-medium"
10+
default = "e2-standard-2"
1111
}
1212

1313
variable "enable_alpha" {

0 commit comments

Comments
 (0)