2
2
name : build
3
3
4
4
on :
5
- push :
5
+ merge_group :
6
+ types :
7
+ - checks_requested
6
8
pull_request :
9
+ push :
7
10
repository_dispatch :
8
- types : [apb]
11
+ types :
12
+ - apb
13
+
14
+ # Set a default shell for any run steps. The `-Eueo pipefail` sets errtrace,
15
+ # nounset, errexit, and pipefail. The `-x` will print all commands as they are
16
+ # run. Please see the GitHub Actions documentation for more information:
17
+ # https://docs.github.com/en/actions/using-jobs/setting-default-values-for-jobs
18
+ defaults :
19
+ run :
20
+ shell : bash -Eueo pipefail -x {0}
9
21
10
22
env :
11
23
AWS_DEFAULT_REGION : us-east-1
12
24
CURL_CACHE_DIR : ~/.cache/curl
13
25
PIP_CACHE_DIR : ~/.cache/pip
14
26
PRE_COMMIT_CACHE_DIR : ~/.cache/pre-commit
15
27
RUN_TMATE : ${{ secrets.RUN_TMATE }}
28
+ TERRAFORM_DOCS_REPO_BRANCH_NAME : improvement/support_atx_closed_markdown_headers
29
+ TERRAFORM_DOCS_REPO_DEPTH : 1
30
+ TERRAFORM_DOCS_REPO_URL : https://github.com/mcdonnnj/terraform-docs.git
16
31
17
32
jobs :
18
33
diagnostics :
28
43
egress-policy : audit
29
44
- id : github-status
30
45
name : Check GitHub status
31
- uses : crazy-max/ghaction-github-status@v3
46
+ uses : crazy-max/ghaction-github-status@v4
32
47
- id : dump-context
33
48
name : Dump context
34
49
uses : crazy-max/ghaction-dump-context@v2
@@ -46,20 +61,20 @@ jobs:
46
61
uses : cisagov/setup-env-github-action@develop
47
62
- uses : actions/checkout@v4
48
63
- id : setup-python
49
- uses : actions/setup-python@v4
64
+ uses : actions/setup-python@v5
50
65
with :
51
- python-version : " 3.11 "
66
+ python-version : ${{ steps.setup-env.outputs.python-version }}
52
67
# We need the Go version and Go cache location for the actions/cache step,
53
68
# so the Go installation must happen before that.
54
69
- id : setup-go
55
- uses : actions/setup-go@v4
70
+ uses : actions/setup-go@v5
56
71
with :
57
72
# There is no expectation for actual Go code so we disable caching as
58
73
# it relies on the existence of a go.sum file.
59
74
cache : false
60
- go-version : " 1.20 "
61
- - name : Lookup Go cache directory
62
- id : go- cache
75
+ go-version : ${{ steps.setup-env.outputs.go-version }}
76
+ - id : go- cache
77
+ name : Lookup Go cache directory
63
78
run : |
64
79
echo "dir=$(go env GOCACHE)" >> $GITHUB_OUTPUT
65
80
- uses : actions/cache@v3
70
85
packer${{ steps.setup-env.outputs.packer-version }}-\
71
86
tf${{ steps.setup-env.outputs.terraform-version }}-"
72
87
with :
88
+ key : " ${{ env.BASE_CACHE_KEY }}\
89
+ ${{ hashFiles('**/requirements-test.txt') }}-\
90
+ ${{ hashFiles('**/requirements.txt') }}-\
91
+ ${{ hashFiles('**/.pre-commit-config.yaml') }}"
73
92
# Note that the .terraform directory IS NOT included in the
74
93
# cache because if we were caching, then we would need to use
75
94
# the `-upgrade=true` option. This option blindly pulls down the
@@ -81,10 +100,6 @@ jobs:
81
100
${{ env.PRE_COMMIT_CACHE_DIR }}
82
101
${{ env.CURL_CACHE_DIR }}
83
102
${{ steps.go-cache.outputs.dir }}
84
- key : " ${{ env.BASE_CACHE_KEY }}\
85
- ${{ hashFiles('**/requirements-test.txt') }}-\
86
- ${{ hashFiles('**/requirements.txt') }}-\
87
- ${{ hashFiles('**/.pre-commit-config.yaml') }}"
88
103
restore-keys : |
89
104
${{ env.BASE_CACHE_KEY }}
90
105
- name : Setup curl cache
@@ -102,34 +117,46 @@ jobs:
102
117
${{ env.CURL_CACHE_DIR }}/"${PACKER_ZIP}"
103
118
sudo mv /usr/local/bin/packer /usr/local/bin/packer-default
104
119
sudo ln -s /opt/packer/packer /usr/local/bin/packer
105
- - uses : hashicorp/setup-terraform@v2
120
+ - uses : hashicorp/setup-terraform@v3
106
121
with :
107
122
terraform_version : ${{ steps.setup-env.outputs.terraform-version }}
108
123
- name : Install go-critic
109
124
env :
110
125
PACKAGE_URL : github.com/go-critic/go-critic/cmd/gocritic
111
126
PACKAGE_VERSION : ${{ steps.setup-env.outputs.go-critic-version }}
112
127
run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
128
+ - name : Install goimports
129
+ env :
130
+ PACKAGE_URL : golang.org/x/tools/cmd/goimports
131
+ PACKAGE_VERSION : ${{ steps.setup-env.outputs.goimports-version }}
132
+ run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
113
133
- name : Install gosec
114
134
env :
115
135
PACKAGE_URL : github.com/securego/gosec/v2/cmd/gosec
116
136
PACKAGE_VERSION : ${{ steps.setup-env.outputs.gosec-version }}
117
137
run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
118
- - name : Install shfmt
119
- env :
120
- PACKAGE_URL : mvdan.cc/sh/v3/cmd/shfmt
121
- PACKAGE_VERSION : ${{ steps.setup-env.outputs.shfmt-version }}
122
- run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
123
138
- name : Install staticcheck
124
139
env :
125
140
PACKAGE_URL : honnef.co/go/tools/cmd/staticcheck
126
141
PACKAGE_VERSION : ${{ steps.setup-env.outputs.staticcheck-version }}
127
142
run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
128
- - name : Install Terraform-docs
129
- env :
130
- PACKAGE_URL : github.com/terraform-docs/terraform-docs
131
- PACKAGE_VERSION : ${{ steps.setup-env.outputs.terraform-docs-version }}
132
- run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
143
+ # TODO: https://github.com/cisagov/skeleton-generic/issues/165
144
+ # We are temporarily using @mcdonnnj's forked branch of terraform-docs
145
+ # until his PR: https://github.com/terraform-docs/terraform-docs/pull/745
146
+ # is approved. This temporary fix will allow for ATX header support when
147
+ # terraform-docs is run during linting.
148
+ - name : Clone ATX headers branch from terraform-docs fork
149
+ run : |
150
+ git clone \
151
+ --branch $TERRAFORM_DOCS_REPO_BRANCH_NAME \
152
+ --depth $TERRAFORM_DOCS_REPO_DEPTH \
153
+ --single-branch \
154
+ $TERRAFORM_DOCS_REPO_URL /tmp/terraform-docs
155
+ - name : Build and install terraform-docs binary
156
+ run : |
157
+ go build \
158
+ -C /tmp/terraform-docs \
159
+ -o $(go env GOPATH)/bin/terraform-docs
133
160
- name : Install dependencies
134
161
run : |
135
162
python -m pip install --upgrade pip setuptools wheel
@@ -156,11 +183,13 @@ jobs:
156
183
uses : step-security/harden-runner@v2
157
184
with :
158
185
egress-policy : audit
186
+ - id : setup-env
187
+ uses : cisagov/setup-env-github-action@develop
159
188
- uses : actions/checkout@v4
160
189
- id : setup-python
161
- uses : actions/setup-python@v4
190
+ uses : actions/setup-python@v5
162
191
with :
163
- python-version : " 3.10 "
192
+ python-version : ${{ steps.setup-env.outputs.python-version }}
164
193
- uses : actions/cache@v3
165
194
env :
166
195
BASE_CACHE_KEY : " ${{ github.job }}-${{ runner.os }}-\
0 commit comments