Skip to content

Commit caba873

Browse files
committed
Merge github.com:cisagov/skeleton-python-library into skeletonize
2 parents 59f2bb0 + 2092099 commit caba873

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1211
-336
lines changed

.ansible-lint

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
# See https://ansible-lint.readthedocs.io/en/latest/configuring.html
3+
# for a list of the configuration elements that can exist in this
4+
# file.
5+
enable_list:
6+
# Useful checks that one must opt-into. See here for more details:
7+
# https://ansible-lint.readthedocs.io/en/latest/rules.html
8+
- fcqn-builtins
9+
- no-log-password
10+
- no-same-owner
11+
exclude_paths:
12+
# This exclusion is implicit, unless exclude_paths is defined
13+
- .cache
14+
# Seems wise to ignore this too
15+
- .github
16+
kinds:
17+
# This will force our systemd specific molecule configurations to be treated
18+
# as plain yaml files by ansible-lint. This mirrors the default kind
19+
# configuration in ansible-lint for molecule configurations:
20+
# yaml: "**/molecule/*/{base,molecule}.{yaml,yml}"
21+
- yaml: "**/molecule/*/molecule-{no,with}-systemd.yml"
22+
use_default_rules: true

.bandit.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
# Configuration file for the Bandit python security scanner
3+
# https://bandit.readthedocs.io/en/latest/config.html
4+
# This config is applied to bandit when scanning the "tests" tree
5+
6+
# Tests are first included by `tests`, and then excluded by `skips`.
7+
# If `tests` is empty, all tests are are considered included.
8+
9+
tests:
10+
# - B101
11+
# - B102
12+
13+
skips:
14+
- B101 # skip "assert used" check since assertions are required in pytests

.coveragerc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This is the configuration for code coverage checks
2+
# https://coverage.readthedocs.io/en/latest/config.html
3+
4+
[run]
5+
source = src/pshtt
6+
omit =
7+
branch = true
8+
9+
[report]
10+
exclude_lines =
11+
if __name__ == "__main__":
12+
show_missing = true

.dockerignore

Lines changed: 0 additions & 15 deletions
This file was deleted.

.flake8

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[flake8]
2+
max-line-length = 80
3+
# Select (turn on)
4+
# * Complexity violations reported by mccabe (C) -
5+
# http://flake8.pycqa.org/en/latest/user/error-codes.html#error-violation-codes
6+
# * Documentation conventions compliance reported by pydocstyle (D) -
7+
# http://www.pydocstyle.org/en/stable/error_codes.html
8+
# * Default errors and warnings reported by pycodestyle (E and W) -
9+
# https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
10+
# * Default errors reported by pyflakes (F) -
11+
# http://flake8.pycqa.org/en/latest/glossary.html#term-pyflakes
12+
# * Default warnings reported by flake8-bugbear (B) -
13+
# https://github.com/PyCQA/flake8-bugbear#list-of-warnings
14+
# * The B950 flake8-bugbear opinionated warning -
15+
# https://github.com/PyCQA/flake8-bugbear#opinionated-warnings
16+
select = C,D,E,F,W,B,B950
17+
# Ignore flake8's default warning about maximum line length, which has
18+
# a hard stop at the configured value. Instead we use
19+
# flake8-bugbear's B950, which allows up to 10% overage.
20+
#
21+
# Also ignore flake8's warning about line breaks before binary
22+
# operators. It no longer agrees with PEP8. See, for example, here:
23+
# https://github.com/ambv/black/issues/21. Guido agrees here:
24+
# https://github.com/python/peps/commit/c59c4376ad233a62ca4b3a6060c81368bd21e85b.
25+
ignore = E501,W503

.github/CODEOWNERS

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Each line is a file pattern followed by one or more owners.
2+
3+
# These owners will be the default owners for everything in the
4+
# repo. Unless a later match takes precedence, these owners will be
5+
# requested for review when someone opens a pull request.
6+
* @dav3r @felddy @jsf9k @mcdonnnj
7+
8+
# These folks own any files in the .github directory at the root of
9+
# the repository and any of its subdirectories.
10+
/.github/ @dav3r @felddy @jsf9k @mcdonnnj

