Skip to content

Commit a97b74b

Browse files
author
mcdonnnj
committed
# Conflicts: # .github/CODEOWNERS
2 parents de7d770 + f0e55b3 commit a97b74b

File tree

5 files changed

+104
-75
lines changed

5 files changed

+104
-75
lines changed

.github/CODEOWNERS

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,26 @@
33
# These owners will be the default owners for everything in the
44
# repo. Unless a later match takes precedence, these owners will be
55
# requested for review when someone opens a pull request.
6+
<<<<<<< HEAD
67
* @climber-girl @dav3r @jasonodoom @jsf9k @mcdonnnj
8+
=======
9+
* @dav3r @felddy @jsf9k @mcdonnnj
10+
>>>>>>> f0e55b3d6fefccf87103354e918b03028abd6f8e
711

812
# These folks own any files in the .github directory at the root of
913
# the repository and any of its subdirectories.
10-
/.github/ @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
14+
/.github/ @dav3r @felddy @jsf9k @mcdonnnj
1115

1216
# 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
17+
/.ansible-lint @dav3r @felddy @jsf9k @mcdonnnj
18+
/.bandit.yml @dav3r @felddy @jsf9k @mcdonnnj
19+
/.flake8 @dav3r @felddy @jsf9k @mcdonnnj
20+
/.isort.cfg @dav3r @felddy @jsf9k @mcdonnnj
21+
/.mdl_config.yaml @dav3r @felddy @jsf9k @mcdonnnj
22+
/.pre-commit-config.yaml @dav3r @felddy @jsf9k @mcdonnnj
23+
/.prettierignore @dav3r @felddy @jsf9k @mcdonnnj
24+
/.yamllint @dav3r @felddy @jsf9k @mcdonnnj
25+
/requirements.txt @dav3r @felddy @jsf9k @mcdonnnj
26+
/requirements-dev.txt @dav3r @felddy @jsf9k @mcdonnnj
27+
/requirements-test.txt @dav3r @felddy @jsf9k @mcdonnnj
28+
/setup-env @dav3r @felddy @jsf9k @mcdonnnj

.github/workflows/build.yml

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ defaults:
2020
shell: bash -Eueo pipefail -x {0}
2121

2222
env:
23-
CURL_CACHE_DIR: ~/.cache/curl
2423
PIP_CACHE_DIR: ~/.cache/pip
2524
PRE_COMMIT_CACHE_DIR: ~/.cache/pre-commit
2625
RUN_TMATE: ${{ secrets.RUN_TMATE }}
@@ -76,7 +75,7 @@ jobs:
7675
name: Lookup Go cache directory
7776
run: |
7877
echo "dir=$(go env GOCACHE)" >> $GITHUB_OUTPUT
79-
- uses: actions/cache@v3
78+
- uses: actions/cache@v4
8079
env:
8180
BASE_CACHE_KEY: "${{ github.job }}-${{ runner.os }}-\
8281
py${{ steps.setup-python.outputs.python-version }}-\
@@ -97,25 +96,12 @@ jobs:
9796
path: |
9897
${{ env.PIP_CACHE_DIR }}
9998
${{ env.PRE_COMMIT_CACHE_DIR }}
100-
${{ env.CURL_CACHE_DIR }}
10199
${{ steps.go-cache.outputs.dir }}
102100
restore-keys: |
103101
${{ env.BASE_CACHE_KEY }}
104-
- name: Setup curl cache
105-
run: mkdir -p ${{ env.CURL_CACHE_DIR }}
106-
- name: Install Packer
107-
env:
108-
PACKER_VERSION: ${{ steps.setup-env.outputs.packer-version }}
109-
run: |
110-
PACKER_ZIP="packer_${PACKER_VERSION}_linux_amd64.zip"
111-
curl --output ${{ env.CURL_CACHE_DIR }}/"${PACKER_ZIP}" \
112-
--time-cond ${{ env.CURL_CACHE_DIR }}/"${PACKER_ZIP}" \
113-
--location \
114-
"https://releases.hashicorp.com/packer/${PACKER_VERSION}/${PACKER_ZIP}"
115-
sudo unzip -d /opt/packer \
116-
${{ env.CURL_CACHE_DIR }}/"${PACKER_ZIP}"
117-
sudo mv /usr/local/bin/packer /usr/local/bin/packer-default
118-
sudo ln -s /opt/packer/packer /usr/local/bin/packer
102+
- uses: hashicorp/setup-packer@v3
103+
with:
104+
version: ${{ steps.setup-env.outputs.packer-version }}
119105
- uses: hashicorp/setup-terraform@v3
120106
with:
121107
terraform_version: ${{ steps.setup-env.outputs.terraform-version }}

