-
Notifications
You must be signed in to change notification settings - Fork 113
158 lines (151 loc) · 4.71 KB
/
tests.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Tests
on:
pull_request:
branches:
- main
push:
branches:
- main
env:
GOPROXY: https://proxy.golang.org/
jobs:
copywrite:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- name: Checkout Repo
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # https://github.com/actions/checkout/releases/tag/v3.6.0
- name: Install copywrite
uses: hashicorp/setup-copywrite@v1.1.2
- name: Validate Header Compliance
run: copywrite headers --plan
# resolve-versions allows us to show resolved Go versions in job titles
# for added clarity and quick orientation in a long list of past jobs
resolve-versions:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
-
name: Resolve old stable version
id: oldstable
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # https://github.com/actions/setup-go/releases/tag/v4.1.0
with:
go-version: oldstable
-
name: Resolve stable version
id: stable
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # https://github.com/actions/setup-go/releases/tag/v4.1.0
with:
go-version: stable
outputs:
oldstable: ${{ steps.oldstable.outputs.go-version }}
stable: ${{ steps.stable.outputs.go-version }}
static-checks:
name: static-checks (go ${{ matrix.go_version }})
needs: resolve-versions
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
go_version:
- ${{ needs.resolve-versions.outputs.oldstable }}
- ${{ needs.resolve-versions.outputs.stable }}
steps:
-
name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # https://github.com/actions/checkout/releases/tag/v3.6.0
-
name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # https://github.com/actions/setup-go/releases/tag/v4.1.0
with:
go-version: ${{ matrix.go_version }}
-
name: Go fmt
run:
# exit 1 if any files need go fmt
test -z $(gofmt -s -l .)
-
name: Go vet
run: go vet ./...
unit-tests:
name: unit-tests (${{ matrix.os }}, go ${{ matrix.go_version }})
needs:
- resolve-versions
- static-checks
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
go_version:
- ${{ needs.resolve-versions.outputs.oldstable }}
- ${{ needs.resolve-versions.outputs.stable }}
steps:
-
name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # https://github.com/actions/checkout/releases/tag/v3.6.0
-
name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # https://github.com/actions/setup-go/releases/tag/v4.1.0
with:
go-version: ${{ matrix.go_version }}
-
name: Go mod download
run: go mod download -x
-
name: Go mod verify
run: go mod verify
-
name: Run build
run: go build ./...
-
name: Run unit tests
run: go test -race $(go list ./... | grep -v /tfexec/internal/e2etest)
e2e-tests:
name: e2e-tests (${{ matrix.os }}, go ${{ matrix.go_version }}, terraform ${{ matrix.terraform_version }})
needs:
- resolve-versions
- static-checks
- unit-tests
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
go_version:
- ${{ needs.resolve-versions.outputs.oldstable }}
- ${{ needs.resolve-versions.outputs.stable }}
terraform_version:
- "0.11.15"
- "0.12.31"
- "0.13.7"
- "0.14.11"
- "0.15.5"
- "1.0.11"
- "1.1.9"
- "1.2.9"
- "1.3.7"
- "refs/heads/main"
steps:
-
name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # https://github.com/actions/checkout/releases/tag/v3.6.0
-
name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # https://github.com/actions/setup-go/releases/tag/v4.1.0
with:
go-version: ${{ matrix.go_version }}
-
name: Run E2E tests
env:
TFEXEC_E2ETEST_VERSIONS: ${{ matrix.terraform_version }}
run: go test -race -timeout=30m -v ./tfexec/internal/e2etest