From ad11340779355f87451b3d0a9ccb82f07734397d Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Mon, 16 Dec 2019 09:51:13 -0500 Subject: [PATCH 01/57] Initial commit with changes from skeleton-python-library. --- Dockerfile | 15 +++++ README.md | 16 +++--- build.sh | 73 ++++++++++++++++++++++++ bump_version.sh | 47 ++++++++++++++++ docker-compose.yml | 8 +++ eal/__init__.py | 3 + {src/example => eal}/_version.py | 2 +- eal/example_aws_lambda.py | 76 +++++++++++++++++++++++++ lambda_handler.py | 45 +++++++++++++++ setup.py | 23 ++++---- src/example/__init__.py | 5 -- src/example/data/secret.txt | 1 - src/example/example.py | 74 ------------------------- tag.sh | 9 +++ tests/test_example.py | 95 -------------------------------- tests/test_example_aws_lambda.py | 90 ++++++++++++++++++++++++++++++ 16 files changed, 385 insertions(+), 197 deletions(-) create mode 100644 Dockerfile create mode 100755 build.sh create mode 100755 bump_version.sh create mode 100644 docker-compose.yml create mode 100644 eal/__init__.py rename {src/example => eal}/_version.py (70%) create mode 100755 eal/example_aws_lambda.py create mode 100644 lambda_handler.py delete mode 100644 src/example/__init__.py delete mode 100644 src/example/data/secret.txt delete mode 100755 src/example/example.py create mode 100755 tag.sh delete mode 100644 tests/test_example.py create mode 100644 tests/test_example_aws_lambda.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..93c3756 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM lambci/lambda:build-python3.8 +LABEL maintainer="mark.feldhousen@trio.dhs.gov" +LABEL vendor="Cyber and Infrastructure Security Agency" + +COPY build.sh . + +# Files needed to install local eal module +COPY setup.py . +COPY requirements.txt . +COPY README.md . +COPY eal ./eal + +COPY lambda_handler.py . + +ENTRYPOINT ["./build.sh"] diff --git a/README.md b/README.md index 58440eb..0ece328 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ -# skeleton-python-library # +# skeleton-aws-lambda # -[![GitHub Build Status](https://github.com/cisagov/skeleton-python-library/workflows/build/badge.svg)](https://github.com/cisagov/skeleton-python-library/actions) -[![Coverage Status](https://coveralls.io/repos/github/cisagov/skeleton-python-library/badge.svg?branch=develop)](https://coveralls.io/github/cisagov/skeleton-python-library?branch=develop) -[![Total alerts](https://img.shields.io/lgtm/alerts/g/cisagov/skeleton-python-library.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/cisagov/skeleton-python-library/alerts/) -[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/cisagov/skeleton-python-library.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/cisagov/skeleton-python-library/context:python) -[![Known Vulnerabilities](https://snyk.io/test/github/cisagov/skeleton-python-library/develop/badge.svg)](https://snyk.io/test/github/cisagov/skeleton-python-library) +[![GitHub Build Status](https://github.com/cisagov/skeleton-aws-lambda/workflows/build/badge.svg)](https://github.com/cisagov/skeleton-aws-lambda/actions) +[![Coverage Status](https://coveralls.io/repos/github/cisagov/skeleton-aws-lambda/badge.svg?branch=develop)](https://coveralls.io/github/cisagov/skeleton-aws-lambda?branch=develop) +[![Total alerts](https://img.shields.io/lgtm/alerts/g/cisagov/skeleton-aws-lambda.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/cisagov/skeleton-aws-lambda/alerts/) +[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/cisagov/skeleton-aws-lambda.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/cisagov/skeleton-aws-lambda/context:python) +[![Known Vulnerabilities](https://snyk.io/test/github/cisagov/skeleton-aws-lambda/develop/badge.svg)](https://snyk.io/test/github/cisagov/skeleton-aws-lambda) This is a generic skeleton project that can be used to quickly get a -new [cisagov](https://github.com/cisagov) Python library GitHub +new [cisagov](https://github.com/cisagov) Python AWS Lambda GitHub project started. This skeleton project contains [licensing information](LICENSE), as well as [pre-commit hooks](https://pre-commit.com) and [GitHub Actions](https://github.com/features/actions) configurations -appropriate for a Python library project. +appropriate for a Python based AWS Lambda. ## Contributing ## diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..886b7bb --- /dev/null +++ b/build.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash + +set -o nounset +set -o errexit +set -o pipefail + +### +# Define the name of the Lambda zip file being produced +### +ZIP_FILE=skeleton-aws-lambda.zip + +### +# Set up the Python virtual environment +### +VENV_DIR=/venv +python -m venv $VENV_DIR +# Here shellcheck complains because it can't follow the dynamic path. +# The path doesn't even exist until runtime, so we must disable that +# check. +# +# shellcheck disable=1090 +source $VENV_DIR/bin/activate + +### +# Update pip and setuptools +### +pip install --upgrade pip setuptools + +### +# Install local example AWS lambda (eal) requirements +### +pip install -r requirements.txt + +### +# Leave the Python virtual environment +# +# Note that we have to turn off nounset before running deactivate, +# since otherwise we get an error that states "/venv/bin/activate: +# line 31: $1: unbound variable". +### +set +o nounset +deactivate +set -o nounset + +### +# Set up the build directory +### +BUILD_DIR=/build + +### +# Copy all packages, including any hidden dotfiles. Also copy the +# local eal package and the Lambda handler. +### +cp -rT $VENV_DIR/lib/python3.8/site-packages/ $BUILD_DIR +cp -rT $VENV_DIR/lib64/python3.8/site-packages/ $BUILD_DIR +cp -r eal $BUILD_DIR +cp lambda_handler.py $BUILD_DIR + +### +# Zip it all up +### +OUTPUT_DIR=/output +if [ ! -d $OUTPUT_DIR ] +then + mkdir $OUTPUT_DIR +fi + +if [ -e $OUTPUT_DIR/$ZIP_FILE ] +then + rm $OUTPUT_DIR/$ZIP_FILE +fi +cd $BUILD_DIR +zip -rq9 $OUTPUT_DIR/$ZIP_FILE . diff --git a/bump_version.sh b/bump_version.sh new file mode 100755 index 0000000..4e203c4 --- /dev/null +++ b/bump_version.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +# bump_version.sh (show|major|minor|patch|prerelease|build) + +set -o nounset +set -o errexit +set -o pipefail + +VERSION_FILE=eal/_version.py + +HELP_INFORMATION="bump_version.sh (show|major|minor|patch|prerelease|build|finalize)" + +old_version=$(grep __version__ $VERSION_FILE | grep -o '".*"' | sed 's/"//g') + +if [ $# -ne 1 ] +then + echo "$HELP_INFORMATION" +else + case $1 in + 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" + tmp_file=/tmp/version.$$ + sed "s/$old_version/$new_version/" $VERSION_FILE > $tmp_file + mv $tmp_file $VERSION_FILE + git add $VERSION_FILE + git commit -m"Bump version from $old_version to $new_version" + git push + ;; + finalize) + new_version=$(python -c "import semver; print(semver.finalize_version('$old_version'))") + echo Changing version from "$old_version" to "$new_version" + tmp_file=/tmp/version.$$ + sed "s/$old_version/$new_version/" $VERSION_FILE > $tmp_file + mv $tmp_file $VERSION_FILE + git add $VERSION_FILE + git commit -m"Finalize version from $old_version to $new_version" + git push + ;; + show) + echo "$old_version" + ;; + *) + echo "$HELP_INFORMATION" + ;; + esac +fi diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..6c67abb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +version: '3.2' + +services: + build_example_aws_lambda: + build: . + image: 'cisagov/build_example_aws_lambda' + volumes: + - .:/output diff --git a/eal/__init__.py b/eal/__init__.py new file mode 100644 index 0000000..7699f8d --- /dev/null +++ b/eal/__init__.py @@ -0,0 +1,3 @@ +"""This package contains the skeleton-aws-lambda code.""" + +__version__ = "1.0.0" diff --git a/src/example/_version.py b/eal/_version.py similarity index 70% rename from src/example/_version.py rename to eal/_version.py index 33cee84..de155d7 100644 --- a/src/example/_version.py +++ b/eal/_version.py @@ -1,2 +1,2 @@ """This file defines the version of this module.""" -__version__ = "0.0.1" +__version__ = "1.0.0" diff --git a/eal/example_aws_lambda.py b/eal/example_aws_lambda.py new file mode 100755 index 0000000..87b6242 --- /dev/null +++ b/eal/example_aws_lambda.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 + +"""example_aws_lambda: An example AWS lambda for the cisagov organization. +Usage: + eal --region REGION --message MESSAGE [--log-level=LEVEL] + eal (-h | --help) + eal --version + +Options: + -h --help Show this message. + --version Show version. + --region REGION The region this is running in. + --message MESSAGE The message to output. + --log-level=LEVEL If specified, then the log level will be set to + the specified value. Valid values are "debug", + "info", "warning", "error", and "critical". + [default: warning] +""" + +# Standard library +from datetime import datetime, timezone +import logging + +# Third-party libraries (install with pip) +import docopt + +# Local library +from ._version import __version__ + +def setup_logging(log_level): + try: + logging.basicConfig( + format="%(asctime)-15s %(levelname)s %(message)s", level=log_level.upper() + ) + except ValueError: + logging.critical( + f'"{log_level}" is not a valid logging level. Possible values ' + "are debug, info, warning, error, and critical." + ) + return 1 + +def do_lambda_functionality(region=None, invocation_time=None, message="Hello, World!"): + """Print out the provided region, invocation time, and the function's time.""" + function_time = datetime.now(timezone.utc) + + logging.debug(__name__) + print(f"Region: {region}") + print(f"Invocation Time: {invocation_time}") + print(f"Function Time (UTC): {function_time}") + print(f"Provided Message: {message}") + + return True + +def main(): + """Set up logging and call the import_data function.""" + # Parse command line arguments + args = docopt.docopt(__doc__, version=__version__) + + # Set up logging + setup_logging(args["--log-level"]) + + + result = do_lambda_functionality( + args["--region"], + datetime.now(timezone.utc), + args["--message"] + ) + + # Stop logging and clean up + logging.shutdown() + + return 0 if result else -1 + + +if __name__ == "__main__": + main() diff --git a/lambda_handler.py b/lambda_handler.py new file mode 100644 index 0000000..61521bc --- /dev/null +++ b/lambda_handler.py @@ -0,0 +1,45 @@ +"""This module contains the lamdba_handler code.""" + +import logging +import os + +# Local module +from eal import example_aws_lambda as eal + +# This Lambda function expects the following environment variables to be +# defined: +# 1. messaget - The message for the lambda to print +# 2. log_level - If provided it should be one of the following: "debug", "info", +# "warning", "error", and "critical" + +# In the case of AWS Lambda, the root logger is used BEFORE our Lambda handler +# runs, and this creates a default handler that goes to the console. Once +# logging has been configured, calling logging.basicConfig() has no effect. We +# can get around this by removing any root handlers (if present) before calling +# logging.basicConfig(). This unconfigures logging and allows --debug to +# affect the logging level that appears in the CloudWatch logs. +# +# See +# https://stackoverflow.com/questions/1943747/python-logging-before-you-run-logging-basicconfig +# and +# https://stackoverflow.com/questions/37703609/using-python-logging-with-aws-lambda +# for more details. +root = logging.getLogger() +if root.handlers: + for handler in root.handlers: + root.removeHandler(handler) + + +def handler(event, context): + """Handle all Lambda events.""" + eal.setup_logging(os.environ.get("log_level", "info")) + + logging.debug(f"AWS Event was: {event}") + + result = eal.do_lambda_functionality( + region=event["region"], + invocation_time=event["time"], + message=os.environ["message"] + ) + + return result diff --git a/setup.py b/setup.py index eb246c4..85cda7e 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ """ -This is the setup module for the example project. +This is the setup module for the example lambda. Based on: @@ -11,7 +11,7 @@ from glob import glob from os.path import splitext, basename -from setuptools import setup, find_packages +from setuptools import setup def readme(): @@ -29,16 +29,16 @@ def package_vars(version_file): setup( - name="example", + name="example-aws-lambda", # Versions should comply with PEP440 - version=package_vars("src/example/_version.py")["__version__"], - description="Example python library", + version=package_vars("eal/_version.py")["__version__"], + description="A skeleton with an example AWS lambda to build from.", long_description=readme(), long_description_content_type="text/markdown", # NCATS "homepage" url="https://www.us-cert.gov/resources/ncats", # The project's main homepage - download_url="https://github.com/cisagov/skeleton-python-library", + download_url="https://github.com/cisagov/skeleton-aws-lambda", # Author details author="Cyber and Infrastructure Security Agency", author_email="ncats@hq.dhs.gov", @@ -59,16 +59,13 @@ def package_vars(version_file): "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", ], # What does your project relate to? keywords="skeleton", - packages=find_packages(where="src"), - package_dir={"": "src"}, - package_data={"example": ["data/*.txt"]}, - py_modules=[splitext(basename(path))[0] for path in glob("src/*.py")], - include_package_data=True, + packages=["eal"], + py_modules=[splitext(basename(path))[0] for path in glob("eal/*.py")], install_requires=["docopt", "setuptools"], extras_require={"test": ["pre-commit", "pytest", "pytest-cov", "coveralls"]}, - # Conveniently allows one to run the CLI tool as `example` - entry_points={"console_scripts": ["example = example.example:main"]}, + entry_points={"console_scripts": ["eal = eal.example_aws_lambda:main"]}, ) diff --git a/src/example/__init__.py b/src/example/__init__.py deleted file mode 100644 index ba27a7c..0000000 --- a/src/example/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -"""The example library.""" -from .example import example_div -from ._version import __version__ # noqa: F401 - -__all__ = ["example_div"] diff --git a/src/example/data/secret.txt b/src/example/data/secret.txt deleted file mode 100644 index c40a49b..0000000 --- a/src/example/data/secret.txt +++ /dev/null @@ -1 +0,0 @@ -Three may keep a secret, if two of them are dead. diff --git a/src/example/example.py b/src/example/example.py deleted file mode 100755 index d389e0d..0000000 --- a/src/example/example.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python - -"""example is an example Python library and tool. - -Usage: - example [--log-level=LEVEL] - example (-h | --help) - -Options: - -h --help Show this message. - --log-level=LEVEL If specified, then the log level will be set to - the specified value. Valid values are "debug", "info", - "warning", "error", and "critical". [default: warning] -""" - -import logging -import os -import sys - -import docopt -import pkg_resources - -from ._version import __version__ - -DEFAULT_ECHO_MESSAGE = "Hello World from the example default!" - - -def example_div(x, y): - """Print some logging messages.""" - logging.debug("This is a debug message") - logging.info("This is an info message") - logging.warning("This is a warning message") - logging.error("This is an error message") - logging.critical("This is a critical message") - return x / y - - -def main(): - """Set up logging and call the example function.""" - args = docopt.docopt(__doc__, version=__version__) - # Set up logging - log_level = args["--log-level"] - try: - logging.basicConfig( - format="%(asctime)-15s %(levelname)s %(message)s", level=log_level.upper() - ) - except ValueError: - logging.critical( - f'"{log_level}" is not a valid logging level. Possible values ' - "are debug, info, warning, and error." - ) - return 1 - - print(f"8 / 2 == {example_div(8, 2)}") - - # Access some data from an environment variable - message = os.getenv("ECHO_MESSAGE", DEFAULT_ECHO_MESSAGE) - print(f'ECHO_MESSAGE="{message}"') - - # Access some data from our package data (see the setup.py) - secret_message = ( - pkg_resources.resource_string("example", "data/secret.txt") - .decode("utf-8") - .strip() - ) - print(f'Secret="{secret_message}"') - - # Stop logging and clean up - logging.shutdown() - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/tag.sh b/tag.sh new file mode 100755 index 0000000..e1f7447 --- /dev/null +++ b/tag.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -o nounset +set -o errexit +set -o pipefail + +version=$(./bump_version.sh show) + +git tag "v$version" && git push --tags diff --git a/tests/test_example.py b/tests/test_example.py deleted file mode 100644 index 5e41e31..0000000 --- a/tests/test_example.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env pytest -vs -"""Tests for example.""" - -import logging -import os -import sys -from unittest.mock import patch - -import pytest - -import example - -div_params = [ - (1, 1, 1), - (2, 2, 1), - (0, 1, 0), - (8, 2, 4), - pytest.param(0, 0, 0, marks=pytest.mark.xfail(raises=ZeroDivisionError)), -] - -log_levels = ( - "debug", - "info", - "warning", - "error", - "critical", - pytest.param("critical2", marks=pytest.mark.xfail), -) - -# define sources of version strings -RELEASE_TAG = os.getenv("RELEASE_TAG") -PROJECT_VERSION = example.__version__ - - -def test_stdout_version(capsys): - """Verify that version string sent to stdout agrees with the module version.""" - with pytest.raises(SystemExit): - with patch.object(sys, "argv", ["bogus", "--version"]): - example.example.main() - captured = capsys.readouterr() - assert ( - captured.out == f"{PROJECT_VERSION}\n" - ), "standard output by '--version' should agree with module.__version__" - - -@pytest.mark.skipif( - RELEASE_TAG in [None, ""], reason="this is not a release (RELEASE_TAG not set)" -) -def test_release_version(): - """Verify that release tag version agrees with the module version.""" - assert ( - RELEASE_TAG == f"v{PROJECT_VERSION}" - ), "RELEASE_TAG does not match the project version" - - -@pytest.mark.parametrize("level", log_levels) -def test_log_levels(level): - """Validate commandline log-level arguments.""" - with patch.object(sys, "argv", ["bogus", f"--log-level={level}"]): - with patch.object(logging.root, "handlers", []): - assert ( - logging.root.hasHandlers() is False - ), "root logger should not have handlers yet" - return_code = example.example.main() - assert ( - logging.root.hasHandlers() is True - ), "root logger should now have a handler" - assert return_code == 0, "main() should return success (0)" - - -@pytest.mark.parametrize("dividend, divisor, quotient", div_params) -def test_division(dividend, divisor, quotient): - """Verify division results.""" - result = example.example_div(dividend, divisor) - assert result == quotient, "result should equal quotient" - - -@pytest.mark.slow -def test_slow_division(): - """Example of using a custom marker. - - This test will only be run if --runslow is passed to pytest. - Look in conftest.py to see how this is implemented. - """ - import time - - result = example.example_div(256, 16) - time.sleep(4) - assert result == 16, "result should equal be 16" - - -def test_zero_division(): - """Verify that division by zero throws the correct exception.""" - with pytest.raises(ZeroDivisionError): - example.example_div(1, 0) diff --git a/tests/test_example_aws_lambda.py b/tests/test_example_aws_lambda.py new file mode 100644 index 0000000..4cad854 --- /dev/null +++ b/tests/test_example_aws_lambda.py @@ -0,0 +1,90 @@ +#!/usr/bin/env pytest -vs +"""Tests for example-aws-lambda.""" + +from datetime import datetime, timezone +import logging +import os +import sys +from unittest.mock import patch + +import pytest + +from eal import example_aws_lambda as eal + +log_levels = ( + "debug", + "info", + "warning", + "error", + "critical", + pytest.param("critical2", marks=pytest.mark.xfail), +) + +# define sources of version strings +RELEASE_TAG = os.getenv("RELEASE_TAG") +PROJECT_VERSION = eal.__version__ + +TEST_REGION = "pytest-local" + + +def test_stdout_version(capsys): + """Verify that version string sent to stdout agrees with the module version.""" + with pytest.raises(SystemExit): + with patch.object(sys, "argv", ["bogus", "--version"]): + eal.main() + captured = capsys.readouterr() + assert ( + captured.out == f"{PROJECT_VERSION}\n" + ), "standard output by '--version' should agree with module.__version__" + + +@pytest.mark.skipif( + RELEASE_TAG in [None, ""], reason="this is not a release (RELEASE_TAG not set)" +) +def test_release_version(): + """Verify that release tag version agrees with the module version.""" + assert ( + RELEASE_TAG == f"v{PROJECT_VERSION}" + ), "RELEASE_TAG does not match the project version" + + +@pytest.mark.parametrize("level", log_levels) +def test_log_levels(level): + """Validate commandline log-level arguments.""" + test_message = "pytest-log_levels" + with patch.object(sys, "argv", ["bogus", f"--region={TEST_REGION}", f"--message={test_message}", f"--log-level={level}"]): + with patch.object(logging.root, "handlers", []): + assert ( + logging.root.hasHandlers() is False + ), "root logger should not have handlers yet" + return_code = eal.main() + assert ( + logging.root.hasHandlers() is True + ), "root logger should now have a handler" + assert return_code == 0, "main() should return success (0)" + + +def test_lambda_function_run(capsys): + """Verify that the core function works.""" + test_message = "pytest-lambda-functionality" + test_time = datetime.now(timezone.utc) + eal.setup_logging("warning") + eal.do_lambda_functionality(TEST_REGION, test_time, test_message) + captured = capsys.readouterr() + output_lines = captured.out.split("\n") + assert (len(output_lines) == 5), "unexpected output length" + assert (output_lines[0] == f"Region: {TEST_REGION}"), "region did not match what was provided" + assert (output_lines[1] == f"Invocation Time: {test_time}"), "invocation time did not match what was provided" + assert (output_lines[3] == f"Provided Message: {test_message}"), "message did not match what was provided" + + +def test_commandline_run(capsys): + """Verify that the script works from the commandline.""" + test_message = "pytest-cli_functionality" + with patch.object(sys, "argv", ["bogus", f"--region={TEST_REGION}", f"--message={test_message}"]): + eal.main() + captured = capsys.readouterr() + output_lines = (captured.out).split("\n") + assert (len(output_lines) == 5), "unexpected output length" + assert (output_lines[0] == f"Region: {TEST_REGION}"), "region did not match what was provided" + assert (output_lines[3] == f"Provided Message: {test_message}"), "message did not match what was provided" From f6fff57ac2f6e8b914535edfef9d88a26b3710f1 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Mon, 16 Dec 2019 09:57:09 -0500 Subject: [PATCH 02/57] Change GitHub Actions Python versions to 3.8 --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e2c1a1f..a7b709c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions/setup-python@v1 with: - python-version: 3.7 + python-version: 3.8 - name: Cache pip test requirements uses: actions/cache@v1 with: @@ -42,7 +42,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions/setup-python@v1 with: - python-version: 3.7 + python-version: 3.8 - name: Cache pip test requirements uses: actions/cache@v1 with: @@ -72,7 +72,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions/setup-python@v1 with: - python-version: 3.7 + python-version: 3.8 - name: Cache pip build requirements uses: actions/cache@v1 with: From 55bd2cab76b47776bf6134c3ab856a7fa459a25a Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Mon, 16 Dec 2019 10:11:18 -0500 Subject: [PATCH 03/57] Fix code formatting that snuck through because pre-commit wasn't installed as a hook. --- eal/example_aws_lambda.py | 10 ++++---- lambda_handler.py | 2 +- tests/test_example_aws_lambda.py | 39 ++++++++++++++++++++++++-------- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/eal/example_aws_lambda.py b/eal/example_aws_lambda.py index 87b6242..8b2522d 100755 --- a/eal/example_aws_lambda.py +++ b/eal/example_aws_lambda.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 """example_aws_lambda: An example AWS lambda for the cisagov organization. + Usage: eal --region REGION --message MESSAGE [--log-level=LEVEL] eal (-h | --help) @@ -27,7 +28,9 @@ # Local library from ._version import __version__ + def setup_logging(log_level): + """Set up logging at the provided level.""" try: logging.basicConfig( format="%(asctime)-15s %(levelname)s %(message)s", level=log_level.upper() @@ -39,6 +42,7 @@ def setup_logging(log_level): ) return 1 + def do_lambda_functionality(region=None, invocation_time=None, message="Hello, World!"): """Print out the provided region, invocation time, and the function's time.""" function_time = datetime.now(timezone.utc) @@ -51,6 +55,7 @@ def do_lambda_functionality(region=None, invocation_time=None, message="Hello, W return True + def main(): """Set up logging and call the import_data function.""" # Parse command line arguments @@ -59,11 +64,8 @@ def main(): # Set up logging setup_logging(args["--log-level"]) - result = do_lambda_functionality( - args["--region"], - datetime.now(timezone.utc), - args["--message"] + args["--region"], datetime.now(timezone.utc), args["--message"] ) # Stop logging and clean up diff --git a/lambda_handler.py b/lambda_handler.py index 61521bc..d89c0d5 100644 --- a/lambda_handler.py +++ b/lambda_handler.py @@ -39,7 +39,7 @@ def handler(event, context): result = eal.do_lambda_functionality( region=event["region"], invocation_time=event["time"], - message=os.environ["message"] + message=os.environ["message"], ) return result diff --git a/tests/test_example_aws_lambda.py b/tests/test_example_aws_lambda.py index 4cad854..720abbe 100644 --- a/tests/test_example_aws_lambda.py +++ b/tests/test_example_aws_lambda.py @@ -52,7 +52,16 @@ def test_release_version(): def test_log_levels(level): """Validate commandline log-level arguments.""" test_message = "pytest-log_levels" - with patch.object(sys, "argv", ["bogus", f"--region={TEST_REGION}", f"--message={test_message}", f"--log-level={level}"]): + with patch.object( + sys, + "argv", + [ + "bogus", + f"--region={TEST_REGION}", + f"--message={test_message}", + f"--log-level={level}", + ], + ): with patch.object(logging.root, "handlers", []): assert ( logging.root.hasHandlers() is False @@ -72,19 +81,31 @@ def test_lambda_function_run(capsys): eal.do_lambda_functionality(TEST_REGION, test_time, test_message) captured = capsys.readouterr() output_lines = captured.out.split("\n") - assert (len(output_lines) == 5), "unexpected output length" - assert (output_lines[0] == f"Region: {TEST_REGION}"), "region did not match what was provided" - assert (output_lines[1] == f"Invocation Time: {test_time}"), "invocation time did not match what was provided" - assert (output_lines[3] == f"Provided Message: {test_message}"), "message did not match what was provided" + assert len(output_lines) == 5, "unexpected output length" + assert ( + output_lines[0] == f"Region: {TEST_REGION}" + ), "region did not match what was provided" + assert ( + output_lines[1] == f"Invocation Time: {test_time}" + ), "invocation time did not match what was provided" + assert ( + output_lines[3] == f"Provided Message: {test_message}" + ), "message did not match what was provided" def test_commandline_run(capsys): """Verify that the script works from the commandline.""" test_message = "pytest-cli_functionality" - with patch.object(sys, "argv", ["bogus", f"--region={TEST_REGION}", f"--message={test_message}"]): + with patch.object( + sys, "argv", ["bogus", f"--region={TEST_REGION}", f"--message={test_message}"] + ): eal.main() captured = capsys.readouterr() output_lines = (captured.out).split("\n") - assert (len(output_lines) == 5), "unexpected output length" - assert (output_lines[0] == f"Region: {TEST_REGION}"), "region did not match what was provided" - assert (output_lines[3] == f"Provided Message: {test_message}"), "message did not match what was provided" + assert len(output_lines) == 5, "unexpected output length" + assert ( + output_lines[0] == f"Region: {TEST_REGION}" + ), "region did not match what was provided" + assert ( + output_lines[3] == f"Provided Message: {test_message}" + ), "message did not match what was provided" From c40688203d9083a660f96e7cc4a8119a1200352c Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Mon, 16 Dec 2019 10:15:30 -0500 Subject: [PATCH 04/57] Set a requirement for the coverage package to be less than version 5.0 due to an ImportError seen in the GitHub Action. When installed locally I correctly get a 4.4 < installed < 5.0, but on GitHub it is pulling down 5.0 which gives the coveralls package problems. --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 85cda7e..f9eb077 100644 --- a/setup.py +++ b/setup.py @@ -66,6 +66,8 @@ def package_vars(version_file): packages=["eal"], py_modules=[splitext(basename(path))[0] for path in glob("eal/*.py")], install_requires=["docopt", "setuptools"], - extras_require={"test": ["pre-commit", "pytest", "pytest-cov", "coveralls"]}, + extras_require={ + "test": ["pre-commit", "pytest", "pytest-cov", "coveralls", "coverage < 5.0"] + }, entry_points={"console_scripts": ["eal = eal.example_aws_lambda:main"]}, ) From 77799ab6923d1d19ab7ca9293776faf7e2096210 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Mon, 16 Dec 2019 10:37:31 -0500 Subject: [PATCH 05/57] Fix coveralls configuration file to look at the correct directory for code. --- .coveragerc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.coveragerc b/.coveragerc index d315b87..37370c2 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,7 +2,7 @@ # https://coverage.readthedocs.io/en/latest/config.html [run] -source = src/example +source = eal omit = branch = true From 2fa4cbe194ac05ff89e377ad91adfa3fc7eddb6f Mon Sep 17 00:00:00 2001 From: Jeremy Frasier Date: Fri, 24 Jan 2020 16:45:48 -0500 Subject: [PATCH 06/57] Make workflow run when a PR is opened, synchronized, or reopened A user forked cisagov/scan-target-data and created a pull request, but the required GitHub Action(s) did not run. This is presumably because the user does not have Actions enabled in his or her fork. Ideally, the required Action(s) would run in cisagov/scan-target-data when a PR to merge changes back is created. Based on my reading of this link, adding the "pull_request" event type should make this happen: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows#pull-request-events-for-forked-repositories --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d12843d..c9cc05b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,7 @@ --- name: build -on: [push] +on: [push, pull_request] jobs: build: From dbd589d2e27b517726fec167987058b3d687992f Mon Sep 17 00:00:00 2001 From: Jeremy Frasier Date: Fri, 24 Jan 2020 17:10:49 -0500 Subject: [PATCH 07/57] Improve list formatting --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c9cc05b..e6c14e6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,10 @@ --- name: build -on: [push, pull_request] +on: [ + push, + pull_request +] jobs: build: From aaef9088f0b3bee886d2c1fc09f4603987b1e785 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Mon, 27 Jan 2020 08:20:25 -0500 Subject: [PATCH 08/57] Pull in changes to build workflow from skeleton-generic to support correct workflow if someone forks and does a pull request. --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e2c1a1f..d56c763 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,10 @@ --- name: build -on: [push] +on: [ + push, + pull_request +] env: PIP_CACHE_DIR: ~/.cache/pip From fb71a2f8cb2a9c9f4a58188b871137b58c12125d Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Mon, 27 Jan 2020 15:02:21 -0500 Subject: [PATCH 09/57] Adjust build.sh comments. Remove explicit setuptools upgrade. Add --system-site-packages flag to venv setup so only packages not in the environment already are installed. --- build.sh | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/build.sh b/build.sh index 886b7bb..9e06bdf 100755 --- a/build.sh +++ b/build.sh @@ -5,15 +5,19 @@ set -o errexit set -o pipefail ### -# Define the name of the Lambda zip file being produced +# Define the name of the Lambda zip file being produced. ### ZIP_FILE=skeleton-aws-lambda.zip ### -# Set up the Python virtual environment +# Set up the Python virtual environment. +# We use --system-site-packages so the venv has access to the packages already +# installed in the container to avoid duplicating what will be available in the +# lambda environment on AWS. ### VENV_DIR=/venv -python -m venv $VENV_DIR +python -m venv --system-site-packages $VENV_DIR + # Here shellcheck complains because it can't follow the dynamic path. # The path doesn't even exist until runtime, so we must disable that # check. @@ -22,17 +26,17 @@ python -m venv $VENV_DIR source $VENV_DIR/bin/activate ### -# Update pip and setuptools +# Upgrade pip. ### -pip install --upgrade pip setuptools +pip install --upgrade pip ### -# Install local example AWS lambda (eal) requirements +# Install local example AWS lambda (eal) and requirements. ### pip install -r requirements.txt ### -# Leave the Python virtual environment +# Leave the Python virtual environment. # # Note that we have to turn off nounset before running deactivate, # since otherwise we get an error that states "/venv/bin/activate: @@ -43,13 +47,13 @@ deactivate set -o nounset ### -# Set up the build directory +# Set up the build directory. ### BUILD_DIR=/build ### -# Copy all packages, including any hidden dotfiles. Also copy the -# local eal package and the Lambda handler. +# Copy all packages, including any hidden dotfiles. Also copy the +# local eal package and the lambda handler. ### cp -rT $VENV_DIR/lib/python3.8/site-packages/ $BUILD_DIR cp -rT $VENV_DIR/lib64/python3.8/site-packages/ $BUILD_DIR @@ -57,7 +61,7 @@ cp -r eal $BUILD_DIR cp lambda_handler.py $BUILD_DIR ### -# Zip it all up +# Zip it all up. ### OUTPUT_DIR=/output if [ ! -d $OUTPUT_DIR ] @@ -69,5 +73,6 @@ if [ -e $OUTPUT_DIR/$ZIP_FILE ] then rm $OUTPUT_DIR/$ZIP_FILE fi + cd $BUILD_DIR zip -rq9 $OUTPUT_DIR/$ZIP_FILE . From 7db87878bfd40ebe073e4860ba0fec3991c7a738 Mon Sep 17 00:00:00 2001 From: Felddy Date: Wed, 29 Jan 2020 16:50:39 -0500 Subject: [PATCH 10/57] Add schema library. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5f82b0e..d5839ce 100644 --- a/setup.py +++ b/setup.py @@ -70,7 +70,7 @@ def package_vars(version_file): package_data={"example": ["data/*.txt"]}, py_modules=[splitext(basename(path))[0] for path in glob("src/*.py")], include_package_data=True, - install_requires=["docopt", "setuptools >= 24.2.0"], + install_requires=["docopt", "setuptools >= 24.2.0", "schema"], extras_require={ "test": [ "pre-commit", From 229da937e2b982e9361de3b18893c23b65be84f9 Mon Sep 17 00:00:00 2001 From: Felddy Date: Wed, 29 Jan 2020 16:53:02 -0500 Subject: [PATCH 11/57] Add schema checks for arguments. Log output instead of print. Improve docs. Do some interesting parsing. --- .isort.cfg | 2 +- src/example/example.py | 67 +++++++++++++++++++++++++++++++----------- 2 files changed, 51 insertions(+), 18 deletions(-) diff --git a/.isort.cfg b/.isort.cfg index c0d5626..1156f7e 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -7,6 +7,6 @@ import_heading_thirdparty=Third-Party Libraries import_heading_firstparty=cisagov Libraries # Should be auto-populated by seed-isort-config hook -known_third_party=docopt,pkg_resources,pytest,setuptools +known_third_party=docopt,pkg_resources,pytest,schema,setuptools # These must be manually set to correctly separate them from third party libraries known_first_party=example diff --git a/src/example/example.py b/src/example/example.py index 28b99f2..b2856d9 100755 --- a/src/example/example.py +++ b/src/example/example.py @@ -2,15 +2,23 @@ """example is an example Python library and tool. +Divide one integer by another and log the result. Also log some information +from an environment variable and a package resource. + +EXIT STATUS + This utility exits with one of the following values: + 0 Calculation completed successfully. + >0 An error occurred. + Usage: - example [--log-level=LEVEL] + example [--log-level=LEVEL] example (-h | --help) Options: -h --help Show this message. --log-level=LEVEL If specified, then the log level will be set to the specified value. Valid values are "debug", "info", - "warning", "error", and "critical". [default: warning] + "warning", "error", and "critical". [default: info] """ # Standard Python Libraries @@ -21,43 +29,68 @@ # Third-Party Libraries import docopt import pkg_resources +from schema import And, Schema, SchemaError, Use from ._version import __version__ DEFAULT_ECHO_MESSAGE = "Hello World from the example default!" -def example_div(x, y): +def example_div(dividend, divisor): """Print some logging messages.""" logging.debug("This is a debug message") logging.info("This is an info message") logging.warning("This is a warning message") logging.error("This is an error message") logging.critical("This is a critical message") - return x / y + return dividend / divisor def main(): """Set up logging and call the example function.""" args = docopt.docopt(__doc__, version=__version__) - # Set up logging - log_level = args["--log-level"] + # Validate and convert arguments as needed + schema = Schema( + { + "--log-level": And( + str, + Use(str.lower), + lambda n: n in ("debug", "info", "warning", "error", "critical"), + error="Possible values for --log-level are " + + "debug, info, warning, error, and critical.", + ), + "": Use(int, error=" must be an integer."), + "": And( + Use(int), + lambda n: n != 0, + error=" must be an integer that is not 0.", + ), + str: object, # Don't care about other keys, if any + } + ) + try: - logging.basicConfig( - format="%(asctime)-15s %(levelname)s %(message)s", level=log_level.upper() - ) - except ValueError: - logging.critical( - f'"{log_level}" is not a valid logging level. Possible values ' - "are debug, info, warning, and error." - ) + args = schema.validate(args) + except SchemaError as err: + # Exit because one or more of the arguments were invalid + print(err, file=sys.stderr) return 1 - print(f"8 / 2 == {example_div(8, 2)}") + # Assign validated arguments to variables + dividend = args[""] + divisor = args[""] + log_level = args["--log-level"] + + # Set up logging + logging.basicConfig( + format="%(asctime)-15s %(levelname)s %(message)s", level=log_level.upper() + ) + + logging.info(f"{dividend} / {divisor} == {example_div(dividend, divisor)}") # Access some data from an environment variable message = os.getenv("ECHO_MESSAGE", DEFAULT_ECHO_MESSAGE) - print(f'ECHO_MESSAGE="{message}"') + logging.info(f'ECHO_MESSAGE="{message}"') # Access some data from our package data (see the setup.py) secret_message = ( @@ -65,7 +98,7 @@ def main(): .decode("utf-8") .strip() ) - print(f'Secret="{secret_message}"') + logging.info(f'Secret="{secret_message}"') # Stop logging and clean up logging.shutdown() From 7cbaaa922b1dafbc10bd3c0deb82070330e15a33 Mon Sep 17 00:00:00 2001 From: Felddy Date: Wed, 29 Jan 2020 16:54:37 -0500 Subject: [PATCH 12/57] Add tests for new arguments --- tests/test_example.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_example.py b/tests/test_example.py index 4d1cef1..dd10029 100644 --- a/tests/test_example.py +++ b/tests/test_example.py @@ -59,7 +59,7 @@ def test_release_version(): @pytest.mark.parametrize("level", log_levels) def test_log_levels(level): """Validate commandline log-level arguments.""" - with patch.object(sys, "argv", ["bogus", f"--log-level={level}"]): + with patch.object(sys, "argv", ["bogus", f"--log-level={level}", "1", "1"]): with patch.object(logging.root, "handlers", []): assert ( logging.root.hasHandlers() is False @@ -96,3 +96,10 @@ def test_zero_division(): """Verify that division by zero throws the correct exception.""" with pytest.raises(ZeroDivisionError): example.example_div(1, 0) + + +def test_zero_divisor_argument(): + """Verify that a divisor of zero is handled as expected.""" + with patch.object(sys, "argv", ["bogus", "1", "0"]): + return_code = example.example.main() + assert return_code == 1, "main() should exit with error" From 8520a7061e8161b71910fd069987b8deed9c54e6 Mon Sep 17 00:00:00 2001 From: Felddy Date: Thu, 30 Jan 2020 11:27:06 -0500 Subject: [PATCH 13/57] Removed uses of xfail. This was a bad example of when to use xfail. See the semantics here: http://doc.pytest.org/en/latest/skipping.html --- tests/test_example.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/test_example.py b/tests/test_example.py index dd10029..c3334d7 100644 --- a/tests/test_example.py +++ b/tests/test_example.py @@ -18,7 +18,6 @@ (2, 2, 1), (0, 1, 0), (8, 2, 4), - pytest.param(0, 0, 0, marks=pytest.mark.xfail(raises=ZeroDivisionError)), ] log_levels = ( @@ -27,7 +26,6 @@ "warning", "error", "critical", - pytest.param("critical2", marks=pytest.mark.xfail), ) # define sources of version strings @@ -71,6 +69,13 @@ def test_log_levels(level): assert return_code == 0, "main() should return success (0)" +def test_bad_log_level(): + """Validate bad log-level argument returns error.""" + with patch.object(sys, "argv", ["bogus", "--log-level=emergency", "1", "1"]): + return_code = example.example.main() + assert return_code == 1, "main() should return failure" + + @pytest.mark.parametrize("dividend, divisor, quotient", div_params) def test_division(dividend, divisor, quotient): """Verify division results.""" From 454553ed62207464a13e32c4454f75a3fa68c91b Mon Sep 17 00:00:00 2001 From: Felddy Date: Thu, 30 Jan 2020 12:19:36 -0500 Subject: [PATCH 14/57] Bumping github actions python version to 3.8. Advertise support for 3.8 in setup.py --- .github/workflows/build.yml | 6 +++--- setup.py | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d56c763..60cc9b9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions/setup-python@v1 with: - python-version: 3.7 + python-version: 3.8 - name: Cache pip test requirements uses: actions/cache@v1 with: @@ -45,7 +45,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions/setup-python@v1 with: - python-version: 3.7 + python-version: 3.8 - name: Cache pip test requirements uses: actions/cache@v1 with: @@ -75,7 +75,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions/setup-python@v1 with: - python-version: 3.7 + python-version: 3.8 - name: Cache pip build requirements uses: actions/cache@v1 with: diff --git a/setup.py b/setup.py index d5839ce..ad59e1a 100644 --- a/setup.py +++ b/setup.py @@ -61,6 +61,7 @@ def package_vars(version_file): "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", ], python_requires=">=3.6", # What does your project relate to? From 532751627a347637814e8a7f626dad487a1b6053 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Mon, 10 Feb 2020 10:39:07 -0500 Subject: [PATCH 15/57] Backported changes to CONTRIBUTING.md from the development guide. --- CONTRIBUTING.md | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 93addc2..eb00ca9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -56,10 +56,31 @@ eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" ``` -For Linux (or on the Mac, if you don't want to use `brew`) you can use +For Linux, Windows Subsystem for Linux (WSL), or on the Mac (if you +don't want to use `brew`) you can use [pyenv/pyenv-installer](https://github.com/pyenv/pyenv-installer) to -install the necessary tools. When you are finished you will need to -add the same two lines above to your profile. +install the necessary tools. Before running this ensure that you have +installed the prerequisites for your platform according to the +[`pyenv` wiki +page](https://github.com/pyenv/pyenv/wiki/common-build-problems). + +On WSL you should treat your platform as whatever Linux distribution +you've chosen to install. + +Once you have installed `pyenv` you will need to add the following +lines to your `.bashrc`: + +```bash +export PATH="$PATH:$HOME/.pyenv/bin" +eval "$(pyenv init -)" +eval "$(pyenv virtualenv-init -)" +``` + +If you are using a shell other than `bash` you should follow the +instructions that the `pyenv-installer` script outputs. + +You will need to reload your shell for these changes to take effect so +you can begin to use `pyenv`. For a list of Python versions that are already installed and ready to use with `pyenv`, use the command `pyenv versions`. To see a list of From f7a4166ad67d961324bc44130e092eb1ddebd320 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Tue, 11 Feb 2020 10:41:17 -0500 Subject: [PATCH 16/57] Update Python version used to 3.8 Update actions/checkout to v2 Update formatting to match downstream children --- .github/workflows/build.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e6c14e6..4953f7c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,20 +10,16 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - - name: Set up Python 3.7 - uses: actions/setup-python@v1 + - uses: actions/checkout@v2 + - uses: actions/setup-python@v1 with: - python-version: 3.7 - + python-version: 3.8 - name: Cache pre-commit hooks uses: actions/cache@v1 with: path: ~/.cache/pre-commit key: "${{ runner.os }}-pre-commit-\ ${{ hashFiles('**/.pre-commit-config.yaml') }}" - - name: Cache pip test requirements uses: actions/cache@v1 with: @@ -33,11 +29,9 @@ jobs: restore-keys: | ${{ runner.os }}-pip-test- ${{ runner.os }}-pip- - - name: Install dependencies run: | python -m pip install --upgrade pip pip install --upgrade -r requirements-test.txt - - name: Run pre-commit on all files run: pre-commit run --all-files From b857939b3d0c5393b8b5528a6bb9bce2ff0f736f Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Wed, 12 Feb 2020 00:01:16 -0500 Subject: [PATCH 17/57] Run pre-commit autoupdate. --- .pre-commit-config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c8fc88a..7856658 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ default_language_version: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.4.0 + rev: v2.5.0 hooks: - id: check-executables-have-shebangs - id: check-json @@ -27,13 +27,13 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.19.0 + rev: v0.22.0 hooks: - id: markdownlint args: - --config=.mdl_config.json - repo: https://github.com/adrienverge/yamllint - rev: v1.18.0 + rev: v1.20.0 hooks: - id: yamllint - repo: https://github.com/detailyang/pre-commit-shell @@ -47,7 +47,7 @@ repos: additional_dependencies: - flake8-docstrings - repo: https://github.com/asottile/pyupgrade - rev: v1.25.1 + rev: v1.26.2 hooks: - id: pyupgrade - repo: https://github.com/PyCQA/bandit @@ -61,7 +61,7 @@ repos: hooks: - id: black - repo: https://github.com/asottile/seed-isort-config - rev: v1.9.3 + rev: v1.9.4 hooks: - id: seed-isort-config - repo: https://github.com/pre-commit/mirrors-isort @@ -71,7 +71,7 @@ repos: hooks: - id: isort - repo: https://github.com/ansible/ansible-lint.git - rev: v4.1.1a5 + rev: v4.2.0 hooks: - id: ansible-lint # files: molecule/default/playbook.yml @@ -81,7 +81,7 @@ repos: - id: terraform_fmt - id: terraform_validate_no_variables - repo: https://github.com/IamTheFij/docker-pre-commit - rev: v1.0.0 + rev: v1.0.1 hooks: - id: docker-compose-check - repo: https://github.com/prettier/prettier From d99fd00bc2e5c4a0afeb2d6717dac7fe77f64d33 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Wed, 12 Feb 2020 00:14:11 -0500 Subject: [PATCH 18/57] Flip cache order to mirror how it is done downstream. --- .github/workflows/build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4953f7c..76801a8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,12 +14,6 @@ jobs: - uses: actions/setup-python@v1 with: python-version: 3.8 - - name: Cache pre-commit hooks - uses: actions/cache@v1 - with: - path: ~/.cache/pre-commit - key: "${{ runner.os }}-pre-commit-\ - ${{ hashFiles('**/.pre-commit-config.yaml') }}" - name: Cache pip test requirements uses: actions/cache@v1 with: @@ -29,6 +23,12 @@ jobs: restore-keys: | ${{ runner.os }}-pip-test- ${{ runner.os }}-pip- + - name: Cache pre-commit hooks + uses: actions/cache@v1 + with: + path: ~/.cache/pre-commit + key: "${{ runner.os }}-pre-commit-\ + ${{ hashFiles('**/.pre-commit-config.yaml') }}" - name: Install dependencies run: | python -m pip install --upgrade pip From fd033377fe93d865ab2cc98042a79c462dbbd976 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Wed, 12 Feb 2020 11:41:16 -0500 Subject: [PATCH 19/57] Fix spacing before comment in .bandit.yml (shown with pre-commit run --verbose --all-files). --- .bandit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bandit.yml b/.bandit.yml index 7b89269..0b53a96 100644 --- a/.bandit.yml +++ b/.bandit.yml @@ -11,4 +11,4 @@ tests: # - B102 skips: - - B101 # skip "assert used" check since assertions are required in pytests + - B101 # skip "assert used" check since assertions are required in pytests From 49f7002b6e3d185718ff78361e6b28e225a75787 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Wed, 12 Feb 2020 15:27:50 -0500 Subject: [PATCH 20/57] Unpin coverage as coveralls supports coverage 5.0+ as of 1.10.0 --- setup.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/setup.py b/setup.py index ad59e1a..928afe9 100644 --- a/setup.py +++ b/setup.py @@ -73,16 +73,7 @@ def package_vars(version_file): include_package_data=True, install_requires=["docopt", "setuptools >= 24.2.0", "schema"], extras_require={ - "test": [ - "pre-commit", - "coveralls", - # coveralls does not currently support coverage 5.0 - # https://github.com/coveralls-clients/coveralls-python/issues/203 - # is the issue for this on the coveralls project - "coverage < 5.0", - "pytest-cov", - "pytest", - ] + "test": ["pre-commit", "coveralls", "coverage", "pytest-cov", "pytest"] }, # Conveniently allows one to run the CLI tool as `example` entry_points={"console_scripts": ["example = example.example:main"]}, From 96675a15987dcf1ecdcecc8c9d2d6df0874507ef Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Wed, 12 Feb 2020 15:40:18 -0500 Subject: [PATCH 21/57] Add --verbose flag to the coveralls call in the test workflow. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4cb95ba..9afd8c3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -64,7 +64,7 @@ jobs: RELEASE_TAG: ${{ github.event.release.tag_name }} run: pytest - name: Upload coverage report - run: coveralls + run: coveralls --verbose env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} if: success() From df8a7eb68c72a9400b9b544d526d965a1a74b503 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Wed, 12 Feb 2020 15:56:23 -0500 Subject: [PATCH 22/57] Pin coveralls version to see if the service_number addition in 1.11.0 is breaking coveralls uploads. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 928afe9..b7bbe70 100644 --- a/setup.py +++ b/setup.py @@ -73,7 +73,7 @@ def package_vars(version_file): include_package_data=True, install_requires=["docopt", "setuptools >= 24.2.0", "schema"], extras_require={ - "test": ["pre-commit", "coveralls", "coverage", "pytest-cov", "pytest"] + "test": ["pre-commit", "coveralls < 1.11.0", "coverage", "pytest-cov", "pytest"] }, # Conveniently allows one to run the CLI tool as `example` entry_points={"console_scripts": ["example = example.example:main"]}, From 8785abe1d4e84a60fae2a551aab0096eafa169d9 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Wed, 12 Feb 2020 16:17:49 -0500 Subject: [PATCH 23/57] Remove --verbose from coveralls call in test workflow. Add comment explaining why coveralls is being pinned. --- .github/workflows/build.yml | 2 +- setup.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9afd8c3..4cb95ba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -64,7 +64,7 @@ jobs: RELEASE_TAG: ${{ github.event.release.tag_name }} run: pytest - name: Upload coverage report - run: coveralls --verbose + run: coveralls env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} if: success() diff --git a/setup.py b/setup.py index b7bbe70..afda7e8 100644 --- a/setup.py +++ b/setup.py @@ -73,7 +73,19 @@ def package_vars(version_file): include_package_data=True, install_requires=["docopt", "setuptools >= 24.2.0", "schema"], extras_require={ - "test": ["pre-commit", "coveralls < 1.11.0", "coverage", "pytest-cov", "pytest"] + "test": [ + "pre-commit", + # coveralls 1.11.0 added a service number for calls from + # GitHub Actions. When run this resulted in a 422 response from the + # coveralls API with the message: + # Unprocessable Entity for url: https://coveralls.io/api/v1/jobs + # Temporarily pinning coveralls to before this version until this + # issue is resolved. + "coveralls < 1.11.0", + "coverage", + "pytest-cov", + "pytest", + ] }, # Conveniently allows one to run the CLI tool as `example` entry_points={"console_scripts": ["example = example.example:main"]}, From 6a7210cc3d2f0f976eec198f620d0ebfc338be57 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Fri, 14 Feb 2020 15:15:31 -0500 Subject: [PATCH 24/57] Pin to testing branch per https://github.com/coveralls-clients/coveralls-python/issues/219 for testing. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index afda7e8..e0d5003 100644 --- a/setup.py +++ b/setup.py @@ -81,7 +81,7 @@ def package_vars(version_file): # Unprocessable Entity for url: https://coveralls.io/api/v1/jobs # Temporarily pinning coveralls to before this version until this # issue is resolved. - "coveralls < 1.11.0", + "coveralls @ git+https://github.com/coveralls-clients/coveralls-python.git@fix-github-actions", "coverage", "pytest-cov", "pytest", From d59f5f97cdfee079a817263fae1d7f797941a77b Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Sun, 16 Feb 2020 15:38:30 -0500 Subject: [PATCH 25/57] Change coveralls pin to avoid the version with the regression. 1.11.1 is released which fixed the regression introduced in 1.11.0 per https://github.com/coveralls-clients/coveralls-python/releases/tag/1.11.1 --- setup.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index e0d5003..ac0d34e 100644 --- a/setup.py +++ b/setup.py @@ -76,12 +76,12 @@ def package_vars(version_file): "test": [ "pre-commit", # coveralls 1.11.0 added a service number for calls from - # GitHub Actions. When run this resulted in a 422 response from the - # coveralls API with the message: + # GitHub Actions. This caused a regression which resulted in a 422 + # response from the coveralls API with the message: # Unprocessable Entity for url: https://coveralls.io/api/v1/jobs - # Temporarily pinning coveralls to before this version until this - # issue is resolved. - "coveralls @ git+https://github.com/coveralls-clients/coveralls-python.git@fix-github-actions", + # 1.11.1 fixed this issue, but to ensure expected behavior we'll pin + # to never grab the regression version. + "coveralls != 1.11.0", "coverage", "pytest-cov", "pytest", From e96577bce4b3b6aefa044943e478301a7d11288f Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Tue, 18 Feb 2020 18:04:06 -0500 Subject: [PATCH 26/57] All references to '-r' for pip calls have been replaced with the more verbose '--requirement'. --- .github/workflows/build.yml | 2 +- CONTRIBUTING.md | 2 +- requirements-dev.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 76801a8..aff7e7a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,6 +32,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install --upgrade -r requirements-test.txt + pip install --upgrade --requirement requirements-test.txt - name: Run pre-commit on all files run: pre-commit run --all-files diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eb00ca9..dacaaad 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -102,7 +102,7 @@ commands: cd skeleton-generic pyenv virtualenv skeleton-generic pyenv local skeleton-generic -pip install -r requirements-dev.txt +pip install --requirement requirements-dev.txt ``` #### Installing the pre-commit hook #### diff --git a/requirements-dev.txt b/requirements-dev.txt index f122cc5..d84ee68 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,2 +1,2 @@ --r requirements-test.txt +--requirement requirements-test.txt ipython From 0478f94b8cd74cbe0c6b24f4b53535a0a92bb280 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Wed, 19 Feb 2020 11:48:02 -0500 Subject: [PATCH 27/57] Adjust language in description of pre-commit step in the GitHub Actions workflow. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cd48651..09535e5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,7 +37,7 @@ jobs: run: | python -m pip install --upgrade pip pip install --upgrade --requirement requirements-test.txt - - name: Run linters on all files + - name: Run pre-commit on all files run: pre-commit run --all-files test: runs-on: ubuntu-latest From 5019d015f7bda4269f694e86d99171da23582646 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Wed, 19 Feb 2020 14:04:32 -0500 Subject: [PATCH 28/57] Update artifact generation in line with work done in the findings-data-import-lambda repository. --- .github/workflows/build.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 09535e5..290a5eb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -89,10 +89,17 @@ jobs: run: | python -m pip install --upgrade pip wheel pip install --upgrade --requirement requirements.txt - - name: Build artifacts - run: python3 setup.py sdist bdist_wheel + - name: Build environment + run: docker-compose build + - name: Generate lambda zip + run: docker-compose up + # We have to unzip the produced lambda zip because the upload-artifact + # action will compress whatever is at/in the provided path. This results + # in a zipped zip file. + - name: Unzip produced zip + run: unzip findings-data-import.zip -d lambda_zip_contents - name: Upload artifacts uses: actions/upload-artifact@v1 with: - name: dist - path: dist + name: skeleton-aws-lambda + path: lambda_zip_contents/ From e7cefd232a2759d8310408f6f87e122a308612de Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Wed, 19 Feb 2020 14:12:57 -0500 Subject: [PATCH 29/57] Update filename to unzip during build action. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 290a5eb..e36224b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -97,7 +97,7 @@ jobs: # action will compress whatever is at/in the provided path. This results # in a zipped zip file. - name: Unzip produced zip - run: unzip findings-data-import.zip -d lambda_zip_contents + run: unzip skeleton-aws-lambda.zip -d lambda_zip_contents - name: Upload artifacts uses: actions/upload-artifact@v1 with: From af261c328c1aefac59b422de973c59662094190d Mon Sep 17 00:00:00 2001 From: Felddy Date: Thu, 20 Feb 2020 17:29:09 -0500 Subject: [PATCH 30/57] Autoupdate pre-commit hooks. Add mypy. --- .pre-commit-config.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1522593..df79e95 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -47,7 +47,7 @@ repos: additional_dependencies: - flake8-docstrings - repo: https://github.com/asottile/pyupgrade - rev: v1.26.2 + rev: v2.0.0 hooks: - id: pyupgrade # Run bandit on "tests" tree with a configuration @@ -84,7 +84,7 @@ repos: rev: v4.2.0 hooks: - id: ansible-lint - # files: molecule/default/playbook.yml + # files: molecule/default/playbook.yml - repo: https://github.com/antonbabenko/pre-commit-terraform.git rev: v1.12.0 hooks: @@ -98,3 +98,7 @@ repos: rev: 1.19.1 hooks: - id: prettier + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.761 + hooks: + - id: mypy From b68db4ce5f1c19327c38a37ad3e6ccb6ce32eb97 Mon Sep 17 00:00:00 2001 From: Felddy Date: Thu, 20 Feb 2020 17:29:58 -0500 Subject: [PATCH 31/57] Sort .gitignore add mypy cache. --- .gitignore | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 724760e..bedb6e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ -*.egg-info __pycache__ -.python-version .coverage +.mypy_cache .pytest_cache +.python-version +*.egg-info From 3172a9924060b1bfb2b5c1d7edd0852154ba4a10 Mon Sep 17 00:00:00 2001 From: Felddy Date: Thu, 20 Feb 2020 17:35:43 -0500 Subject: [PATCH 32/57] Add PEP 484 type hints. See: https://www.python.org/dev/peps/pep-0484/ --- src/example/example.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/example/example.py b/src/example/example.py index b2856d9..556e8b5 100755 --- a/src/example/example.py +++ b/src/example/example.py @@ -25,6 +25,7 @@ import logging import os import sys +from typing import Any, Dict # Third-Party Libraries import docopt @@ -33,10 +34,10 @@ from ._version import __version__ -DEFAULT_ECHO_MESSAGE = "Hello World from the example default!" +DEFAULT_ECHO_MESSAGE: str = "Hello World from the example default!" -def example_div(dividend, divisor): +def example_div(dividend: float, divisor: float) -> float: """Print some logging messages.""" logging.debug("This is a debug message") logging.info("This is an info message") @@ -46,11 +47,11 @@ def example_div(dividend, divisor): return dividend / divisor -def main(): +def main() -> int: """Set up logging and call the example function.""" - args = docopt.docopt(__doc__, version=__version__) + args: Dict[str, str] = docopt.docopt(__doc__, version=__version__) # Validate and convert arguments as needed - schema = Schema( + schema: Schema = Schema( { "--log-level": And( str, @@ -70,16 +71,16 @@ def main(): ) try: - args = schema.validate(args) + validated_args: Dict[str, Any] = schema.validate(args) except SchemaError as err: # Exit because one or more of the arguments were invalid print(err, file=sys.stderr) return 1 # Assign validated arguments to variables - dividend = args[""] - divisor = args[""] - log_level = args["--log-level"] + dividend: int = validated_args[""] + divisor: int = validated_args[""] + log_level: str = validated_args["--log-level"] # Set up logging logging.basicConfig( @@ -89,11 +90,11 @@ def main(): logging.info(f"{dividend} / {divisor} == {example_div(dividend, divisor)}") # Access some data from an environment variable - message = os.getenv("ECHO_MESSAGE", DEFAULT_ECHO_MESSAGE) + message: str = os.getenv("ECHO_MESSAGE", DEFAULT_ECHO_MESSAGE) logging.info(f'ECHO_MESSAGE="{message}"') # Access some data from our package data (see the setup.py) - secret_message = ( + secret_message: str = ( pkg_resources.resource_string("example", "data/secret.txt") .decode("utf-8") .strip() From 067ee0850c154845b7de623988c5a1bd5ce67d3a Mon Sep 17 00:00:00 2001 From: Felddy Date: Thu, 20 Feb 2020 17:29:09 -0500 Subject: [PATCH 33/57] Autoupdate pre-commit hooks. Add mypy. --- .pre-commit-config.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7856658..46cea9e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -47,7 +47,7 @@ repos: additional_dependencies: - flake8-docstrings - repo: https://github.com/asottile/pyupgrade - rev: v1.26.2 + rev: v2.0.0 hooks: - id: pyupgrade - repo: https://github.com/PyCQA/bandit @@ -74,7 +74,7 @@ repos: rev: v4.2.0 hooks: - id: ansible-lint - # files: molecule/default/playbook.yml + # files: molecule/default/playbook.yml - repo: https://github.com/antonbabenko/pre-commit-terraform.git rev: v1.12.0 hooks: @@ -88,3 +88,7 @@ repos: rev: 1.19.1 hooks: - id: prettier + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.761 + hooks: + - id: mypy From bf366086f48d9b7a7e49b9f44f33b44f6a23aeb3 Mon Sep 17 00:00:00 2001 From: Jeremy Frasier Date: Mon, 2 Mar 2020 08:11:32 -0500 Subject: [PATCH 34/57] Add .mypy_cache to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 073a081..95b74cd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.mypy_cache __pycache__ .python-version From 454864bc029ce968cbeb8f9f5b88ad1c54522335 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Tue, 3 Mar 2020 16:49:53 -0500 Subject: [PATCH 35/57] Incorporate the Python version into keys for pip and pre-commit caches. This should resolve the issue seen when the Python version changes before there is an update to .pre-commit-config.yml which results in pre-commit pointing to a non-existent Python installation. --- .github/workflows/build.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aff7e7a..a92cd83 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,20 +14,25 @@ jobs: - uses: actions/setup-python@v1 with: python-version: 3.8 + - name: Store installed Python version + run: | + echo "::set-env name=PY_VERSION::"\ + "$(python -c "import platform;print(platform.python_version())")" - name: Cache pip test requirements uses: actions/cache@v1 with: path: ~/.cache/pip - key: "${{ runner.os }}-pip-test-\ + key: "${{ runner.os }}-pip-test-py${{ env.PY_VERSION }}-\ ${{ hashFiles('**/requirements-test.txt') }}" restore-keys: | + ${{ runner.os }}-pip-test-py${{ env.PY_VERSION }}- ${{ runner.os }}-pip-test- ${{ runner.os }}-pip- - name: Cache pre-commit hooks uses: actions/cache@v1 with: path: ~/.cache/pre-commit - key: "${{ runner.os }}-pre-commit-\ + key: "${{ runner.os }}-pre-commit-py${{ env.PY_VERSION }}-\ ${{ hashFiles('**/.pre-commit-config.yaml') }}" - name: Install dependencies run: | From 478f1688a108dd0f6e634c5f03c7ba6cb816e3f2 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Wed, 4 Mar 2020 08:41:59 -0500 Subject: [PATCH 36/57] Change the cache paths from hardcoded values in their appropriate blocks to environment variables declared before the job block. --- .github/workflows/build.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a92cd83..298e93c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,10 @@ on: [ pull_request ] +env: + PIP_CACHE_DIR: ~/.cache/pip + PRE_COMMIT_CACHE_DIR: ~/.cache/pre-commit + jobs: build: runs-on: ubuntu-latest @@ -21,7 +25,7 @@ jobs: - name: Cache pip test requirements uses: actions/cache@v1 with: - path: ~/.cache/pip + path: ${{ env.PIP_CACHE_DIR }} key: "${{ runner.os }}-pip-test-py${{ env.PY_VERSION }}-\ ${{ hashFiles('**/requirements-test.txt') }}" restore-keys: | @@ -31,7 +35,7 @@ jobs: - name: Cache pre-commit hooks uses: actions/cache@v1 with: - path: ~/.cache/pre-commit + path: ${{ env.PRE_COMMIT_CACHE_DIR }} key: "${{ runner.os }}-pre-commit-py${{ env.PY_VERSION }}-\ ${{ hashFiles('**/.pre-commit-config.yaml') }}" - name: Install dependencies From d7913343523e9841e1d295a5203e2043f055064b Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Wed, 4 Mar 2020 10:56:39 -0500 Subject: [PATCH 37/57] Add a rule for markdownlint to allow multiple headers with the same name as long as they are not nested in the same heading group. --- .mdl_config.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.mdl_config.json b/.mdl_config.json index 492955a..7a6f3f8 100644 --- a/.mdl_config.json +++ b/.mdl_config.json @@ -3,5 +3,8 @@ "code_blocks": false, "tables": false }, + "MD024": { + "allow_different_nesting": true + }, "default": true } From c6093a27ddd03d10138e8dadabba66243c7cb1a2 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Fri, 6 Mar 2020 09:58:31 -0500 Subject: [PATCH 38/57] Adjust handler logging setup variable names to appease the mypy hook. --- lambda_handler.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lambda_handler.py b/lambda_handler.py index 9cbaafe..7428cfa 100644 --- a/lambda_handler.py +++ b/lambda_handler.py @@ -25,10 +25,10 @@ # and # https://stackoverflow.com/questions/37703609/using-python-logging-with-aws-lambda # for more details. -root = logging.getLogger() -if root.handlers: - for handler in root.handlers: - root.removeHandler(handler) +logging_root = logging.getLogger() +if logging_root.handlers: + for logging_handler in logging_root.handlers: + logging_root.removeHandler(logging_handler) def handler(event, context): From 61790a9bbd22cede3cd41d94115d0e8ad8ba51d1 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Tue, 31 Mar 2020 14:41:10 -0400 Subject: [PATCH 39/57] Fixed broken hook id for pre-commit-terraform: terraform_validate_no_variables was changed to terraform_validate in the following commit: https://github.com/antonbabenko/pre-commit-terraform/commit/35e0356188b64a4c5af9a4e7200d936e514cba71. Ran pre-commit autoupdate. --- .pre-commit-config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 46cea9e..42b824f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,7 +33,7 @@ repos: args: - --config=.mdl_config.json - repo: https://github.com/adrienverge/yamllint - rev: v1.20.0 + rev: v1.21.0 hooks: - id: yamllint - repo: https://github.com/detailyang/pre-commit-shell @@ -47,7 +47,7 @@ repos: additional_dependencies: - flake8-docstrings - repo: https://github.com/asottile/pyupgrade - rev: v2.0.0 + rev: v2.1.0 hooks: - id: pyupgrade - repo: https://github.com/PyCQA/bandit @@ -61,7 +61,7 @@ repos: hooks: - id: black - repo: https://github.com/asottile/seed-isort-config - rev: v1.9.4 + rev: v2.1.0 hooks: - id: seed-isort-config - repo: https://github.com/pre-commit/mirrors-isort @@ -76,19 +76,19 @@ repos: - id: ansible-lint # files: molecule/default/playbook.yml - repo: https://github.com/antonbabenko/pre-commit-terraform.git - rev: v1.12.0 + rev: v1.27.0 hooks: - id: terraform_fmt - - id: terraform_validate_no_variables + - id: terraform_validate - repo: https://github.com/IamTheFij/docker-pre-commit rev: v1.0.1 hooks: - id: docker-compose-check - repo: https://github.com/prettier/prettier - rev: 1.19.1 + rev: 2.0.2 hooks: - id: prettier - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.761 + rev: v0.770 hooks: - id: mypy From 0bc1aab45e2338e658a63a9b92e9f9d14eafdec8 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Mon, 6 Apr 2020 12:05:57 -0400 Subject: [PATCH 40/57] Ran `pre-commit autoupdate` to get the latest version of the `pre-commit-terraform` hook since the PR I submitted, https://github.com/antonbabenko/pre-commit-terraform/pull/100, was approved. This will fix issues with `skeleton-tf-module` related to multiple directories with Terraform code. --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 42b824f..129aa39 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -76,7 +76,7 @@ repos: - id: ansible-lint # files: molecule/default/playbook.yml - repo: https://github.com/antonbabenko/pre-commit-terraform.git - rev: v1.27.0 + rev: v1.29.0 hooks: - id: terraform_fmt - id: terraform_validate @@ -85,7 +85,7 @@ repos: hooks: - id: docker-compose-check - repo: https://github.com/prettier/prettier - rev: 2.0.2 + rev: 2.0.4 hooks: - id: prettier - repo: https://github.com/pre-commit/mirrors-mypy From b01a0ee7bd1e0854b4c4c6bb999316c21221c97f Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Mon, 6 Apr 2020 13:47:18 -0400 Subject: [PATCH 41/57] Explicitly install pre-commit hooks as its own step so it's clearer when the failure is with setup rather than hooks running. --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 298e93c..6026d47 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,5 +42,7 @@ jobs: run: | python -m pip install --upgrade pip pip install --upgrade --requirement requirements-test.txt + - name: Install pre-commit hooks + run: pre-commit install-hooks - name: Run pre-commit on all files run: pre-commit run --all-files From 1f3d440a1af6283621b5584da9b56e2747d40a0b Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Mon, 6 Apr 2020 19:02:31 -0400 Subject: [PATCH 42/57] Rename action to accurately reflect that we are only linting, not building. Adjust description for pre-commit hook setup to better convey what is being done. --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6026d47..9c6b03a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ env: PRE_COMMIT_CACHE_DIR: ~/.cache/pre-commit jobs: - build: + lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -42,7 +42,7 @@ jobs: run: | python -m pip install --upgrade pip pip install --upgrade --requirement requirements-test.txt - - name: Install pre-commit hooks + - name: Set up pre-commit hook environments run: pre-commit install-hooks - name: Run pre-commit on all files run: pre-commit run --all-files From 647b351997ab7cafd391bdabda7b1b5e68214b8a Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Mon, 6 Apr 2020 19:04:21 -0400 Subject: [PATCH 43/57] Sort .gitignore entries. --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 95b74cd..e00826d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ .mypy_cache -__pycache__ .python-version +__pycache__ From a988a2d133de1f55ccc85e2496681346688dcef6 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Tue, 7 Apr 2020 13:54:01 -0400 Subject: [PATCH 44/57] Remove duplicate '.mypy_cache' entry in .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index ad2861f..fdbe25e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ *.egg-info .coverage .mypy_cache -.mypy_cache .pytest_cache .python-version __pycache__ From c8b4bcf126989abf35e4ce226263ef7da139c959 Mon Sep 17 00:00:00 2001 From: Hillary Date: Tue, 14 Apr 2020 12:43:18 -0400 Subject: [PATCH 45/57] Update CODEOWNERS --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 32918e8..a3619be 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -4,4 +4,4 @@ # the repo. Unless a later match takes precedence, # these owners will be requested for review when someone # opens a pull request. -* @dav3r @felddy @jsf9k @mcdonnnj @cisagov/team-ois +* @dav3r @felddy @hillaryj @jsf9k @mcdonnnj @cisagov/team-ois From 8c99c5294a798bca98a68212507fce924505a289 Mon Sep 17 00:00:00 2001 From: Felddy Date: Thu, 30 Apr 2020 23:31:59 -0400 Subject: [PATCH 46/57] Allow events from apb to rebuild this repository weekly. --- .github/workflows/build.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9c6b03a..5fe2f8b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,10 +1,11 @@ --- name: build -on: [ - push, - pull_request -] +on: + push: + pull_request: + repository_dispatch: + types: [apb] env: PIP_CACHE_DIR: ~/.cache/pip From 7d7a6774571c4727b4858b1117c31f97160131da Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Fri, 8 May 2020 17:49:17 -0400 Subject: [PATCH 47/57] Updated pre-commit configuration with 'pre-commit autoupdate'. --- .pre-commit-config.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 129aa39..de0152b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,13 +27,13 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.22.0 + rev: v0.23.0 hooks: - id: markdownlint args: - --config=.mdl_config.json - repo: https://github.com/adrienverge/yamllint - rev: v1.21.0 + rev: v1.23.0 hooks: - id: yamllint - repo: https://github.com/detailyang/pre-commit-shell @@ -41,13 +41,13 @@ repos: hooks: - id: shell-lint - repo: https://gitlab.com/pycqa/flake8 - rev: 3.7.9 + rev: 3.8.0a2 hooks: - id: flake8 additional_dependencies: - flake8-docstrings - repo: https://github.com/asottile/pyupgrade - rev: v2.1.0 + rev: v2.4.1 hooks: - id: pyupgrade - repo: https://github.com/PyCQA/bandit @@ -61,7 +61,7 @@ repos: hooks: - id: black - repo: https://github.com/asottile/seed-isort-config - rev: v2.1.0 + rev: v2.1.1 hooks: - id: seed-isort-config - repo: https://github.com/pre-commit/mirrors-isort @@ -71,12 +71,12 @@ repos: hooks: - id: isort - repo: https://github.com/ansible/ansible-lint.git - rev: v4.2.0 + rev: v4.3.0a0 hooks: - id: ansible-lint # files: molecule/default/playbook.yml - repo: https://github.com/antonbabenko/pre-commit-terraform.git - rev: v1.29.0 + rev: v1.30.0 hooks: - id: terraform_fmt - id: terraform_validate @@ -85,7 +85,7 @@ repos: hooks: - id: docker-compose-check - repo: https://github.com/prettier/prettier - rev: 2.0.4 + rev: 2.0.5 hooks: - id: prettier - repo: https://github.com/pre-commit/mirrors-mypy From b724c79e29f2d84e22438cd15803c5db08049472 Mon Sep 17 00:00:00 2001 From: Felddy Date: Mon, 11 May 2020 21:44:53 -0400 Subject: [PATCH 48/57] Add Lineage configuration. --- .github/lineage.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/lineage.yml diff --git a/.github/lineage.yml b/.github/lineage.yml new file mode 100644 index 0000000..8dfc20b --- /dev/null +++ b/.github/lineage.yml @@ -0,0 +1,6 @@ +--- +version: "1" + +lineage: + skeleton: + remote-url: https://github.com/cisagov/skeleton-generic.git From 0651d3c35b88093a6c2c5ba113f80a1e8f1030b6 Mon Sep 17 00:00:00 2001 From: Felddy Date: Mon, 11 May 2020 22:21:35 -0400 Subject: [PATCH 49/57] Add Lineage configuration. --- .github/lineage.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/lineage.yml diff --git a/.github/lineage.yml b/.github/lineage.yml new file mode 100644 index 0000000..569fc89 --- /dev/null +++ b/.github/lineage.yml @@ -0,0 +1,6 @@ +--- +version: "1" + +lineage: + skeleton: + remote-url: https://github.com/cisagov/skeleton-python-library.git From ce6658abc69d1444e51f45c20441c98e6b54c086 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Wed, 13 May 2020 15:25:31 -0400 Subject: [PATCH 50/57] Update isort pre-commit hook source repository. The mirrors-isort respository has been deprecated per this Pull Request: https://github.com/pre-commit/mirrors-isort/pull/13 Since isort includes pre-commit configuration in current versions we will switch to using it directly. --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index de0152b..5be35e4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -64,10 +64,10 @@ repos: rev: v2.1.1 hooks: - id: seed-isort-config - - repo: https://github.com/pre-commit/mirrors-isort + - repo: https://github.com/timothycrosley/isort # pick the isort version you'd like to use from # https://github.com/pre-commit/mirrors-isort/releases - rev: v4.3.21 + rev: 4.3.21 hooks: - id: isort - repo: https://github.com/ansible/ansible-lint.git From daaebc1cc13782e8fb39be6815aa53bf3efd44f3 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Wed, 13 May 2020 15:30:04 -0400 Subject: [PATCH 51/57] Ran pre-commit autoupdate. --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5be35e4..a2e4f76 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,7 +41,7 @@ repos: hooks: - id: shell-lint - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.0a2 + rev: 3.8.1 hooks: - id: flake8 additional_dependencies: From 2399f24622b1d6be92c494653d9308e9694c5496 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Wed, 13 May 2020 15:35:36 -0400 Subject: [PATCH 52/57] Remove legacy comment from the isort hook declaration. This comment references the mirrors-isort repository that we are no longer using. --- .pre-commit-config.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a2e4f76..bf8ae6e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -65,8 +65,6 @@ repos: hooks: - id: seed-isort-config - repo: https://github.com/timothycrosley/isort - # pick the isort version you'd like to use from - # https://github.com/pre-commit/mirrors-isort/releases rev: 4.3.21 hooks: - id: isort From fe4d5eb72a8f6ce9e23daae98d7a0c87675a9da4 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Wed, 13 May 2020 16:07:18 -0400 Subject: [PATCH 53/57] Disable the terraform_validate hook. We have seen a number of issues related to this hook ever since it was re-enabled. It will need to remain disabled until at least the 0.13 Terraform release, and can only be re-enabled if all issues we have seen have been resolved in how `terraform validate` operates. --- .pre-commit-config.yaml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bf8ae6e..74af27c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -77,7 +77,19 @@ repos: rev: v1.30.0 hooks: - id: terraform_fmt - - id: terraform_validate + # There are ongoing issues with how this command works. This issue + # documents the core issue: + # https://github.com/hashicorp/terraform/issues/21408 + # We have seen issues primarily with proxy providers and Terraform code + # that uses remote state. The PR + # https://github.com/hashicorp/terraform/pull/24887 + # has been approved and is part of the 0.13 release to resolve the issue + # with remote states. + # The PR + # https://github.com/hashicorp/terraform/pull/24896 + # is a proprosed fix to deal with `terraform validate` with proxy + # providers (among other configurations). + # - id: terraform_validate - repo: https://github.com/IamTheFij/docker-pre-commit rev: v1.0.1 hooks: From f831ef827cae16fd288f2e7a16fedc53c6e06873 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Wed, 13 May 2020 21:34:58 -0400 Subject: [PATCH 54/57] Add final statement to descriptionf or why terraform_validate is disabled. Review noticed that there lacked a determination for what we were doing about the problem with the terraform_validate hook. I described the problems but failed to mention what our path forward would be. This commit rectifies that oversight. --- .pre-commit-config.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 74af27c..b7c5518 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -89,6 +89,9 @@ repos: # https://github.com/hashicorp/terraform/pull/24896 # is a proprosed fix to deal with `terraform validate` with proxy # providers (among other configurations). + # We have decided to disable the terraform_validate hook until the issues + # above have been resolved, which we hope will be with the release of + # Terraform 0.13. # - id: terraform_validate - repo: https://github.com/IamTheFij/docker-pre-commit rev: v1.0.1 From 87ea53022c39f3adead2688fbae5698147b279d8 Mon Sep 17 00:00:00 2001 From: Jeremy Frasier Date: Tue, 9 Jun 2020 15:10:11 -0400 Subject: [PATCH 55/57] Add setuptools and wheel as pip dependencies setuptools usually comes along with pip, but wheel does not. Using wheel where possible to build python extensions is more modern and more security conscious than using setup.py. --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..0a8547b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +setuptools +wheel From 7f8d430a309b22a3410949e64ccd60ad5a1dc79f Mon Sep 17 00:00:00 2001 From: Jeremy Frasier Date: Tue, 9 Jun 2020 15:19:05 -0400 Subject: [PATCH 56/57] Pull in requirements.txt from requirements-test.txt --- requirements-test.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-test.txt b/requirements-test.txt index 416634f..66f74db 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1 +1,2 @@ +--requirement requirements.txt pre-commit From 370f2a2d8b7375c6e529565aa49a41d6499c028e Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Mon, 15 Jun 2020 17:35:25 -0400 Subject: [PATCH 57/57] Remove requirements that already exist in setup.py to align with a Single Source of Truth. --- requirements-test.txt | 1 - requirements.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/requirements-test.txt b/requirements-test.txt index 47e4ffd..0a6d7d6 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,3 +1,2 @@ --requirement requirements.txt -e .[test] -pre-commit diff --git a/requirements.txt b/requirements.txt index e9d0dcc..d08662f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ -e . -setuptools wheel