.github/dependabot.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
3+
# Any ignore directives should be uncommented in downstream projects to disable
4+
# Dependabot updates for the given dependency. Downstream projects will get
5+
# these updates when the pull request(s) in the appropriate skeleton are merged
6+
# and Lineage processes these changes.
7+
8+
version: 2
9+
updates:
10+
- package-ecosystem: "github-actions"
11+
directory: "/"
12+
schedule:
13+
interval: "weekly"
14+
15+
- package-ecosystem: "pip"
16+
directory: "/"
17+
schedule:
18+
interval: "weekly"
19+
20+
- package-ecosystem: "terraform"
21+
directory: "/"
22+
schedule:
23+
interval: "weekly"

.github/lineage.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
lineage:
3+
skeleton:
4+
remote-url: https://github.com/cisagov/skeleton-python-library.git
5+
version: '1'

.github/workflows/build.yml

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
---
2+
name: build
3+
4+
on:
5+
push:
6+
pull_request:
7+
repository_dispatch:
8+
types: [apb]
9+
10+
env:
11+
CURL_CACHE_DIR: ~/.cache/curl
12+
PIP_CACHE_DIR: ~/.cache/pip
13+
PRE_COMMIT_CACHE_DIR: ~/.cache/pre-commit
14+
RUN_TMATE: ${{ secrets.RUN_TMATE }}
15+
16+
jobs:
17+
lint:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- id: setup-env
21+
uses: cisagov/setup-env-github-action@develop
22+
- uses: actions/checkout@v2
23+
- id: setup-python
24+
uses: actions/setup-python@v2
25+
with:
26+
python-version: 3.9
27+
# We need the Go version and Go cache location for the actions/cache step,
28+
# so the Go installation must happen before that.
29+
- uses: actions/setup-go@v2
30+
with:
31+
go-version: '1.16'
32+
- name: Store installed Go version
33+
id: go-version
34+
run: |
35+
echo "::set-output name=version::"\
36+
"$(go version | sed 's/^go version go\([0-9.]\+\) .*/\1/')"
37+
- name: Lookup Go cache directory
38+
id: go-cache
39+
run: |
40+
echo "::set-output name=dir::$(go env GOCACHE)"
41+
- uses: actions/cache@v2
42+
env:
43+
BASE_CACHE_KEY: "${{ github.job }}-${{ runner.os }}-\
44+
py${{ steps.setup-python.outputs.python-version }}-\
45+
go${{ steps.go-version.outputs.version }}-\
46+
packer${{ steps.setup-env.outputs.packer-version }}-\
47+
tf${{ steps.setup-env.outputs.terraform-version }}-"
48+
with:
49+
# Note that the .terraform directory IS NOT included in the
50+
# cache because if we were caching, then we would need to use
51+
# the `-upgrade=true` option. This option blindly pulls down the
52+
# latest modules and providers instead of checking to see if an
53+
# update is required. That behavior defeats the benefits of caching.
54+
# so there is no point in doing it for the .terraform directory.
55+
path: |
56+
${{ env.PIP_CACHE_DIR }}
57+
${{ env.PRE_COMMIT_CACHE_DIR }}
58+
${{ env.CURL_CACHE_DIR }}
59+
${{ steps.go-cache.outputs.dir }}
60+
# We do not use '**/setup.py' in the cache key so only the 'setup.py'
61+
# file in the root of the repository is used. This is in case a Python
62+
# package were to have a 'setup.py' as part of its internal codebase.
63+
key: "${{ env.BASE_CACHE_KEY }}\
64+
${{ hashFiles('**/requirements-test.txt') }}-\
65+
${{ hashFiles('**/requirements.txt') }}-\
66+
${{ hashFiles('**/.pre-commit-config.yaml') }}-\
67+
${{ hashFiles('setup.py') }}"
68+
restore-keys: |
69+
${{ env.BASE_CACHE_KEY }}
70+
- name: Setup curl cache
71+
run: mkdir -p ${{ env.CURL_CACHE_DIR }}
72+
- name: Install Packer
73+
env:
74+
PACKER_VERSION: ${{ steps.setup-env.outputs.packer-version }}
75+
run: |
76+
PACKER_ZIP="packer_${PACKER_VERSION}_linux_amd64.zip"
77+
curl --output ${{ env.CURL_CACHE_DIR }}/"${PACKER_ZIP}" \
78+
--time-cond ${{ env.CURL_CACHE_DIR }}/"${PACKER_ZIP}" \
79+
--location \
80+
"https://releases.hashicorp.com/packer/${PACKER_VERSION}/${PACKER_ZIP}"
81+
sudo unzip -d /opt/packer \
82+
${{ env.CURL_CACHE_DIR }}/"${PACKER_ZIP}"
83+
sudo mv /usr/local/bin/packer /usr/local/bin/packer-default
84+
sudo ln -s /opt/packer/packer /usr/local/bin/packer
85+
- uses: hashicorp/setup-terraform@v1
86+
with:
87+
terraform_version: ${{ steps.setup-env.outputs.terraform-version }}
88+
- name: Install shfmt
89+
env:
90+
PACKAGE_URL: mvdan.cc/sh/v3/cmd/shfmt
91+
PACKAGE_VERSION: ${{ steps.setup-env.outputs.shfmt-version }}
92+
run: go install ${PACKAGE_URL}@${PACKAGE_VERSION}
93+
- name: Install Terraform-docs
94+
env:
95+
PACKAGE_URL: github.com/terraform-docs/terraform-docs
96+
PACKAGE_VERSION: ${{ steps.setup-env.outputs.terraform-docs-version }}
97+
run: go install ${PACKAGE_URL}@${PACKAGE_VERSION}
98+
- name: Install dependencies
99+
run: |
100+
python -m pip install --upgrade pip
101+
pip install --upgrade --requirement requirements-test.txt
102+
- name: Set up pre-commit hook environments
103+
run: pre-commit install-hooks
104+
- name: Run pre-commit on all files
105+
run: pre-commit run --all-files
106+
- name: Setup tmate debug session
107+
uses: mxschmitt/action-tmate@v3
108+
if: env.RUN_TMATE
109+
test:
110+
runs-on: ubuntu-latest
111+
strategy:
112+
fail-fast: false
113+
matrix:
114+
python-version:
115+
- "3.6"
116+
- "3.7"
117+
- "3.8"
118+
- "3.9"
119+
- "3.10"
120+
steps:
121+
- uses: actions/checkout@v2
122+
- id: setup-python
123+
uses: actions/setup-python@v2
124+
with:
125+
python-version: ${{ matrix.python-version }}
126+
- uses: actions/cache@v2
127+
env:
128+
BASE_CACHE_KEY: "${{ github.job }}-${{ runner.os }}-\
129+
py${{ steps.setup-python.outputs.python-version }}-"
130+
with:
131+
path: ${{ env.PIP_CACHE_DIR }}
132+
# We do not use '**/setup.py' in the cache key so only the 'setup.py'
133+
# file in the root of the repository is used. This is in case a Python
134+
# package were to have a 'setup.py' as part of its internal codebase.
135+
key: "${{ env.BASE_CACHE_KEY }}\
136+
${{ hashFiles('**/requirements-test.txt') }}-\
137+
${{ hashFiles('**/requirements.txt') }}-\
138+
${{ hashFiles('setup.py') }}"
139+
restore-keys: |
140+
${{ env.BASE_CACHE_KEY }}
141+
- name: Install dependencies
142+
run: |
143+
python -m pip install --upgrade pip
144+
pip install --upgrade --requirement requirements-test.txt
145+
- name: Run tests
146+
env:
147+
RELEASE_TAG: ${{ github.event.release.tag_name }}
148+
run: pytest
149+
- name: Upload coverage report
150+
run: coveralls
151+
env:
152+
COVERALLS_FLAG_NAME: "py${{ matrix.python-version }}"
153+
COVERALLS_PARALLEL: true
154+
COVERALLS_SERVICE_NAME: github
155+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
156+
if: success()
157+
- name: Setup tmate debug session
158+
uses: mxschmitt/action-tmate@v3
159+
if: env.RUN_TMATE
160+
coveralls-finish:
161+
runs-on: ubuntu-latest
162+
needs: test
163+
steps:
164+
- uses: actions/checkout@v2
165+
- id: setup-python
166+
uses: actions/setup-python@v2
167+
with:
168+
python-version: 3.9
169+
- uses: actions/cache@v2
170+
env:
171+
BASE_CACHE_KEY: "${{ github.job }}-${{ runner.os }}-\
172+
py${{ steps.setup-python.outputs.python-version }}-"
173+
with:
174+
path: ${{ env.PIP_CACHE_DIR }}
175+
# We do not use '**/setup.py' in the cache key so only the 'setup.py'
176+
# file in the root of the repository is used. This is in case a Python
177+
# package were to have a 'setup.py' as part of its internal codebase.
178+
key: "${{ env.BASE_CACHE_KEY }}\
179+
${{ hashFiles('**/requirements-test.txt') }}-\
180+
${{ hashFiles('**/requirements.txt') }}-\
181+
${{ hashFiles('setup.py') }}"
182+
restore-keys: |
183+
${{ env.BASE_CACHE_KEY }}
184+
- name: Install dependencies
185+
run: |
186+
python -m pip install --upgrade pip
187+
pip install --upgrade --requirement requirements-test.txt
188+
- name: Finished coveralls reports
189+
run: coveralls --finish
190+
env:
191+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
192+
- name: Setup tmate debug session
193+
uses: mxschmitt/action-tmate@v3
194+
if: env.RUN_TMATE
195+
build:
196+
runs-on: ubuntu-latest
197+
needs: [lint, test]
198+
strategy:
199+
fail-fast: false
200+
matrix:
201+
python-version:
202+
- "3.6"
203+
- "3.7"
204+
- "3.8"
205+
- "3.9"
206+
- "3.10"
207+
steps:
208+
- uses: actions/checkout@v2
209+
- id: setup-python
210+
uses: actions/setup-python@v2
211+
with:
212+
python-version: ${{ matrix.python-version }}
213+
- uses: actions/cache@v2
214+
env:
215+
BASE_CACHE_KEY: "${{ github.job }}-${{ runner.os }}-\
216+
py${{ steps.setup-python.outputs.python-version }}-"
217+
with:
218+
path: ${{ env.PIP_CACHE_DIR }}
219+
# We do not use '**/setup.py' in the cache key so only the 'setup.py'
220+
# file in the root of the repository is used. This is in case a Python
221+
# package were to have a 'setup.py' as part of its internal codebase.
222+
key: "${{ env.BASE_CACHE_KEY }}\
223+
${{ hashFiles('**/requirements.txt') }}-\
224+
${{ hashFiles('setup.py') }}"
225+
restore-keys: |
226+
${{ env.BASE_CACHE_KEY }}
227+
- name: Install dependencies
228+
run: |
229+
python -m pip install --upgrade pip wheel
230+
pip install --upgrade --requirement requirements.txt
231+
- name: Build artifacts
232+
run: python3 setup.py sdist bdist_wheel
233+
- name: Upload artifacts
234+
uses: actions/upload-artifact@v2
235+
with:
236+
name: dist-${{ matrix.python-version }}
237+
path: dist
238+
- name: Setup tmate debug session
239+
uses: mxschmitt/action-tmate@v3
240+
if: env.RUN_TMATE

0 commit comments

Comments
 (0)