.github/workflows/sync-labels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
egress-policy: audit
2525
- id: github-status
2626
name: Check GitHub status
27-
uses: crazy-max/ghaction-github-status@v3
27+
uses: crazy-max/ghaction-github-status@v4
2828
- id: dump-context
2929
name: Dump context
3030
uses: crazy-max/ghaction-dump-context@v2

.pre-commit-config.yaml

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ default_language_version:
44
python: python3
55

66
repos:
7+
# Check the pre-commit configuration
8+
- repo: meta
9+
hooks:
10+
- id: check-useless-excludes
11+
712
- repo: https://github.com/pre-commit/pre-commit-hooks
813
rev: v4.6.0
914
hooks:
@@ -19,7 +24,6 @@ repos:
1924
- --allow-missing-credentials
2025
- id: detect-private-key
2126
- id: end-of-file-fixer
22-
exclude: files/(issue|motd)
2327
- id: mixed-line-ending
2428
args:
2529
- --fix=lf
@@ -31,22 +35,15 @@ repos:
3135

3236
# Text file hooks
3337
- repo: https://github.com/igorshubovych/markdownlint-cli
34-
rev: v0.41.0
38+
rev: v0.42.0
3539
hooks:
3640
- id: markdownlint
3741
args:
3842
- --config=.mdl_config.yaml
39-
- repo: https://github.com/pre-commit/mirrors-prettier
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
43+
- repo: https://github.com/rbubley/mirrors-prettier
44+
rev: v3.3.3
4345
hooks:
4446
- 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-
5047
- repo: https://github.com/adrienverge/yamllint
5148
rev: v1.35.1
5249
hooks:
@@ -56,14 +53,14 @@ repos:
5653

5754
# GitHub Actions hooks
5855
- repo: https://github.com/python-jsonschema/check-jsonschema
59-
rev: 0.28.4
56+
rev: 0.29.2
6057
hooks:
6158
- id: check-github-actions
6259
- id: check-github-workflows
6360

6461
# pre-commit hooks
6562
- repo: https://github.com/pre-commit/pre-commit
66-
rev: v3.7.1
63+
rev: v3.8.0
6764
hooks:
6865
- id: validate_manifest
6966

@@ -98,7 +95,7 @@ repos:
9895

9996
# Shell script hooks
10097
- repo: https://github.com/scop/pre-commit-shfmt
101-
rev: v3.8.0-1
98+
rev: v3.9.0-1
10299
hooks:
103100
- id: shfmt
104101
args:
@@ -122,37 +119,49 @@ repos:
122119

123120
# Python hooks
124121
- repo: https://github.com/PyCQA/bandit
125-
rev: 1.7.8
122+
rev: 1.7.10
126123
hooks:
127124
- id: bandit
128125
args:
129126
- --config=.bandit.yml
130127
- repo: https://github.com/psf/black-pre-commit-mirror
131-
rev: 24.4.2
128+
rev: 24.8.0
132129
hooks:
133130
- id: black
134131
- repo: https://github.com/PyCQA/flake8
135-
rev: 7.0.0
132+
rev: 7.1.1
136133
hooks:
137134
- id: flake8
138135
additional_dependencies:
139-
- flake8-docstrings
136+
- flake8-docstrings==1.7.0
140137
- repo: https://github.com/PyCQA/isort
141138
rev: 5.13.2
142139
hooks:
143140
- id: isort
144141
- repo: https://github.com/pre-commit/mirrors-mypy
145-
rev: v1.10.0
142+
rev: v1.11.2
146143
hooks:
147144
- id: mypy
145+
- repo: https://github.com/pypa/pip-audit
146+
rev: v2.7.3
147+
hooks:
148+
- id: pip-audit
149+
args:
150+
# Add any pip requirements files to scan
151+
- --requirement
152+
- requirements-dev.txt
153+
- --requirement
154+
- requirements-test.txt
155+
- --requirement
156+
- requirements.txt
148157
- repo: https://github.com/asottile/pyupgrade
149-
rev: v3.15.2
158+
rev: v3.17.0
150159
hooks:
151160
- id: pyupgrade
152161

