Skip to content
This repository was archived by the owner on Dec 1, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a842abb
Insist that the cisagov devs are the owners of the .github directory
jsf9k Nov 3, 2020
5b199bc
Remove offending slash
jsf9k Nov 3, 2020
02c5a6f
Use the python version output by actions/setup-python
jsf9k Nov 11, 2020
a9ee3dd
Make sure the requirements in setup.py are sorted
mcdonnnj Nov 13, 2020
64c3fb6
Organize pre-commit hooks
mcdonnnj Nov 16, 2020
ede0485
Change how the version number is extracted in setup.py
mcdonnnj Nov 16, 2020
40b3b80
Add comment explaining a Flake8 check disable
mcdonnnj Nov 16, 2020
57fc8a4
Resolve LGTM alert
mcdonnnj Nov 16, 2020
763d247
Merge pull request #60 from cisagov/organize_pre-commit_requirements
mcdonnnj Nov 18, 2020
1310cfd
Merge branch 'develop' into improvement/insist-that-devs-own-gihub-dir
jsf9k Nov 18, 2020
2a2067f
Merge pull request #57 from cisagov/improvement/insist-that-devs-own-…
jsf9k Nov 18, 2020
b638143
Merge branch 'develop' into improvement/get-python-version-more-simply
jsf9k Nov 18, 2020
3b312c4
Merge pull request #59 from cisagov/improvement/get-python-version-mo…
jsf9k Nov 18, 2020
dd6e0b8
Merge github.com:cisagov/skeleton-generic into lineage/skeleton
mcdonnnj Nov 18, 2020
a2e4fd3
Merge pull request #61 from cisagov/lineage/skeleton
mcdonnnj Nov 18, 2020
a8f761c
Merge branch 'develop' into sort_requirements
mcdonnnj Nov 18, 2020
a8bdbe5
Merge pull request #59 from cisagov/sort_requirements
mcdonnnj Nov 18, 2020
0747d20
Merge branch 'develop' into resolve_manual_check_disables
mcdonnnj Nov 18, 2020
b32bb9a
Merge pull request #60 from cisagov/resolve_manual_check_disables
mcdonnnj Nov 18, 2020
7ead7a4
Merge github.com:cisagov/skeleton-python-library into lineage/skeleton
mcdonnnj Nov 19, 2020
73d54a3
Fix missing replacements of old PY_VERSION usage
mcdonnnj Nov 19, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Each line is a file pattern followed by one or more owners.

# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# these owners will be requested for review when someone
# opens a pull request.
# These owners will be the default owners for everything in the
# repo. Unless a later match takes precedence, these owners will be
# requested for review when someone opens a pull request.
* @dav3r @felddy @hillaryj @jsf9k @mcdonnnj

# These folks own any files in the .github directory at the root of
# the repository and any of its subdirectories.
/.github/ @dav3r @felddy @hillaryj @jsf9k @mcdonnnj
43 changes: 23 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- id: setup-python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Store installed Python version
run: |
echo "PY_VERSION="\
"$(python -c "import platform;print(platform.python_version())")" \
>> $GITHUB_ENV
- name: Cache linting environments
uses: actions/cache@v2
with:
path: |
${{ env.PIP_CACHE_DIR }}
${{ env.PRE_COMMIT_CACHE_DIR }}
key: "lint-${{ runner.os }}-py${{ env.PY_VERSION }}-\
key: |
lint-${{ runner.os }}-\
py${{ steps.setup-python.outputs.python-version }}-\
${{ hashFiles('**/requirements-test.txt') }}-\
${{ hashFiles('**/requirements.txt') }}-\
${{ hashFiles('**/.pre-commit-config.yaml') }}"
restore-keys: |
lint-${{ runner.os }}-py${{ env.PY_VERSION }}-
lint-${{ runner.os }}-\
py${{ steps.setup-python.outputs.python-version }}-
lint-${{ runner.os }}-
- name: Install dependencies
run: |
Expand All @@ -59,11 +58,13 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.PIP_CACHE_DIR }}
key: "test-${{ runner.os }}-py${{ matrix.python-version }}-\
key: "test-${{ runner.os }}-\
py${{ matrix.python-version }}-\
${{ hashFiles('**/requirements-test.txt') }}-\
${{ hashFiles('**/requirements.txt') }}"
restore-keys: |
test-${{ runner.os }}-py${{ matrix.python-version }}-
test-${{ runner.os }}-\
py${{ matrix.python-version }}-
test-${{ runner.os }}-
- name: Install dependencies
run: |
Expand Down Expand Up @@ -93,10 +94,12 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.PIP_CACHE_DIR }}
key: "build-${{ runner.os }}-py${{ matrix.python-version }}-\
key: "build-${{ runner.os }}-\
py${{ matrix.python-version }}-\
${{ hashFiles('**/requirements.txt') }}"
restore-keys: |
build-${{ runner.os }}-py${{ matrix.python-version }}-
build-${{ runner.os }}-\
py${{ matrix.python-version }}-
build-${{ runner.os }}-
- name: Install dependencies
run: |
Expand All @@ -114,21 +117,20 @@ jobs:
needs: build
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- id: setup-python
uses: actions/setup-python@v2
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 lambda building environments
uses: actions/cache@v2
with:
path: ${{ env.PIP_CACHE_DIR }}
key: "build_lambda-${{ runner.os }}-py${{ env.PY_VERSION }}-\
key: "build_lambda-${{ runner.os }}-\
py${{ steps.setup-python.outputs.python-version }}-\
${{ hashFiles('**/requirements.txt') }}"
restore-keys: |
build_lambda-${{ runner.os }}-py${{ env.PY_VERSION }}-
build_lambda-${{ runner.os }}-\
py${{ steps.setup-python.outputs.python-version }}-
build_lambda-${{ runner.os }}-
- name: Install dependencies
run: |
Expand All @@ -150,5 +152,6 @@ jobs:
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: skeleton-aws-lambda-py${{ env.PY_VERSION }}
name: "skeleton-aws-lambda-\
py${{ steps.setup-python.outputs.python-version }}"
path: lambda_zip_contents/
13 changes: 6 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- id: setup-python
uses: actions/setup-python@v2
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 lambda building environments
uses: actions/cache@v2
with:
path: ${{ env.PIP_CACHE_DIR }}
key: "release-${{ runner.os }}-py${{ env.PY_VERSION }}-\
key: "release-${{ runner.os }}-\
py${{ steps.setup-python.outputs.python-version }}-\
${{ hashFiles('**/requirements.txt') }}"
restore-keys: |
release-${{ runner.os }}-py${{ env.PY_VERSION }}-
release-${{ runner.os }}-\
py${{ steps.setup-python.outputs.python-version }}-
release-${{ runner.os }}-
- name: Install dependencies
run: |
Expand Down
48 changes: 30 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,30 @@ repos:
- --autofix
- id: requirements-txt-fixer
- id: trailing-whitespace

