22name : build
33
44on :
5- push :
5+ merge_group :
6+ types :
7+ - checks_requested
68 pull_request :
9+ push :
710 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}
921
1022env :
1123 CURL_CACHE_DIR : ~/.cache/curl
1224 PIP_CACHE_DIR : ~/.cache/pip
1325 PRE_COMMIT_CACHE_DIR : ~/.cache/pre-commit
1426 RUN_TMATE : ${{ secrets.RUN_TMATE }}
27+ TERRAFORM_DOCS_REPO_BRANCH_NAME : improvement/support_atx_closed_markdown_headers
28+ TERRAFORM_DOCS_REPO_DEPTH : 1
29+ TERRAFORM_DOCS_REPO_URL : https://github.com/mcdonnnj/terraform-docs.git
1530
1631jobs :
1732 diagnostics :
2742 egress-policy : audit
2843 - id : github-status
2944 name : Check GitHub status
30- uses : crazy-max/ghaction-github-status@v3
45+ uses : crazy-max/ghaction-github-status@v4
3146 - id : dump-context
3247 name : Dump context
3348 uses : crazy-max/ghaction-dump-context@v2
@@ -45,20 +60,20 @@ jobs:
4560 uses : cisagov/setup-env-github-action@develop
4661 - uses : actions/checkout@v4
4762 - id : setup-python
48- uses : actions/setup-python@v4
63+ uses : actions/setup-python@v5
4964 with :
50- python-version : " 3.11 "
65+ python-version : ${{ steps.setup-env.outputs.python-version }}
5166 # We need the Go version and Go cache location for the actions/cache step,
5267 # so the Go installation must happen before that.
5368 - id : setup-go
54- uses : actions/setup-go@v4
69+ uses : actions/setup-go@v5
5570 with :
5671 # There is no expectation for actual Go code so we disable caching as
5772 # it relies on the existence of a go.sum file.
5873 cache : false
59- go-version : " 1.20 "
60- - name : Lookup Go cache directory
61- id : go- cache
74+ go-version : ${{ steps.setup-env.outputs.go-version }}
75+ - id : go- cache
76+ name : Lookup Go cache directory
6277 run : |
6378 echo "dir=$(go env GOCACHE)" >> $GITHUB_OUTPUT
6479 - uses : actions/cache@v3
6984 packer${{ steps.setup-env.outputs.packer-version }}-\
7085 tf${{ steps.setup-env.outputs.terraform-version }}-"
7186 with :
87+ key : " ${{ env.BASE_CACHE_KEY }}\
88+ ${{ hashFiles('**/requirements-test.txt') }}-\
89+ ${{ hashFiles('**/requirements.txt') }}-\
90+ ${{ hashFiles('**/.pre-commit-config.yaml') }}"
7291 # Note that the .terraform directory IS NOT included in the
7392 # cache because if we were caching, then we would need to use
7493 # the `-upgrade=true` option. This option blindly pulls down the
8099 ${{ env.PRE_COMMIT_CACHE_DIR }}
81100 ${{ env.CURL_CACHE_DIR }}
82101 ${{ steps.go-cache.outputs.dir }}
83- key : " ${{ env.BASE_CACHE_KEY }}\
84- ${{ hashFiles('**/requirements-test.txt') }}-\
85- ${{ hashFiles('**/requirements.txt') }}-\
86- ${{ hashFiles('**/.pre-commit-config.yaml') }}"
87102 restore-keys : |
88103 ${{ env.BASE_CACHE_KEY }}
89104 - name : Setup curl cache
@@ -101,34 +116,46 @@ jobs:
101116 ${{ env.CURL_CACHE_DIR }}/"${PACKER_ZIP}"
102117 sudo mv /usr/local/bin/packer /usr/local/bin/packer-default
103118 sudo ln -s /opt/packer/packer /usr/local/bin/packer
104- - uses : hashicorp/setup-terraform@v2
119+ - uses : hashicorp/setup-terraform@v3
105120 with :
106121 terraform_version : ${{ steps.setup-env.outputs.terraform-version }}
107122 - name : Install go-critic
108123 env :
109124 PACKAGE_URL : github.com/go-critic/go-critic/cmd/gocritic
110125 PACKAGE_VERSION : ${{ steps.setup-env.outputs.go-critic-version }}
111126 run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
127+ - name : Install goimports
128+ env :
129+ PACKAGE_URL : golang.org/x/tools/cmd/goimports
130+ PACKAGE_VERSION : ${{ steps.setup-env.outputs.goimports-version }}
131+ run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
112132 - name : Install gosec
113133 env :
114134 PACKAGE_URL : github.com/securego/gosec/v2/cmd/gosec
115135 PACKAGE_VERSION : ${{ steps.setup-env.outputs.gosec-version }}
116136 run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
117- - name : Install shfmt
118- env :
119- PACKAGE_URL : mvdan.cc/sh/v3/cmd/shfmt
120- PACKAGE_VERSION : ${{ steps.setup-env.outputs.shfmt-version }}
121- run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
122137 - name : Install staticcheck
123138 env :
124139 PACKAGE_URL : honnef.co/go/tools/cmd/staticcheck
125140 PACKAGE_VERSION : ${{ steps.setup-env.outputs.staticcheck-version }}
126141 run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
127- - name : Install Terraform-docs
128- env :
129- PACKAGE_URL : github.com/terraform-docs/terraform-docs
130- PACKAGE_VERSION : ${{ steps.setup-env.outputs.terraform-docs-version }}
131- run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
142+ # TODO: https://github.com/cisagov/skeleton-generic/issues/165
143+ # We are temporarily using @mcdonnnj's forked branch of terraform-docs
144+ # until his PR: https://github.com/terraform-docs/terraform-docs/pull/745
145+ # is approved. This temporary fix will allow for ATX header support when
146+ # terraform-docs is run during linting.
147+ - name : Clone ATX headers branch from terraform-docs fork
148+ run : |
149+ git clone \
150+ --branch $TERRAFORM_DOCS_REPO_BRANCH_NAME \
151+ --depth $TERRAFORM_DOCS_REPO_DEPTH \
152+ --single-branch \
153+ $TERRAFORM_DOCS_REPO_URL /tmp/terraform-docs
154+ - name : Build and install terraform-docs binary
155+ run : |
156+ go build \
157+ -C /tmp/terraform-docs \
158+ -o $(go env GOPATH)/bin/terraform-docs
132159 - name : Install dependencies
133160 run : |
134161 python -m pip install --upgrade pip setuptools wheel
0 commit comments