Skip to content
This repository was archived by the owner on Dec 1, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
4baa1ed
Standardize the layout of the Lineage configuration file
mcdonnnj Jun 7, 2021
249bbbb
Add to the cache keys for the GitHub Actions workflow
mcdonnnj Jun 7, 2021
449eef4
Add comments explaining different hashFiles() argument
mcdonnnj Jun 7, 2021
1e8f822
Add style enforcement rules
mcdonnnj Jun 18, 2021
afc6bd6
Add rule for image headers
mcdonnnj Jun 18, 2021
ce173f4
Switch to a YAML markdownlint configuration file
mcdonnnj Jun 18, 2021
f2a4230
Add comments to markdownlint configuration
mcdonnnj Jun 18, 2021
d4781ee
Add the validate_manifest hook from pre-commit
mcdonnnj Jun 24, 2021
7ae8bea
Add assertion to verify that the root logger's logging level is set c…
jsf9k Jun 25, 2021
106af21
Install terraform and packer for the linting job
jsf9k Jul 9, 2021
c481043
Break out the curl cache creation into its own step
jsf9k Jul 10, 2021
70414cf
Remove unnecessary line in tasks
jsf9k Jul 10, 2021
b629f7f
Modify the Packer installation to model that of Terraform
jsf9k Jul 10, 2021
181d1b2
Install a specific version of terraform-docs
jsf9k Jul 11, 2021
bb6e566
Move go installation so that it takes place before the cache task
jsf9k Jul 12, 2021
337d1ef
Capitalize Go for consistency
jsf9k Jul 12, 2021
8ee2116
Prefer the newer "go install" syntax
jsf9k Jul 13, 2021
e2a729d
Install the shfmt tool for GHA
mcdonnnj Jul 13, 2021
406b688
Replace the beautysh hook with pre-commit-shfmt
mcdonnnj Jul 13, 2021
2b48e75
Apply changes from the shfmt pre-commit hook
mcdonnnj Jul 13, 2021
1df1757
Remove unnecessary boilerplate
mcdonnnj Jul 14, 2021
ad5009c
Explicitly call sys.exit for errors
mcdonnnj Jul 14, 2021
8a8785d
Update function type hints
mcdonnnj Jul 14, 2021
29ade6f
Do not use f-strings in logging messages
mcdonnnj Jul 14, 2021
015d47e
Update testing for exit code changes
mcdonnnj Jul 14, 2021
1708b5c
Update pre-commit hooks
mcdonnnj Jul 13, 2021
d7dcfee
Merge pull request #83 from cisagov/maintenance/update_pre-commit_hooks
mcdonnnj Jul 19, 2021
c17800a
Merge branch 'develop' into improvement/add_pre-commit_hook
mcdonnnj Jul 19, 2021
41a5286
Merge pull request #80 from cisagov/improvement/add_pre-commit_hook
mcdonnnj Jul 19, 2021
e607360
Merge branch 'develop' into improvement/update_mdl_configuration
mcdonnnj Jul 19, 2021
f6ad0e9
Merge branch 'develop' into improvement/install-tf-and-packer-for-lin…
jsf9k Jul 19, 2021
382c39c
Merge pull request #79 from cisagov/improvement/update_mdl_configuration
mcdonnnj Jul 19, 2021
3e3b918
Merge branch 'develop' into improvement/install-tf-and-packer-for-lin…
mcdonnnj Jul 19, 2021
0e4fc41
Merge pull request #82 from cisagov/improvement/install-tf-and-packer…
mcdonnnj Jul 19, 2021
3e83a80
Merge branch 'develop' into improvement/replace_beautysh_with_shfmt
mcdonnnj Jul 19, 2021
81cdb4d
Merge pull request #84 from cisagov/improvement/replace_beautysh_with…
mcdonnnj Jul 19, 2021
e45aec3
Merge github.com:cisagov/skeleton-generic into lineage/skeleton
mcdonnnj Jul 20, 2021
63cf76f
Changes from the pre-commit-shfmt hook
mcdonnnj Jul 20, 2021
77c19cb
Add stubs required by mypy pre-commit hook
mcdonnnj Jul 20, 2021
3452b9d
Install mypy type stubs as part of setup-env
jsf9k Jul 20, 2021
0efaf16
Merge pull request #82 from cisagov/lineage/skeleton
mcdonnnj Jul 22, 2021
6610849
Merge branch 'develop' into improvement/standardize_lineage_configura…
mcdonnnj Jul 22, 2021
720ecdc
Merge pull request #77 from cisagov/improvement/standardize_lineage_c…
mcdonnnj Jul 22, 2021
9706b8b
Merge branch 'develop' into improvement/improve-test
mcdonnnj Jul 22, 2021
422f11e
Merge pull request #80 from cisagov/improvement/improve-test
mcdonnnj Jul 22, 2021
d9f689f
Merge branch 'develop' into improvement/changes_to_match_development_…
mcdonnnj Jul 22, 2021
3c9b5d7
Merge pull request #81 from cisagov/improvement/changes_to_match_deve…
mcdonnnj Jul 22, 2021
82c3fad
Merge branch 'develop' into improvement/add_setup_to_gha_cache_key
mcdonnnj Jul 22, 2021
30b1756
Merge pull request #78 from cisagov/improvement/add_setup_to_gha_cach…
mcdonnnj Jul 22, 2021
ae6be3f
Merge github.com:cisagov/skeleton-python-library into lineage/skeleton
mcdonnnj Aug 9, 2021
50f7e4b
Run shfmt tool on the repository
mcdonnnj Aug 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/lineage.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
version: "1"

