From ecdfc527d4338218f005684439214c2d126aa11b Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Fri, 15 Jan 2021 10:34:34 -0500 Subject: [PATCH 01/11] Add the beautysh pre-commit hook This hook performs auto-formatting (beautifying) of Bash scripts. --- .pre-commit-config.yaml | 7 +++++++ setup-env | 14 +++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8a3c7eb..42a2c7a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,6 +48,13 @@ repos: - --strict # Shell script hooks + - repo: https://github.com/lovesegfault/beautysh + rev: 6.0.1 + hooks: + - id: beautysh + args: + - --indent-size + - '2' - repo: https://github.com/detailyang/pre-commit-shell rev: 1.0.5 hooks: diff --git a/setup-env b/setup-env index 4d822c4..1579e04 100755 --- a/setup-env +++ b/setup-env @@ -50,14 +50,14 @@ while (( "$#" )); do shift ;; -*) # unsupported flags - echo "Error: Unsupported flag $1" >&2 - exit 1 - ;; + echo "Error: Unsupported flag $1" >&2 + exit 1 + ;; *) # preserve positional arguments - PARAMS="$PARAMS $1" - shift - ;; - esac + PARAMS="$PARAMS $1" + shift + ;; + esac done # set positional arguments in their proper place From 12033ed60cff74437014a4f1cf9cde9d2b4a13ef Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Fri, 5 Feb 2021 13:19:51 -0500 Subject: [PATCH 02/11] Add the mypy package to dev rquirements --- requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index cb51627..1d7e302 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,4 @@ --requirement requirements-test.txt ipython +mypy semver From 6bd93ff6fbd1e9fe1a6e508d6a65225b63220a53 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Sun, 31 Jan 2021 19:24:54 -0500 Subject: [PATCH 03/11] Update pre-commit hooks with `pre-commit autoupdate` --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8a3c7eb..e1da8e2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,7 +41,7 @@ repos: hooks: - id: prettier - repo: https://github.com/adrienverge/yamllint - rev: v1.25.0 + rev: v1.26.0 hooks: - id: yamllint args: @@ -75,17 +75,17 @@ repos: hooks: - id: isort - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.790 + rev: v0.800 hooks: - id: mypy - repo: https://github.com/asottile/pyupgrade - rev: v2.7.4 + rev: v2.10.0 hooks: - id: pyupgrade # Ansible hooks - repo: https://github.com/ansible-community/ansible-lint - rev: v4.3.7 + rev: v5.0.0 hooks: - id: ansible-lint # files: molecule/default/playbook.yml From b54a0fc817545941b6cb0707fe127e79f5c06f26 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Thu, 11 Feb 2021 18:27:08 -0500 Subject: [PATCH 04/11] Update the URL used for our Python packages us-cert.gov now forwards to us-cert.cisa.gov, and since NCATS is a pre-CISA designation it makes sense to update this URL. The URL points to a specific set of services offered that does not encompass everything that is hosted in the cisagov org on GitHub. We have chosen the page describing CISA's cybersecurity mission as the best replacement URL. --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index a458722..56b9b95 100644 --- a/setup.py +++ b/setup.py @@ -48,8 +48,8 @@ def get_version(version_file): description="Example python library", long_description=readme(), long_description_content_type="text/markdown", - # NCATS "homepage" - url="https://www.us-cert.gov/resources/ncats", + # Landing page for CISA's cybersecurity mission + url="https://www.cisa.gov/cybersecurity", # The project's main homepage download_url="https://github.com/cisagov/skeleton-python-library", # Author details From 7409f9d3536e81a872cb67c02749c2da0864032c Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Thu, 11 Feb 2021 18:32:18 -0500 Subject: [PATCH 05/11] Update the author_email field in package metadata We no longer have access to the old email address. Additionally the agency has gotten it's own email domain, so we prefer cisa.dhs.gov addresses at this point. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 56b9b95..4a62591 100644 --- a/setup.py +++ b/setup.py @@ -54,7 +54,7 @@ def get_version(version_file): download_url="https://github.com/cisagov/skeleton-python-library", # Author details author="Cyber and Infrastructure Security Agency", - author_email="ncats@hq.dhs.gov", + author_email="github@cisa.dhs.gov", license="License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", # See https://pypi.python.org/pypi?%3Aaction=list_classifiers classifiers=[ From 19e1fb997c3fae8eee180c8c99a0229d05cb3e6f Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Thu, 11 Feb 2021 18:36:57 -0500 Subject: [PATCH 06/11] Remove download_url field and add project_urls field to package metadata The download_urls field was being used incorrectly, as it is supposed to provide a download URL to a file usable to install the package. This would typically be a tarball of some kind. Additionaly this field is discouraged per https://github.com/pypa/packaging.python.org/issues/293, so we should stop using it in our package metadata. The best replacement I found is the project_urls field, which allows us to provide a number of purpose specific URLs about the package. --- setup.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 4a62591..bdee06b 100644 --- a/setup.py +++ b/setup.py @@ -50,8 +50,12 @@ def get_version(version_file): long_description_content_type="text/markdown", # Landing page for CISA's cybersecurity mission url="https://www.cisa.gov/cybersecurity", - # The project's main homepage - download_url="https://github.com/cisagov/skeleton-python-library", + # Additional URLs for this project per + # https://packaging.python.org/guides/distributing-packages-using-setuptools/#project-urls + project_urls={ + "Source": "https://github.com/cisagov/skeleton-python-library", + "Tracker": "https://github.com/cisagov/skeleton-python-library/issues", + }, # Author details author="Cyber and Infrastructure Security Agency", author_email="github@cisa.dhs.gov", From 7f968776c38b1e8bb8d41aafb71c0445d982482c Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Thu, 11 Feb 2021 18:51:08 -0500 Subject: [PATCH 07/11] Fix capitalization of Python in description metadata --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index bdee06b..45ed1a0 100644 --- a/setup.py +++ b/setup.py @@ -45,7 +45,7 @@ def get_version(version_file): name="example", # Versions should comply with PEP440 version=get_version("src/example/_version.py"), - description="Example python library", + description="Example Python library", long_description=readme(), long_description_content_type="text/markdown", # Landing page for CISA's cybersecurity mission From de06bbc81fac2012ef040f61f4ccede70f27e239 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Thu, 11 Feb 2021 18:52:56 -0500 Subject: [PATCH 08/11] Fix agency name in author metadata --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 45ed1a0..14bd3fd 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,7 @@ def get_version(version_file): "Tracker": "https://github.com/cisagov/skeleton-python-library/issues", }, # Author details - author="Cyber and Infrastructure Security Agency", + author="Cybersecurity and Infrastructure Security Agency", author_email="github@cisa.dhs.gov", license="License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", # See https://pypi.python.org/pypi?%3Aaction=list_classifiers From c97a883ada7ae0cbd50f790d4deb4e79639736dd Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Tue, 16 Feb 2021 13:18:08 -0500 Subject: [PATCH 09/11] Revert ansible-lint version update The v5 release of ansible-lint introduces breaking changes, so we are holding off on updating until things are resolved. Conversation about this can be tracked in https://github.com/cisagov/skeleton-ansible-role/issues/69. --- .pre-commit-config.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e1da8e2..4fdfdff 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -85,7 +85,9 @@ repos: # Ansible hooks - repo: https://github.com/ansible-community/ansible-lint - rev: v5.0.0 + # This is intentionally being held back because of issues in v5 per + # https://github.com/cisagov/skeleton-ansible-role/issues/69 + rev: v4.3.7 hooks: - id: ansible-lint # files: molecule/default/playbook.yml From 4d8089ed42875c300c29dab9d4ad134ed46d0f2c Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Tue, 16 Feb 2021 17:49:46 -0500 Subject: [PATCH 10/11] Autoformat bump_version.sh with beautysh --- bump_version.sh | 66 ++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/bump_version.sh b/bump_version.sh index 861eed0..c0bf25c 100755 --- a/bump_version.sh +++ b/bump_version.sh @@ -14,38 +14,38 @@ old_version=$(sed -n "s/^__version__ = \"\(.*\)\"$/\1/p" $VERSION_FILE) if [ $# -ne 1 ] then - echo "$HELP_INFORMATION" + 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" - # A temp file is used to provide compatability with macOS development - # as a result of macOS using the BSD version of sed - 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" - # A temp file is used to provide compatability with macOS development - # as a result of macOS using the BSD version of sed - 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 - ;; - show) - echo "$old_version" - ;; - *) - echo "$HELP_INFORMATION" - ;; - esac + 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" + # A temp file is used to provide compatability with macOS development + # as a result of macOS using the BSD version of sed + 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" + # A temp file is used to provide compatability with macOS development + # as a result of macOS using the BSD version of sed + 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 + ;; + show) + echo "$old_version" + ;; + *) + echo "$HELP_INFORMATION" + ;; + esac fi From cc0b3365fec4c6db00e94d0b7da14819923ffa7b Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Fri, 26 Feb 2021 11:47:26 -0500 Subject: [PATCH 11/11] Autoformat build.sh with beautysh --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 0f2341a..50feda1 100755 --- a/build.sh +++ b/build.sh @@ -90,12 +90,12 @@ cp lambda_handler.py "$BUILD_DIR" OUTPUT_DIR="/output" if [ ! -d "$OUTPUT_DIR" ] then - mkdir "$OUTPUT_DIR" + mkdir "$OUTPUT_DIR" fi if [ -e "$OUTPUT_DIR/$ZIP_FILE" ] then - rm "$OUTPUT_DIR/$ZIP_FILE" + rm "$OUTPUT_DIR/$ZIP_FILE" fi cd $BUILD_DIR