# Text file hooks
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.24.0
hooks:
- id: markdownlint
args:
- --config=.mdl_config.json
- repo: https://github.com/prettier/pre-commit
rev: v2.1.2
hooks:
- id: prettier
- repo: https://github.com/adrienverge/yamllint
rev: v1.25.0
hooks:
- id: yamllint

# Shell script hooks
- repo: https://github.com/detailyang/pre-commit-shell
rev: 1.0.5
hooks:
- id: shell-lint
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
additional_dependencies:
- flake8-docstrings
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.2
hooks:
- id: pyupgrade

# Python hooks
# Run bandit on "tests" tree with a configuration
- repo: https://github.com/PyCQA/bandit
rev: 1.6.2
Expand All @@ -70,15 +70,33 @@ repos:
rev: 20.8b1
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
additional_dependencies:
- flake8-docstrings
- repo: https://github.com/timothycrosley/isort
rev: 5.6.4
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.790
hooks:
- id: mypy
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.2
hooks:
- id: pyupgrade

# Ansible hooks
- repo: https://github.com/ansible/ansible-lint.git
rev: v4.3.5
hooks:
- id: ansible-lint
# files: molecule/default/playbook.yml

# Terraform hooks
- repo: https://github.com/antonbabenko/pre-commit-terraform.git
rev: v1.43.0
hooks:
Expand All @@ -99,15 +117,9 @@ repos:
# above have been resolved, which we hope will be with the release of
# Terraform 0.13.
# - id: terraform_validate

# Docker hooks
- repo: https://github.com/IamTheFij/docker-pre-commit
rev: v2.0.0
hooks:
- id: docker-compose-check
- repo: https://github.com/prettier/pre-commit
rev: v2.1.2
hooks:
- id: prettier
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.790
hooks:
- id: mypy
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
version: '3.2'

services:
Expand Down
7 changes: 5 additions & 2 deletions eal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""This package contains the skeleton-aws-lambda code."""

__version__ = "1.0.0"
# We disable a Flake8 check for "Module imported but unused (F401)" here because
# although this import is not directly used, it populates the value
# package_name.__version__, which is used to get version information about this
# Python package.
from ._version import __version__ # noqa: F401
33 changes: 22 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"""

# Standard Python Libraries
import codecs
from glob import glob
from os.path import basename, splitext
from os.path import abspath, basename, dirname, join, splitext

# Third-Party Libraries
from setuptools import find_packages, setup
Expand All @@ -22,18 +23,28 @@ def readme():
return f.read()


def package_vars(version_file):
"""Read in and return the variables defined by the version_file."""
pkg_vars = {}
with open(version_file) as f:
exec(f.read(), pkg_vars) # nosec
return pkg_vars
# Below two methods were pulled from:
# https://packaging.python.org/guides/single-sourcing-package-version/
def read(rel_path):
"""Open a file for reading from a given relative path."""
here = abspath(dirname(__file__))
with codecs.open(join(here, rel_path), "r") as fp:
return fp.read()


def get_version(version_file):
"""Extract a version number from the given file path."""
for line in read(version_file).splitlines():
if line.startswith("__version__"):
delim = '"' if '"' in line else "'"
return line.split(delim)[1]
raise RuntimeError("Unable to find version string.")


setup(
name="example-aws-lambda",
# Versions should comply with PEP440
version=package_vars("eal/_version.py")["__version__"],
version=get_version("eal/_version.py"),
description="A skeleton with an example AWS lambda to build from.",
long_description=readme(),
long_description_content_type="text/markdown",
Expand Down Expand Up @@ -69,18 +80,18 @@ def package_vars(version_file):
keywords="skeleton",
packages=find_packages(where="."),
py_modules=[splitext(basename(path))[0] for path in glob("eal/*.py")],
install_requires=["docopt", "setuptools"],
install_requires=["docopt", "setuptools >= 24.2.0"],
extras_require={
"test": [
"pre-commit",
"coverage",
# coveralls 1.11.0 added a service number for calls from
# 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
# 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",
"pre-commit",
"pytest-cov",
"pytest",
]
Expand Down