153162
# Ansible hooks
154163
- repo: https://github.com/ansible/ansible-lint
155-
rev: v24.6.0
164+
rev: v24.9.2
156165
hooks:
157166
- id: ansible-lint
158167
additional_dependencies:
@@ -177,7 +186,7 @@ repos:
177186

178187
# Terraform hooks
179188
- repo: https://github.com/antonbabenko/pre-commit-terraform
180-
rev: v1.90.0
189+
rev: v1.96.1
181190
hooks:
182191
- id: terraform_fmt
183192
- id: terraform_validate
@@ -190,7 +199,7 @@ repos:
190199

191200
# Packer hooks
192201
- repo: https://github.com/cisagov/pre-commit-packer
193-
rev: v0.0.2
202+
rev: v0.1.0
194203
hooks:
195204
- id: packer_validate
196205
- id: packer_fmt

setup-env

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,52 @@ python_versions() {
3939
pyenv versions --bare --skip-aliases --skip-envs
4040
}
4141

42+
check_python_version() {
43+
local version=$1
44+
45+
# This is a valid regex for semantically correct Python version strings.
46+
# For more information see here:
47+
# https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
48+
# Break down the regex into readable parts major.minor.patch
49+
local major="0|[1-9]\d*"
50+
local minor="0|[1-9]\d*"
51+
local patch="0|[1-9]\d*"
52+
53+
# Splitting the prerelease part for readability
54+
# Start of the prerelease
55+
local prerelease="(?:-"
56+
# Numeric or alphanumeric identifiers
57+
local prerelease+="(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)"
58+
# Additional dot-separated identifiers
59+
local prerelease+="(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*"
60+
# End of the prerelease, making it optional
61+
local prerelease+=")?"
62+
# Optional build metadata
63+
local build="(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?"
64+
65+
# Final regex composed of parts
66+
local regex="^($major)\.($minor)\.($patch)$prerelease$build$"
67+
68+
# This checks if the Python version does not match the regex pattern specified in $regex,
69+
# using Perl for regex matching. If the pattern is not found, then prompt the user with
70+
# the invalid version message.
71+
if ! echo "$version" | perl -ne "exit(!/$regex/)"; then
72+
echo "Invalid version of Python: Python follows semantic versioning," \
73+
"so any version string that is not a valid semantic version is an" \
74+
"invalid version of Python."
75+
exit 1
76+
# Else if the Python version isn't installed then notify the user.
77+
# grep -E is used for searching through text lines that match the specific verison.
78+
elif ! python_versions | grep -E "^${version}$" > /dev/null; then
79+
echo "Error: Python version $version is not installed."
80+
echo "Installed Python versions are:"
81+
python_versions
82+
exit 1
83+
else
84+
echo "Using Python version $version"
85+
fi
86+
}
87+
4288
# Flag to force deletion and creation of virtual environment
4389
FORCE=0
4490

@@ -144,17 +190,8 @@ while true; do
144190
-p | --python-version)
145191
PYTHON_VERSION="$2"
146192
shift 2
147-
# Check the Python versions being passed in.
148-
if [ -n "${PYTHON_VERSION+x}" ]; then
149-
if python_versions | grep -E "^${PYTHON_VERSION}$" > /dev/null; then
150-
echo Using Python version "$PYTHON_VERSION"
151-
else
152-
echo Error: Python version "$PYTHON_VERSION" is not installed.
153-
echo Installed Python versions are:
154-
python_versions
155-
exit 1
156-
fi
157-
fi
193+
# Check the Python version being passed in.
194+
check_python_version "$PYTHON_VERSION"
158195
;;
159196
-v | --venv-name)
160197
VENV_NAME="$2"
@@ -188,15 +225,8 @@ if [ $LIST_VERSIONS -ne 0 ]; then
188225
# Read the user's desired Python version.
189226
# -r: treat backslashes as literal, -p: display prompt before input.
190227
read -r -p "Enter the desired Python version: " PYTHON_VERSION
191-
# Check the Python versions being passed in.
192-
if [ -n "${PYTHON_VERSION+x}" ]; then
193-
if python_versions | grep -E "^${PYTHON_VERSION}$" > /dev/null; then
194-
echo Using Python version "$PYTHON_VERSION"
195-
else
196-
echo Error: Python version "$PYTHON_VERSION" is not installed.
197-
exit 1
198-
fi
199-
fi
228+
# Check the Python version being passed in.
229+
check_python_version "$PYTHON_VERSION"
200230
fi
201231

202232
# Remove any lingering local configuration.

0 commit comments

Comments
 (0)