Skip to content

Commit

Permalink
Merge pull request #1 from cjolowicz/cookiecutter
Browse files Browse the repository at this point in the history
Hypermodern Python Cookiecutter
  • Loading branch information
cjolowicz authored May 30, 2020
2 parents 2fbd6e5 + a6ef1c7 commit afe3edb
Show file tree
Hide file tree
Showing 33 changed files with 2,087 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .cookiecutter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"_template": "gh:cjolowicz/cookiecutter-hypermodern-python",
"author": "Claudio Jolowicz",
"email": "[email protected]",
"friendly_name": "Retrocookie",
"github_user": "cjolowicz",
"package_name": "retrocookie",
"project_name": "retrocookie",
"version": "0.1.0"
}
2 changes: 2 additions & 0 deletions .darglint
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[darglint]
strictness = short
26 changes: 26 additions & 0 deletions .dependabot/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: 1
update_configs:
- package_manager: "python"
directory: "/"
update_schedule: "daily"
allowed_updates:
- match:
update_type: "all"
- package_manager: "python"
directory: "/docs"
update_schedule: "daily"
allowed_updates:
- match:
update_type: "all"
- package_manager: "python"
directory: "/.github/workflows"
update_schedule: "daily"
allowed_updates:
- match:
update_type: "all"
- package_manager: "github_actions"
directory: "/"
update_schedule: "daily"
allowed_updates:
- match:
update_type: "all"
7 changes: 7 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[flake8]
select = B,B9,C,D,DAR,E,F,N,RST,S,W
ignore = E203,E501,W503
max-line-length = 80
max-complexity = 10
docstring-convention = google
per-file-ignores = tests/*:S101
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
29 changes: 29 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
categories:
- title: ":boom: Breaking Changes"
label: "breaking"
- title: ":rocket: Features"
label: "enhancement"
- title: ":fire: Removals and Deprecations"
label: "removal"
- title: ":beetle: Fixes"
label: "bug"
- title: ":racehorse: Performance"
label: "performance"
- title: ":rotating_light: Testing"
label: "testing"
- title: ":construction_worker: Continuous Integration"
label: "ci"
- title: ":books: Documentation"
label: "documentation"
- title: ":hammer: Refactoring"
label: "refactoring"
- title: ":lipstick: Style"
label: "style"
- title: ":package: Dependencies"
labels:
- "dependencies"
- "build"
template: |
## Changes
$CHANGES
4 changes: 4 additions & 0 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pip==20.1.1
nox==2019.11.9
poetry==1.0.5
virtualenv==20.0.21
72 changes: 72 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Release

on:
push:
branches:
- master

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/[email protected]
with:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Detect and tag new version
id: check-version
uses: salsify/[email protected]
with:
version-command: |
poetry version | awk '{ print $2 }'
- name: Bump version for developmental release
if: "! steps.check-version.outputs.tag"
run: |
poetry version patch &&
version=$(poetry version | awk '{ print $2 }') &&
poetry version $version.dev.$(date +%s)
- name: Build package
run: |
poetry build --ansi
- name: Publish package on PyPI
if: steps.check-version.outputs.tag
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

- name: Publish package on TestPyPI
if: "! steps.check-version.outputs.tag"
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Publish the release notes
uses: release-drafter/[email protected]
with:
publish: ${{ steps.check-version.outputs.tag != '' }}
tag: ${{ steps.check-version.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96 changes: 96 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Tests

on:
- push
- pull_request

jobs:
tests:
name: ${{ matrix.session }} ${{ matrix.python-version }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { python-version: 3.8, os: ubuntu-latest, session: "pre-commit" }
- { python-version: 3.8, os: ubuntu-latest, session: "safety" }
- { python-version: 3.8, os: ubuntu-latest, session: "mypy-3.8" }
- { python-version: 3.7, os: ubuntu-latest, session: "mypy-3.7" }
- { python-version: 3.6, os: ubuntu-latest, session: "mypy-3.6" }
- { python-version: 3.8, os: ubuntu-latest, session: "tests-3.8" }
- { python-version: 3.7, os: ubuntu-latest, session: "tests-3.7" }
- { python-version: 3.6, os: ubuntu-latest, session: "tests-3.6" }
- { python-version: 3.8, os: windows-latest, session: "tests-3.8" }
- { python-version: 3.8, os: macos-latest, session: "tests-3.8" }
- { python-version: 3.8, os: ubuntu-latest, session: "docs" }

env:
NOXSESSION: ${{ matrix.session }}

steps:
- name: Check out the repository
uses: actions/[email protected]

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Install Nox
run: |
pip install --constraint=.github/workflows/constraints.txt nox
nox --version
- name: Compute pre-commit cache key
if: matrix.session == 'pre-commit'
id: pre-commit-cache
shell: python
run: |
import hashlib
import sys
python = "py{}.{}".format(*sys.version_info[:2])
payload = sys.version.encode() + sys.executable.encode()
digest = hashlib.sha256(payload).hexdigest()
result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8])
print("::set-output name=result::{}".format(result))
- name: Restore pre-commit cache
uses: actions/[email protected]
if: matrix.session == 'pre-commit'
with:
path: ~/.cache/pre-commit
key: ${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
${{ steps.pre-commit-cache.outputs.result }}-
- name: Run Nox
run: |
nox --force-color
- name: Upload documentation
if: matrix.session == 'docs'
uses: actions/upload-artifact@v2
with:
name: docs
path: docs/_build

- name: Create coverage report
if: always() && matrix.session == 'tests'
run: |
nox --force-color --session=coverage -- xml
- name: Upload coverage report
if: always() && matrix.session == 'tests'
uses: codecov/[email protected]
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.mypy_cache/
/.coverage
/.nox/
/.python-version
/.pytype/
/dist/
/docs/_build/
/src/*.egg-info/
__pycache__/
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.0.0
hooks:
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-added-large-files
- repo: https://github.com/prettier/prettier
rev: 2.0.5
hooks:
- id: prettier
- repo: https://github.com/psf/black
rev: 19.10b0
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.1
hooks:
- id: flake8
additional_dependencies:
- flake8-bandit==2.1.2
- flake8-bugbear==20.1.4
- flake8-docstrings==1.5.0
- flake8-rst-docstrings==0.0.13
- pep8-naming==0.10.0
- darglint==1.3.0
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.3.0
hooks:
- id: reorder-python-imports
args: [--application-directories=src]
9 changes: 9 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
sphinx:
configuration: docs/conf.py
formats: all
python:
version: 3.8
install:
- requirements: docs/requirements.txt
- path: .
Loading

0 comments on commit afe3edb

Please sign in to comment.