-
Notifications
You must be signed in to change notification settings - Fork 30
142 lines (138 loc) · 4.38 KB
/
terraform-ci.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
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
name: terraform-ci
on:
push:
branches:
- 'main'
- 'release/**'
pull_request:
branches:
- 'main'
- 'release/**'
permissions: {}
jobs:
action-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Lint workflow
uses: docker://docker.mirror.hashicorp.services/rhysd/actionlint:latest
with:
# we need to ignore the SC2086 rule to pass unescaped $VARS to the terraform commands
args: -ignore SC2086
get-go-version:
runs-on: ubuntu-latest
needs:
- action-lint
defaults:
run:
working-directory: ./test/acceptance
outputs:
go-version: ${{ steps.get-go-version.outputs.go-version }}
steps:
- name: Checkout
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Determine Go version
id: get-go-version
# We use .go-version as our source of truth for current Go
# version, because "goenv" can react to it automatically.
run: |
echo "Building with Go $(cat .go-version)"
echo "go-version=$(cat .go-version)" >> "$GITHUB_OUTPUT"
go-fmt-and-lint-acceptance:
runs-on: ubuntu-latest
needs:
- get-go-version
defaults:
run:
working-directory: ./test/acceptance
steps:
- name: Checkout
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}
cache-dependency-path: ./test/acceptance/go.sum
- name: Go CI lint
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
with:
args: "--verbose --enable gofmt"
only-new-issues: false
skip-pkg-cache: true
skip-build-cache: true
working-directory: ./test/acceptance
- name: Lint Consul retry
run: |
go install github.com/hashicorp/lint-consul-retry@latest
lint-consul-retry
terraform-fmt:
runs-on: ubuntu-latest
needs:
- action-lint
steps:
- name: Checkout
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.4.2
- name: Validate
run: terraform fmt -check -recursive .
acceptance-fargate:
needs:
- get-go-version
- terraform-fmt
- go-fmt-and-lint-acceptance
strategy:
# We have a limit of 6 HCP Consul clusters.
# The following controls whether to enable HCP when testing release branches.
# HCP is always disabled for tests on PRs.
matrix:
name:
- acceptance-1.16-FARGATE-HCP
- acceptance-1.16-FARGATE
include:
- name: acceptance-1.16-FARGATE-HCP
enable-hcp: true
launch-type: FARGATE
- name: acceptance-1.16-FARGATE
enable-hcp: false
launch-type: FARGATE
fail-fast: false
uses: ./.github/workflows/reusable-ecs-acceptance.yml
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}
name: ${{ matrix.name }}
launch-type: ${{ matrix.launch-type }}
enable-hcp: ${{ matrix.enable-hcp }}
secrets: inherit
acceptance-ec2:
needs:
- get-go-version
- acceptance-fargate
strategy:
# We have a limit of 6 HCP Consul clusters.
# The following controls whether to enable HCP when testing release branches.
# HCP is always disabled for tests on PRs.
matrix:
name:
- acceptance-1.16-EC2-HCP
- acceptance-1.16-EC2
include:
- name: acceptance-1.16-EC2-HCP
enable-hcp: true
launch-type: EC2
- name: acceptance-1.16-EC2
enable-hcp: false
launch-type: EC2
fail-fast: false
uses: ./.github/workflows/reusable-ecs-acceptance.yml
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}
name: ${{ matrix.name }}
launch-type: ${{ matrix.launch-type }}
enable-hcp: ${{ matrix.enable-hcp }}
secrets: inherit