generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 59
133 lines (116 loc) · 4.48 KB
/
test.yml
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# This GitHub action runs your tests for each commit push and/or PR. Optionally
# you can turn it on using a cron schedule for regular testing.
#
name: Acceptance Tests
on:
# Commenting out for now, since the Service Account with Vault can only create 10 secret keys
# at a time. If this runs twice (on push, when it's already PR'ed) that's 8 secret keys.
# TODO (mbang): re-evaluate ttl on tokens
# pull_request:
# paths-ignore:
# - 'README.md'
push:
branches:
- main
paths-ignore:
- 'README.md'
# For systems with an upstream API that could drift unexpectedly (like most SaaS systems, etc.),
# we recommend testing at a regular interval not necessarily tied to code changes. This will
# ensure you are alerted to something breaking due to an API change, even if the code did not
# change.
# schedule:
# - cron: '0 13 * * *'
jobs:
# ensure the code builds...
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: '1.18'
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Get dependencies
run: |
go mod download
- name: Build
run: |
go build -v .
# run acceptance tests in a matrix with Terraform core versions
test:
name: Matrix Test
needs: build
runs-on: ubuntu-latest
timeout-minutes: 150
strategy:
fail-fast: false
max-parallel: 1
matrix:
# list whatever Terraform versions here you would like to support
terraform:
- '0.12.31'
# skipping due to https://github.com/hashicorp/terraform/issues/25961 test failures
# - '0.13.4'
- '0.14.11'
- '1.0.3'
steps:
- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: '1.16'
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Get dependencies
run: |
go mod download
- name: Get credentials
id: vault
uses: hashicorp/[email protected]
with:
url: ${{ secrets.VAULT_ADDR }}
method: approle
roleId: ${{ secrets.ROLE_ID }}
secretId: ${{ secrets.SECRET_ID }}
tlsSkipVerify: true
exportEnv: false
namespace: admin/tpgw
secrets: |
gcp/key/tf-acctest private_key_data
- name: Pre-sweep lingering resources
timeout-minutes: 10
env:
GOOGLEWORKSPACE_CUSTOMER_ID: ${{ secrets.GOOGLEWORKSPACE_CUSTOMER_ID }}
GOOGLEWORKSPACE_IMPERSONATED_USER_EMAIL: ${{ secrets.GOOGLEWORKSPACE_IMPERSONATED_USER_EMAIL }}
run: |
export GOOGLEWORKSPACE_CREDENTIALS=$(echo -n ${{ steps.vault.outputs.private_key_data }} | base64 --decode)
go test ./internal/provider -v -sweep=us-central1 -sweep-run= -timeout 60m
- name: TF acceptance tests
timeout-minutes: 120
env:
TF_ACC: "1"
TF_LOG: "DEBUG"
TF_ACC_TERRAFORM_VERSION: ${{ matrix.terraform }}
# Set whatever additional acceptance test env vars here. You can
# optionally use data from your repository secrets using the
# following syntax:
# SOME_VAR: ${{ secrets.SOME_VAR }}
GOOGLEWORKSPACE_CUSTOMER_ID: ${{ secrets.GOOGLEWORKSPACE_CUSTOMER_ID }}
GOOGLEWORKSPACE_DOMAIN: ${{ secrets.GOOGLEWORKSPACE_DOMAIN }}
GOOGLEWORKSPACE_IMPERSONATED_USER_EMAIL: ${{ secrets.GOOGLEWORKSPACE_IMPERSONATED_USER_EMAIL }}
GOOGLEWORKSPACE_IMPERSONATED_SERVICE_ACCOUNT: ${{ secrets.GOOGLEWORKSPACE_IMPERSONATED_SERVICE_ACCOUNT }}
run: |
export GOOGLEWORKSPACE_CREDENTIALS=$(echo -n ${{ steps.vault.outputs.private_key_data }} | base64 --decode)
go test -v -cover ./internal/provider/ -timeout 120m
- name: Post-sweep lingering resources
timeout-minutes: 10
env:
GOOGLEWORKSPACE_CUSTOMER_ID: ${{ secrets.GOOGLEWORKSPACE_CUSTOMER_ID }}
GOOGLEWORKSPACE_IMPERSONATED_USER_EMAIL: ${{ secrets.GOOGLEWORKSPACE_IMPERSONATED_USER_EMAIL }}
run: |
export GOOGLEWORKSPACE_CREDENTIALS=$(echo -n ${{ steps.vault.outputs.private_key_data }} | base64 --decode)
go test ./internal/provider -v -sweep=us-central1 -sweep-run= -timeout 60m