Skip to content

Commit b45e9cd

Browse files
author
mcdonnnj
committed
2 parents 1666745 + e79569c commit b45e9cd

File tree

6 files changed

+288
-101
lines changed

6 files changed

+288
-101
lines changed

.github/CODEOWNERS

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,17 @@
88
# These folks own any files in the .github directory at the root of
99
# the repository and any of its subdirectories.
1010
/.github/ @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
11+
12+
# These folks own all linting configuration files.
13+
/.ansible-lint @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
14+
/.bandit.yml @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
15+
/.flake8 @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
16+
/.isort.cfg @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
17+
/.mdl_config.yaml @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
18+
/.pre-commit-config.yaml @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
19+
/.prettierignore @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
20+
/.yamllint @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
21+
/requirements.txt @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
22+
/requirements-dev.txt @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
23+
/requirements-test.txt @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
24+
/setup-env @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj

.github/workflows/build.yml

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,31 @@
22
name: build
33

44
on:
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

1022
env:
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

1631
jobs:
1732
diagnostics:
@@ -27,7 +42,7 @@ jobs:
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
@@ -69,6 +84,10 @@ jobs:
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
@@ -80,10 +99,6 @@ jobs:
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

.github/workflows/sync-labels.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,38 @@ permissions:
1111
contents: read
1212

1313
jobs:
14+
diagnostics:
15+
name: Run diagnostics
16+
runs-on: ubuntu-latest
17+
steps:
18+
# Note that a duplicate of this step must be added at the top of
19+
# each job.
20+
- id: harden-runner
21+
name: Harden the runner
22+
uses: step-security/harden-runner@v2
23+
with:
24+
egress-policy: audit
25+
- id: github-status
26+
name: Check GitHub status
27+
uses: crazy-max/ghaction-github-status@v3
28+
- id: dump-context
29+
name: Dump context
30+
uses: crazy-max/ghaction-dump-context@v2
1431
labeler:
32+
needs:
33+
- diagnostics
1534
permissions:
1635
# actions/checkout needs this to fetch code
1736
contents: read
1837
# crazy-max/ghaction-github-labeler needs this to manage repository labels
1938
issues: write
2039
runs-on: ubuntu-latest
2140
steps:
41+
- id: harden-runner
42+
name: Harden the runner
43+
uses: step-security/harden-runner@v2
44+
with:
45+
egress-policy: audit
2246
- uses: actions/checkout@v4
2347
- name: Sync repository labels
2448
if: success()

.pre-commit-config.yaml

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ default_language_version:
55

66
repos:
77
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: v4.4.0
8+
rev: v4.5.0
99
hooks:
1010
- id: check-case-conflict
1111
- id: check-executables-have-shebangs
@@ -31,32 +31,39 @@ repos:
3131

3232
# Text file hooks
3333
- repo: https://github.com/igorshubovych/markdownlint-cli
34-
rev: v0.36.0
34+
rev: v0.39.0
3535
hooks:
3636
- id: markdownlint
3737
args:
3838
- --config=.mdl_config.yaml
3939
- repo: https://github.com/pre-commit/mirrors-prettier
40-
rev: v3.0.3
40+
# This is the last version of v3 available from the mirror. We should hold
41+
# here until v4, which is currently in alpha, is more stable.
42+
rev: v3.1.0
4143
hooks:
4244
- id: prettier
45+
# This is the latest version of v3 available from NPM. The pre-commit
46+
# mirror does not pull tags for old major versions once a new major
47+
# version tag is published.
48+
additional_dependencies:
49+
4350
- repo: https://github.com/adrienverge/yamllint
44-
rev: v1.32.0
51+
rev: v1.35.1
4552
hooks:
4653
- id: yamllint
4754
args:
4855
- --strict
4956

5057
# GitHub Actions hooks
5158
- repo: https://github.com/python-jsonschema/check-jsonschema
52-
rev: 0.26.3
59+
rev: 0.28.0
5360
hooks:
5461
- id: check-github-actions
5562
- id: check-github-workflows
5663

5764
# pre-commit hooks
5865
- repo: https://github.com/pre-commit/pre-commit
59-
rev: v3.4.0
66+
rev: v3.6.2
6067
hooks:
6168
- id: validate_manifest
6269

@@ -78,75 +85,83 @@ repos:
7885
- id: go-vet-repo-mod
7986
# GoSec
8087
- id: go-sec-repo-mod
81-
88+
# goimports
89+
- id: go-imports-repo
90+
args:
91+
# Write changes to files
92+
- -w
8293
# Nix hooks
8394
- repo: https://github.com/nix-community/nixpkgs-fmt
8495
rev: v1.3.0
8596
hooks:
8697
- id: nixpkgs-fmt
8798

8899
# Shell script hooks
89-
- repo: https://github.com/cisagov/pre-commit-shfmt
90-
rev: v0.0.2
100+
- repo: https://github.com/scop/pre-commit-shfmt
101+
rev: v3.7.0-4
91102
hooks:
92103
- id: shfmt
93104
args:
105+
# List files that will be formatted
106+
- --list
107+
# Write result to file instead of stdout
108+
- --write
94109
# Indent by two spaces
95-
- -i
96-
- '2'
110+
- --indent
111+
- "2"
97112
# Binary operators may start a line
98-
- -bn
113+
- --binary-next-line
99114
# Switch cases are indented
100-
- -ci
115+
- --case-indent
101116
# Redirect operators are followed by a space
102-
- -sr
103-
- repo: https://github.com/detailyang/pre-commit-shell
104-
rev: 1.0.5
117+
- --space-redirects
118+
- repo: https://github.com/shellcheck-py/shellcheck-py
119+
rev: v0.9.0.6
105120
hooks:
106-
- id: shell-lint
121+
- id: shellcheck
107122

108123
# Python hooks
109124
- repo: https://github.com/PyCQA/bandit
110-
rev: 1.7.5
125+
rev: 1.7.7
111126
hooks:
112127
- id: bandit
113128
# Bandit complains about the use of assert() in tests
114129
exclude: molecule/(default|systemd_enabled)/tests
115130
args:
116131
- --config=.bandit.yml
117132
- repo: https://github.com/psf/black-pre-commit-mirror
118-
rev: 23.9.1
133+
rev: 24.2.0
119134
hooks:
120135
- id: black
121136
- repo: https://github.com/PyCQA/flake8
122-
rev: 6.1.0
137+
rev: 7.0.0
123138
hooks:
124139
- id: flake8
125140
additional_dependencies:
126141
- flake8-docstrings
127142
- repo: https://github.com/PyCQA/isort
128-
rev: 5.12.0
143+
rev: 5.13.2
129144
hooks:
130145
- id: isort
131146
- repo: https://github.com/pre-commit/mirrors-mypy
132-
rev: v1.5.1
147+
rev: v1.8.0
133148
hooks:
134149
- id: mypy
135150
- repo: https://github.com/asottile/pyupgrade
136-
rev: v3.10.1
151+
rev: v3.15.1
137152
hooks:
138153
- id: pyupgrade
139154

140155
# Ansible hooks
141156
- repo: https://github.com/ansible/ansible-lint
142-
rev: v6.19.0
157+
rev: v24.2.0
143158
hooks:
144159
- id: ansible-lint
145160
# files: molecule/default/playbook.yml
146161

147162
# Terraform hooks
148163
- repo: https://github.com/antonbabenko/pre-commit-terraform
149-
rev: v1.83.2
164+
rev: v1.88.0
150165
hooks:
151166
- id: terraform_fmt
152167
- id: terraform_validate

0 commit comments

Comments
 (0)