Skip to content

Commit

Permalink
Merge remote-tracking branch 'skeleton-generic/develop' into lineage/…
Browse files Browse the repository at this point in the history
…skeleton
  • Loading branch information
jsf9k committed Sep 25, 2024
2 parents d2bd569 + f0e55b3 commit 939678b
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 76 deletions.
28 changes: 14 additions & 14 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
# These owners will be the default owners for everything in the
# repo. Unless a later match takes precedence, these owners will be
# requested for review when someone opens a pull request.
* @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
* @dav3r @felddy @jsf9k @mcdonnnj

# These folks own any files in the .github directory at the root of
# the repository and any of its subdirectories.
/.github/ @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
/.github/ @dav3r @felddy @jsf9k @mcdonnnj

# These folks own all linting configuration files.
/.ansible-lint @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
/.bandit.yml @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
/.flake8 @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
/.isort.cfg @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
/.mdl_config.yaml @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
/.pre-commit-config.yaml @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
/.prettierignore @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
/.yamllint @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
/requirements.txt @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
/requirements-dev.txt @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
/requirements-test.txt @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
/setup-env @dav3r @felddy @jasonodoom @jsf9k @mcdonnnj
/.ansible-lint @dav3r @felddy @jsf9k @mcdonnnj
/.bandit.yml @dav3r @felddy @jsf9k @mcdonnnj
/.flake8 @dav3r @felddy @jsf9k @mcdonnnj
/.isort.cfg @dav3r @felddy @jsf9k @mcdonnnj
/.mdl_config.yaml @dav3r @felddy @jsf9k @mcdonnnj
/.pre-commit-config.yaml @dav3r @felddy @jsf9k @mcdonnnj
/.prettierignore @dav3r @felddy @jsf9k @mcdonnnj
/.yamllint @dav3r @felddy @jsf9k @mcdonnnj
/requirements.txt @dav3r @felddy @jsf9k @mcdonnnj
/requirements-dev.txt @dav3r @felddy @jsf9k @mcdonnnj
/requirements-test.txt @dav3r @felddy @jsf9k @mcdonnnj
/setup-env @dav3r @felddy @jsf9k @mcdonnnj
22 changes: 4 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ defaults:
shell: bash -Eueo pipefail -x {0}

env:
CURL_CACHE_DIR: ~/.cache/curl
PIP_CACHE_DIR: ~/.cache/pip
PRE_COMMIT_CACHE_DIR: ~/.cache/pre-commit
RUN_TMATE: ${{ secrets.RUN_TMATE }}
Expand Down Expand Up @@ -76,7 +75,7 @@ jobs:
name: Lookup Go cache directory
run: |
echo "dir=$(go env GOCACHE)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
- uses: actions/cache@v4
env:
BASE_CACHE_KEY: "${{ github.job }}-${{ runner.os }}-\
py${{ steps.setup-python.outputs.python-version }}-\
Expand All @@ -97,25 +96,12 @@ jobs:
path: |
${{ env.PIP_CACHE_DIR }}
${{ env.PRE_COMMIT_CACHE_DIR }}
${{ env.CURL_CACHE_DIR }}
${{ steps.go-cache.outputs.dir }}
restore-keys: |
${{ env.BASE_CACHE_KEY }}
- name: Setup curl cache
run: mkdir -p ${{ env.CURL_CACHE_DIR }}
- name: Install Packer
env:
PACKER_VERSION: ${{ steps.setup-env.outputs.packer-version }}
run: |
PACKER_ZIP="packer_${PACKER_VERSION}_linux_amd64.zip"
curl --output ${{ env.CURL_CACHE_DIR }}/"${PACKER_ZIP}" \
--time-cond ${{ env.CURL_CACHE_DIR }}/"${PACKER_ZIP}" \
--location \
"https://releases.hashicorp.com/packer/${PACKER_VERSION}/${PACKER_ZIP}"
sudo unzip -d /opt/packer \
${{ env.CURL_CACHE_DIR }}/"${PACKER_ZIP}"
sudo mv /usr/local/bin/packer /usr/local/bin/packer-default
sudo ln -s /opt/packer/packer /usr/local/bin/packer
- uses: hashicorp/setup-packer@v3
with:
version: ${{ steps.setup-env.outputs.packer-version }}
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ steps.setup-env.outputs.terraform-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
egress-policy: audit
- id: github-status
name: Check GitHub status
uses: crazy-max/ghaction-github-status@v3
uses: crazy-max/ghaction-github-status@v4
- id: dump-context
name: Dump context
uses: crazy-max/ghaction-dump-context@v2
Expand Down
55 changes: 32 additions & 23 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ default_language_version:
python: python3

repos:
# Check the pre-commit configuration
- repo: meta
hooks:
- id: check-useless-excludes

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
Expand All @@ -21,7 +26,6 @@ repos:
- id: detect-private-key
exclude: config/gitleaks.toml
- id: end-of-file-fixer
exclude: files/(issue|motd)
- id: mixed-line-ending
args:
- --fix=lf
Expand All @@ -33,22 +37,15 @@ repos:

# Text file hooks
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.41.0
rev: v0.42.0
hooks:
- id: markdownlint
args:
- --config=.mdl_config.yaml
- repo: https://github.com/pre-commit/mirrors-prettier
# This is the last version of v3 available from the mirror. We should hold
# here until v4, which is currently in alpha, is more stable.
rev: v3.1.0
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.3.3
hooks:
- id: prettier
# This is the latest version of v3 available from NPM. The pre-commit
# mirror does not pull tags for old major versions once a new major
# version tag is published.
additional_dependencies:
- [email protected]
- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
Expand All @@ -58,14 +55,14 @@ repos:

# GitHub Actions hooks
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.4
rev: 0.29.2
hooks:
- id: check-github-actions
- id: check-github-workflows

# pre-commit hooks
- repo: https://github.com/pre-commit/pre-commit
rev: v3.7.1
rev: v3.8.0
hooks:
- id: validate_manifest

Expand Down Expand Up @@ -100,7 +97,7 @@ repos:

# Shell script hooks
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.8.0-1
rev: v3.9.0-1
hooks:
- id: shfmt
args:
Expand All @@ -124,40 +121,52 @@ repos:

# Python hooks
- repo: https://github.com/PyCQA/bandit
rev: 1.7.8
rev: 1.7.10
hooks:
- id: bandit
args:
- --config=.bandit.yml
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.4.2
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies:
- flake8-docstrings
- flake8-docstrings==1.7.0
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
rev: v1.11.2
hooks:
- id: mypy
additional_dependencies:
- types-PyYAML
- types-requests
- repo: https://github.com/pypa/pip-audit
rev: v2.7.3
hooks:
- id: pip-audit
args:
# Add any pip requirements files to scan
- --requirement
- requirements-dev.txt
- --requirement
- requirements-test.txt
- --requirement
- requirements.txt
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
rev: v3.17.0
hooks:
- id: pyupgrade

# Ansible hooks
- repo: https://github.com/ansible/ansible-lint
rev: v24.6.0
rev: v24.9.2
hooks:
- id: ansible-lint
additional_dependencies:
Expand All @@ -182,7 +191,7 @@ repos:

# Terraform hooks
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.90.0
rev: v1.96.1
hooks:
- id: terraform_fmt
- id: terraform_validate
Expand All @@ -195,7 +204,7 @@ repos:

# Packer hooks
- repo: https://github.com/cisagov/pre-commit-packer
rev: v0.0.2
rev: v0.1.0
hooks:
- id: packer_validate
- id: packer_fmt
70 changes: 50 additions & 20 deletions setup-env
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,52 @@ python_versions() {
pyenv versions --bare --skip-aliases --skip-envs
}

check_python_version() {
local version=$1

# This is a valid regex for semantically correct Python version strings.
# For more information see here:
# https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
# Break down the regex into readable parts major.minor.patch
local major="0|[1-9]\d*"
local minor="0|[1-9]\d*"
local patch="0|[1-9]\d*"

# Splitting the prerelease part for readability
# Start of the prerelease
local prerelease="(?:-"
# Numeric or alphanumeric identifiers
local prerelease+="(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)"
# Additional dot-separated identifiers
local prerelease+="(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*"
# End of the prerelease, making it optional
local prerelease+=")?"
# Optional build metadata
local build="(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?"

# Final regex composed of parts
local regex="^($major)\.($minor)\.($patch)$prerelease$build$"

# This checks if the Python version does not match the regex pattern specified in $regex,
# using Perl for regex matching. If the pattern is not found, then prompt the user with
# the invalid version message.
if ! echo "$version" | perl -ne "exit(!/$regex/)"; then
echo "Invalid version of Python: Python follows semantic versioning," \
"so any version string that is not a valid semantic version is an" \
"invalid version of Python."
exit 1
# Else if the Python version isn't installed then notify the user.
# grep -E is used for searching through text lines that match the specific verison.
elif ! python_versions | grep -E "^${version}$" > /dev/null; then
echo "Error: Python version $version is not installed."
echo "Installed Python versions are:"
python_versions
exit 1
else
echo "Using Python version $version"
fi
}

# Flag to force deletion and creation of virtual environment
FORCE=0

Expand Down Expand Up @@ -144,17 +190,8 @@ while true; do
-p | --python-version)
PYTHON_VERSION="$2"
shift 2
# Check the Python versions being passed in.
if [ -n "${PYTHON_VERSION+x}" ]; then
if python_versions | grep -E "^${PYTHON_VERSION}$" > /dev/null; then
echo Using Python version "$PYTHON_VERSION"
else
echo Error: Python version "$PYTHON_VERSION" is not installed.
echo Installed Python versions are:
python_versions
exit 1
fi
fi
# Check the Python version being passed in.
check_python_version "$PYTHON_VERSION"
;;
-v | --venv-name)
VENV_NAME="$2"
Expand Down Expand Up @@ -188,15 +225,8 @@ if [ $LIST_VERSIONS -ne 0 ]; then
# Read the user's desired Python version.
# -r: treat backslashes as literal, -p: display prompt before input.
read -r -p "Enter the desired Python version: " PYTHON_VERSION
# Check the Python versions being passed in.
if [ -n "${PYTHON_VERSION+x}" ]; then
if python_versions | grep -E "^${PYTHON_VERSION}$" > /dev/null; then
echo Using Python version "$PYTHON_VERSION"
else
echo Error: Python version "$PYTHON_VERSION" is not installed.
exit 1
fi
fi
# Check the Python version being passed in.
check_python_version "$PYTHON_VERSION"
fi

# Remove any lingering local configuration.
Expand Down

0 comments on commit 939678b

Please sign in to comment.