lineage:
skeleton:
remote-url: https://github.com/cisagov/skeleton-python-library.git
version: '1'
106 changes: 101 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,101 @@ on:
types: [apb]

env:
CURL_CACHE_DIR: ~/.cache/curl
PIP_CACHE_DIR: ~/.cache/pip
PRE_COMMIT_CACHE_DIR: ~/.cache/pre-commit
RUN_TMATE: ${{ secrets.RUN_TMATE }}

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: cisagov/setup-env-github-action@develop
- uses: actions/checkout@v2
- id: setup-python
uses: actions/setup-python@v2
with:
python-version: 3.9
# GO_VERSION and GOCACHE are used by the cache task, so the Go
# installation must happen before that.
- uses: actions/setup-go@v2
with:
go-version: '1.16'
- name: Store installed Go version
run: |
echo "GO_VERSION="\
"$(go version | sed 's/^go version go\([0-9.]\+\) .*/\1/')" \
>> $GITHUB_ENV
- name: Lookup Go cache directory
id: go-cache
run: |
echo "::set-output name=dir::$(go env GOCACHE)"
- uses: actions/cache@v2
env:
BASE_CACHE_KEY: "${{ github.job }}-${{ runner.os }}-\
py${{ steps.setup-python.outputs.python-version }}-"
py${{ steps.setup-python.outputs.python-version }}-\
go${{ env.GO_VERSION }}-\
packer${{ env.PACKER_VERSION }}-\
tf${{ env.TERRAFORM_VERSION }}-"
with:
# Note that the .terraform directory IS NOT included in the
# cache because if we were caching, then we would need to use
# the `-upgrade=true` option. This option blindly pulls down the
# latest modules and providers instead of checking to see if an
# update is required. That behavior defeats the benefits of caching.
# so there is no point in doing it for the .terraform directory.
path: |
${{ env.PIP_CACHE_DIR }}
${{ env.PRE_COMMIT_CACHE_DIR }}
${{ env.CURL_CACHE_DIR }}
${{ steps.go-cache.outputs.dir }}
# We do not use '**/setup.py' in the cache key so only the 'setup.py'
# file in the root of the repository is used. This is in case a Python
# package were to have a 'setup.py' as part of its internal codebase.
key: "${{ env.BASE_CACHE_KEY }}\
${{ hashFiles('**/requirements-test.txt') }}-\
${{ hashFiles('**/requirements.txt') }}-\
${{ hashFiles('**/.pre-commit-config.yaml') }}"
${{ hashFiles('**/.pre-commit-config.yaml') }}-\
${{ hashFiles('setup.py') }}"
restore-keys: |
${{ env.BASE_CACHE_KEY }}
- name: Setup curl cache
run: mkdir -p ${{ env.CURL_CACHE_DIR }}
- name: Install Packer
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
- name: Install Terraform
run: |
TERRAFORM_ZIP="terraform_${TERRAFORM_VERSION}_linux_amd64.zip"
curl --output ${{ env.CURL_CACHE_DIR }}/"${TERRAFORM_ZIP}" \
--time-cond ${{ env.CURL_CACHE_DIR }}/"${TERRAFORM_ZIP}" \
--location \
"https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/${TERRAFORM_ZIP}"
sudo unzip -d /opt/terraform \
${{ env.CURL_CACHE_DIR }}/"${TERRAFORM_ZIP}"
sudo mv /usr/local/bin/terraform /usr/local/bin/terraform-default
sudo ln -s /opt/terraform/terraform /usr/local/bin/terraform
- name: Install shfmt
run: go install mvdan.cc/sh/v3/cmd/shfmt@${SHFMT_VERSION}
- name: Install Terraform-docs
run: |
go install \
github.com/terraform-docs/terraform-docs@${TERRAFORM_DOCS_VERSION}
- name: Find and initialize Terraform directories
run: |
for path in $(find . -not \( -type d -name ".terraform" -prune \) \
-type f -iname "*.tf" -exec dirname "{}" \; | sort -u); do \
echo "Initializing '$path'..."; \
terraform init -input=false -backend=false "$path"; \
done
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -42,6 +111,9 @@ jobs:
run: pre-commit install-hooks
- name: Run pre-commit on all files
run: pre-commit run --all-files
- name: Setup tmate debug session
uses: mxschmitt/action-tmate@v3
if: env.RUN_TMATE
test:
runs-on: ubuntu-latest
strategy:
Expand All @@ -59,9 +131,13 @@ jobs:
py${{ steps.setup-python.outputs.python-version }}-"
with:
path: ${{ env.PIP_CACHE_DIR }}
# We do not use '**/setup.py' in the cache key so only the 'setup.py'
# file in the root of the repository is used. This is in case a Python
# package were to have a 'setup.py' as part of its internal codebase.
key: "${{ env.BASE_CACHE_KEY }}\
${{ hashFiles('**/requirements-test.txt') }}-\
${{ hashFiles('**/requirements.txt') }}"
${{ hashFiles('**/requirements.txt') }}-\
${{ hashFiles('setup.py') }}"
restore-keys: |
${{ env.BASE_CACHE_KEY }}
- name: Install dependencies
Expand All @@ -80,6 +156,9 @@ jobs:
COVERALLS_SERVICE_NAME: github
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: success()
- name: Setup tmate debug session
uses: mxschmitt/action-tmate@v3
if: env.RUN_TMATE
coveralls-finish:
runs-on: ubuntu-latest
needs: test
Expand All @@ -95,9 +174,13 @@ jobs:
py${{ steps.setup-python.outputs.python-version }}-"
with:
path: ${{ env.PIP_CACHE_DIR }}
# We do not use '**/setup.py' in the cache key so only the 'setup.py'
# file in the root of the repository is used. This is in case a Python
# package were to have a 'setup.py' as part of its internal codebase.
key: "${{ env.BASE_CACHE_KEY }}\
${{ hashFiles('**/requirements-test.txt') }}-\
${{ hashFiles('**/requirements.txt') }}"
${{ hashFiles('**/requirements.txt') }}-\
${{ hashFiles('setup.py') }}"
restore-keys: |
${{ env.BASE_CACHE_KEY }}
- name: Install dependencies
Expand All @@ -108,6 +191,9 @@ jobs:
run: coveralls --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup tmate debug session
uses: mxschmitt/action-tmate@v3
if: env.RUN_TMATE
build:
runs-on: ubuntu-latest
needs: [lint, test]
Expand All @@ -126,8 +212,12 @@ jobs:
py${{ steps.setup-python.outputs.python-version }}-"
with:
path: ${{ env.PIP_CACHE_DIR }}
# We do not use '**/setup.py' in the cache key so only the 'setup.py'
# file in the root of the repository is used. This is in case a Python
# package were to have a 'setup.py' as part of its internal codebase.
key: "${{ env.BASE_CACHE_KEY }}\
${{ hashFiles('**/requirements.txt') }}"
${{ hashFiles('**/requirements.txt') }}-\
${{ hashFiles('setup.py') }}"
restore-keys: |
${{ env.BASE_CACHE_KEY }}
- name: Install dependencies
Expand All @@ -141,6 +231,9 @@ jobs:
with:
name: dist-${{ matrix.python-version }}
path: dist
- name: Setup tmate debug session
uses: mxschmitt/action-tmate@v3
if: env.RUN_TMATE
build_lambda:
runs-on: ubuntu-latest
needs: build
Expand Down Expand Up @@ -183,3 +276,6 @@ jobs:
py${{ matrix.python-version }}-\
${{ env.GH_SHORT_SHA }}"
path: lambda_zip_contents/
- name: Setup tmate debug session
uses: mxschmitt/action-tmate@v3
if: env.RUN_TMATE
10 changes: 0 additions & 10 deletions .mdl_config.json

