Skip to content

Commit

Permalink
Merge 24c9ae9 into 242f671
Browse files Browse the repository at this point in the history
  • Loading branch information
dav3r committed Jul 17, 2020
2 parents 242f671 + 24c9ae9 commit 12f58a5
Show file tree
Hide file tree
Showing 14 changed files with 322 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .bandit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -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 @jsf9k
6 changes: 6 additions & 0 deletions .github/lineage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
version: "1"

lineage:
skeleton:
remote-url: https://github.com/cisagov/skeleton-python-library.git
52 changes: 34 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
name: build

on: [
push,
pull_request
]
on:
push:
pull_request:
repository_dispatch:
types: [apb]

env:
PIP_CACHE_DIR: ~/.cache/pip
Expand All @@ -14,51 +15,62 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- 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: ${{ env.PIP_CACHE_DIR }}
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: ${{ env.PRE_COMMIT_CACHE_DIR }}
key: "${{ runner.os }}-pre-commit-\
key: "${{ runner.os }}-pre-commit-py${{ env.PY_VERSION }}-\
${{ hashFiles('**/.pre-commit-config.yaml') }}"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade -r requirements-test.txt
- name: Run linters on all files
pip install --upgrade --requirement requirements-test.txt
- 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
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: ${{ matrix.python-version }}
- name: Cache pip test requirements
uses: actions/cache@v1
with:
path: ${{ env.PIP_CACHE_DIR }}
key: "${{ runner.os }}-pip-test-\
key: "${{ runner.os }}-pip-test-py${{ matrix.python-version }}-\
${{ hashFiles('**/requirements-test.txt') }}"
restore-keys: |
${{ runner.os }}-pip-test-py${{ matrix.python-version }}-
${{ runner.os }}-pip-test-
${{ runner.os }}-pip-
- 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 tests
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
Expand All @@ -71,28 +83,32 @@ jobs:
build:
runs-on: ubuntu-latest
needs: [lint, test]
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: ${{ matrix.python-version }}
- name: Cache pip build requirements
uses: actions/cache@v1
with:
path: ${{ env.PIP_CACHE_DIR }}
key: "${{ runner.os }}-pip-build-\
key: "${{ runner.os }}-pip-build-py${{ matrix.python-version }}-\
${{ hashFiles('**/requirements.txt') }}"
restore-keys: |
${{ runner.os }}-pip-build-py${{ matrix.python-version }}-
${{ runner.os }}-pip-build-
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
pip install --upgrade -r requirements.txt
pip install --upgrade --requirement requirements.txt
- name: Build artifacts
run: python3 setup.py sdist bdist_wheel
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: dist
name: dist-${{ matrix.python-version }}
path: dist
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
*.egg-info
__pycache__
.python-version
.coverage
.mypy_cache
.pytest_cache
tests/credentials-test.backup
.python-version
__pycache__
3 changes: 3 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ import_heading_firstparty=cisagov Libraries
known_third_party=docopt,more_itertools,pytest,schema,setuptools
# These must be manually set to correctly separate them from third party libraries
known_first_party=aws_profile_sync

# Run isort under the black profile to align with our other Python linting
profile=black
3 changes: 3 additions & 0 deletions .mdl_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"code_blocks": false,
"tables": false
},
"MD024": {
"allow_different_nesting": true
},
"default": true
}
49 changes: 33 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ default_language_version:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
rev: v3.1.0
hooks:
- id: check-executables-have-shebangs
- id: check-json
Expand All @@ -27,27 +27,27 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.22.0
rev: v0.23.2
hooks:
- id: markdownlint
args:
- --config=.mdl_config.json
- repo: https://github.com/adrienverge/yamllint
rev: v1.20.0
rev: v1.23.0
hooks:
- id: yamllint
- repo: https://github.com/detailyang/pre-commit-shell
rev: 1.0.5
hooks:
- id: shell-lint
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
rev: 3.8.3
hooks:
- id: flake8
additional_dependencies:
- flake8-docstrings
- repo: https://github.com/asottile/pyupgrade
rev: v1.26.2
rev: v2.7.0
hooks:
- id: pyupgrade
# Run bandit on "tests" tree with a configuration
Expand All @@ -71,30 +71,47 @@ repos:
hooks:
- id: black
- repo: https://github.com/asottile/seed-isort-config
rev: v1.9.4
rev: v2.2.0
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
# pick the isort version you'd like to use from
# https://github.com/pre-commit/mirrors-isort/releases
rev: v4.3.21
- repo: https://github.com/timothycrosley/isort
rev: 5.0.7
hooks:
- id: isort
- repo: https://github.com/ansible/ansible-lint.git
rev: v4.2.0
rev: v4.3.0a3
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
rev: v1.31.0
hooks:
- id: terraform_fmt
- id: terraform_validate_no_variables
# 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).
# 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
rev: v2.0.0
hooks:
- id: docker-compose-check
- repo: https://github.com/prettier/prettier
rev: 1.19.1
rev: 2.0.5
hooks:
- id: prettier
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.782
hooks:
- id: mypy
45 changes: 39 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,53 @@ There are a few ways to do this, but we prefer to use
create and manage a Python virtual environment specific to this
project.

If you already have `pyenv` and `pyenv-virtualenv` configured you can
take advantage of the `setup-env` tool in this repo to automate the
entire environment configuration process.

```console
./setup-env
```

Otherwise, follow the steps below to manually configure your
environment.

#### Installing and using `pyenv` and `pyenv-virtualenv` ####

On the Mac, installation is as simple as `brew install pyenv
pyenv-virtualenv` and adding this to your profile:
On the Mac, we recommend installing [brew](https://brew.sh/). Then
installation is as simple as `brew install pyenv pyenv-virtualenv` and
adding this to your profile:

```bash
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
Expand All @@ -81,7 +114,7 @@ commands:
cd aws-profile-sync
pyenv virtualenv <python_version_to_use> aws-profile-sync
pyenv local aws-profile-sync
pip install -r requirements-dev.txt
pip install --requirement requirements-dev.txt
```

#### Installing the pre-commit hook ####
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-r requirements-test.txt
--requirement requirements-test.txt
ipython
semver
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--requirement requirements.txt
-e .[test]
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
-e .
wheel

0 comments on commit 12f58a5

Please sign in to comment.