Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:cisagov/skeleton-docker into dev…
Browse files Browse the repository at this point in the history
…elop
  • Loading branch information
felddy committed May 15, 2020
1 parent 59fb0d4 commit d08c090
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .bandit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,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
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-generic.git
29 changes: 20 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
---
name: build

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

env:
IMAGE_NAME: felddy/weewx
Expand All @@ -12,35 +16,42 @@ 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
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Determine image version
id: get_ver
run: |
Expand Down Expand Up @@ -77,7 +88,7 @@ jobs:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.8
Expand All @@ -93,7 +104,7 @@ 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: Download docker image artifact
uses: actions/download-artifact@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.8
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
__pycache__
.python-version
.mypy_cache
.pytest_cache
.python-version
__pycache__
data/*
12 changes: 12 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[settings]
combine_star=true
force_sort_within_sections=true

import_heading_stdlib=Standard Python Libraries
import_heading_thirdparty=Third-Party Libraries
import_heading_firstparty=Local Libraries

# Should be auto-populated by seed-isort-config hook
known_third_party=pytest
# These must be manually set to correctly separate them from third party libraries
known_first_party=
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
}
47 changes: 37 additions & 10 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.4.0
rev: v2.5.0
hooks:
- id: check-executables-have-shebangs
- id: check-json
Expand All @@ -28,27 +28,27 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.19.0
rev: v0.23.0
hooks:
- id: markdownlint
args:
- --config=.mdl_config.json
- repo: https://github.com/adrienverge/yamllint
rev: v1.18.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.1
hooks:
- id: flake8
additional_dependencies:
- flake8-docstrings
- repo: https://github.com/asottile/pyupgrade
rev: v1.25.1
rev: v2.4.1
hooks:
- id: pyupgrade
# Run bandit on "tests" tree with a configuration
Expand All @@ -71,20 +71,47 @@ repos:
rev: 19.10b0
hooks:
- id: black
- repo: https://github.com/asottile/seed-isort-config
rev: v2.1.1
hooks:
- id: seed-isort-config
- repo: https://github.com/timothycrosley/isort
rev: 4.3.21
hooks:
- id: isort
- repo: https://github.com/ansible/ansible-lint.git
rev: v4.1.1a5
rev: v4.3.0a0
hooks:
- id: ansible-lint
- repo: https://github.com/antonbabenko/pre-commit-terraform.git
rev: v1.12.0
rev: v1.30.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.0
rev: v1.0.1
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.770
hooks:
- id: mypy
29 changes: 25 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -81,7 +102,7 @@ commands:
cd weewx-docker
pyenv virtualenv <python_version_to_use> weewx-docker
pyenv local weewx-docker
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 tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
https://docs.pytest.org/en/latest/writing_plugins.html#conftest-py-plugins
"""
# Third-Party Libraries
import pytest


MAIN_SERVICE_NAME = "weewx"
VERSION_SERVICE_NAME = f"{MAIN_SERVICE_NAME}-version"

Expand Down
2 changes: 2 additions & 0 deletions tests/container_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env pytest -vs
"""Tests for example container."""

# Standard Python Libraries
import os
import time

# Third-Party Libraries
import pytest

READY_MESSAGE = "engine: Starting main packet loop"
Expand Down

0 comments on commit d08c090

Please sign in to comment.