This file was deleted.

40 changes: 40 additions & 0 deletions .mdl_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---

# Default state for all rules
default: true

# MD003/heading-style/header-style - Heading style
MD003:
# Enforce the ATX-closed style of header
style: "atx_closed"

# MD004/ul-style - Unordered list style
MD004:
# Enforce dashes for unordered lists
style: "dash"

# MD013/line-length - Line length
MD013:
# Do not enforce for code blocks
code_blocks: false
# Do not enforce for tables
tables: false

# MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the
# same content
MD024:
# Allow headers with the same content as long as they are not in the same
# parent heading
allow_different_nesting: true

# MD029/ol-prefix - Ordered list item prefix
MD029:
# Enforce the `1.` style for ordered lists
style: "one"

# MD033/no-inline-html - Inline HTML
MD033:
# The h1 and img elements are allowed to permit header images
allowed_elements:
- h1
- img
37 changes: 26 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ repos:
hooks:
- id: markdownlint
args:
- --config=.mdl_config.json
- --config=.mdl_config.yaml
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.3.0
rev: v2.3.2
hooks:
- id: prettier
- repo: https://github.com/adrienverge/yamllint
Expand All @@ -47,14 +47,27 @@ repos:
args:
- --strict

# pre-commit hooks
- repo: https://github.com/pre-commit/pre-commit
rev: v2.13.0
hooks:
- id: validate_manifest

# Shell script hooks
- repo: https://github.com/lovesegfault/beautysh
rev: v6.1.0
- repo: https://github.com/cisagov/pre-commit-shfmt
rev: v0.0.2
hooks:
- id: beautysh
- id: shfmt
args:
- --indent-size
# Indent by two spaces
- -i
- '2'
# Binary operators may start a line
- -bn
# Switch cases are indented
- -ci
# Redirect operators are followed by a space
- -sr
- repo: https://github.com/detailyang/pre-commit-shell
rev: 1.0.5
hooks:
Expand All @@ -78,7 +91,7 @@ repos:
name: bandit (everything else)
exclude: tests
- repo: https://github.com/psf/black
rev: 21.5b2
rev: 21.7b0
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
Expand All @@ -88,15 +101,17 @@ repos:
additional_dependencies:
- flake8-docstrings
- repo: https://github.com/PyCQA/isort
rev: 5.8.0
rev: 5.9.2
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.812
rev: v0.910
hooks:
- id: mypy
additional_dependencies:
- types-setuptools
- repo: https://github.com/asottile/pyupgrade
rev: v2.19.1
rev: v2.21.2
hooks:
- id: pyupgrade

Expand Down Expand Up @@ -133,7 +148,7 @@ repos:

# Docker hooks
- repo: https://github.com/IamTheFij/docker-pre-commit
rev: v2.0.0
rev: v2.0.1
hooks:
- id: docker-compose-check

Expand Down
15 changes: 5 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ set -o pipefail
# requirements and then exit.
function check_dependencies {
required_tools="pip python zip"
for tool in $required_tools
do
if [ -z "$(command -v "$tool")" ]
then
for tool in $required_tools; do
if [ -z "$(command -v "$tool")" ]; then
echo "This script requires the following tools to run:"
for item in $required_tools
do
for item in $required_tools; do
echo "- $item"
done
exit 1
Expand Down Expand Up @@ -88,13 +85,11 @@ cp lambda_handler.py "$BUILD_DIR"
# Zip it all up.
###
OUTPUT_DIR="/output"
if [ ! -d "$OUTPUT_DIR" ]
then
if [ ! -d "$OUTPUT_DIR" ]; then
mkdir "$OUTPUT_DIR"
fi

if [ -e "$OUTPUT_DIR/$ZIP_FILE" ]
then
if [ -e "$OUTPUT_DIR/$ZIP_FILE" ]; then
rm "$OUTPUT_DIR/$ZIP_FILE"
fi

Expand Down
5 changes: 2 additions & 3 deletions bump_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ HELP_INFORMATION="bump_version.sh (show|major|minor|patch|prerelease|build|final

old_version=$(sed -n "s/^__version__ = \"\(.*\)\"$/\1/p" $VERSION_FILE)

if [ $# -ne 1 ]
then
if [ $# -ne 1 ]; then
echo "$HELP_INFORMATION"
else
case $1 in
major|minor|patch|prerelease|build)
major | minor | patch | prerelease | build)
new_version=$(python -c "import semver; print(semver.bump_$1('$old_version'))")
echo Changing version from "$old_version" to "$new_version"
# A temp file is used to provide compatability with macOS development
Expand Down
8 changes: 7 additions & 1 deletion eal/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
"""Code to run if this package is used as a Python module."""

# Standard Python Libraries
import sys

from .example_aws_lambda import main

main()
return_code = main()

if return_code:
sys.exit(return_code)
Loading