Skip to content

Commit

Permalink
Initial implementation (#99)
Browse files Browse the repository at this point in the history
* Update template to 2020.7.15

* Remove command-line interface

* Remove click from dependencies

* Update poetry.lock

* Add implementation

* Use this project in its own noxfile.py

* Ignore E402

* Add nox 2020.5.24

* Import nox_poetry from the Nox installation

* Install nox-poetry in Tests workflow

* Add fake tests

* Update cookiecutter-hypermodern-python to 2020.9.15

* Update tests

* Use package instead of __init__ in API reference

* Do not run typeguard by default

* Do not run typeguard in CI

* Update README.rst
  • Loading branch information
cjolowicz authored Sep 25, 2020
1 parent 6525572 commit 0512205
Show file tree
Hide file tree
Showing 24 changed files with 1,339 additions and 597 deletions.
2 changes: 1 addition & 1 deletion .cookiecutter.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"_template": "gh:cjolowicz/cookiecutter-hypermodern-python",
"_template": "https://github.com/cjolowicz/cookiecutter-hypermodern-python.git",
"author": "Claudio Jolowicz",
"email": "mail@claudiojolowicz.com",
"friendly_name": "nox-poetry",
Expand Down
26 changes: 0 additions & 26 deletions .dependabot/config.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[flake8]
select = B,B9,C,D,DAR,E,F,N,RST,S,W
ignore = E203,E501,W503
ignore = E203,E501,RST203,RST301,W503
max-line-length = 80
max-complexity = 10
docstring-convention = google
Expand Down
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
- package-ecosystem: pip
directory: "/.github/workflows"
schedule:
interval: daily
- package-ecosystem: pip
directory: "/docs"
schedule:
interval: daily
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
7 changes: 4 additions & 3 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pip==20.1
nox==2019.11.9
poetry==1.0.5
pip==20.2.3
nox==2020.8.22
poetry==1.0.10
virtualenv==20.0.31
16 changes: 0 additions & 16 deletions .github/workflows/coverage.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/docs.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/workflows/release-drafter.yml

This file was deleted.

88 changes: 62 additions & 26 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,78 @@
name: Release

on:
release:
types: [published]
push:
branches:
- master

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.1.0
- uses: actions/setup-python@v2
- name: Check out the repository
uses: actions/checkout@v2.3.2
with:
fetch-depth: 2

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

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip install --constraint=.github/workflows/constraints.txt nox poetry
- name: Compute cache key prefix
if: matrix.os != 'windows-latest'
id: cache_key_prefix
shell: python
pip --version
- name: Install Poetry
run: |
import hashlib
import sys
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --version
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])
- name: Check if there is a parent commit
id: check-parent-commit
run: |
echo "::set-output name=sha::$(git rev-parse --verify --quiet HEAD^)"
print("::set-output name=result::{}".format(result))
- uses: actions/cache@v1.2.0
if: matrix.os != 'windows-latest'
- name: Detect and tag new version
id: check-version
if: steps.check-parent-commit.outputs.sha
uses: salsify/action-detect-and-tag-new-version@v2.0.1
with:
path: ~/.cache/pre-commit
key: ${{ steps.cache_key_prefix.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
${{ steps.cache_key_prefix.outputs.result }}-
- run: nox --force-color
- run: poetry build --ansi
- uses: pypa/gh-action-pypi-publish@v1.1.0
version-command: |
bash -o pipefail -c "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/gh-action-pypi-publish@v1.3.1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

- name: Publish package on TestPyPI
if: "! steps.check-version.outputs.tag"
uses: pypa/gh-action-pypi-publish@v1.3.1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Publish the release notes
uses: release-drafter/release-drafter@v5.11.0
with:
publish: ${{ steps.check-version.outputs.tag != '' }}
tag: ${{ steps.check-version.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26 changes: 0 additions & 26 deletions .github/workflows/test-pypi.yml

This file was deleted.

97 changes: 76 additions & 21 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,63 @@
name: Tests
on: [push, pull_request]

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 }
- { python-version: 3.8, os: windows-latest }
- { python-version: 3.8, os: macos-latest }
- { python-version: 3.7, os: ubuntu-latest }
- { python-version: 3.6, os: ubuntu-latest }
runs-on: ${{ matrix.os }}
name: Python ${{ matrix.python-version }} (${{ matrix.os }})
- { 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" }
- { python-version: 3.7, os: ubuntu-latest, session: "mypy" }
- { python-version: 3.6, os: ubuntu-latest, session: "mypy" }
- { python-version: 3.8, os: ubuntu-latest, session: "tests" }
- { python-version: 3.7, os: ubuntu-latest, session: "tests" }
- { python-version: 3.6, os: ubuntu-latest, session: "tests" }
- { python-version: 3.8, os: windows-latest, session: "tests" }
- { python-version: 3.8, os: macos-latest, session: "tests" }
- { python-version: 3.8, os: ubuntu-latest, session: "docs-build" }

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

steps:
- uses: actions/checkout@v2.1.0
- uses: actions/setup-python@v2
- name: Check out the repository
uses: actions/checkout@v2.3.2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2.1.2
with:
python-version: ${{ matrix.python-version }}
- name: Compute cache key prefix
if: matrix.os != 'windows-latest'
id: cache_key_prefix

- 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: Install nox-poetry
run: |
pip install .
- name: Compute pre-commit cache key
if: matrix.session == 'pre-commit'
id: pre-commit-cache
shell: python
run: |
import hashlib
Expand All @@ -32,14 +69,32 @@ jobs:
result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8])
print("::set-output name=result::{}".format(result))
- uses: actions/cache@v1.2.0
if: matrix.os != 'windows-latest'
- name: Restore pre-commit cache
uses: actions/cache@v2
if: matrix.session == 'pre-commit'
with:
path: ~/.cache/pre-commit
key: ${{ steps.cache_key_prefix.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }}
key: ${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
${{ steps.cache_key_prefix.outputs.result }}-
- run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip install --constraint=.github/workflows/constraints.txt nox poetry
- run: nox --force-color
${{ steps.pre-commit-cache.outputs.result }}-
- name: Run Nox
run: |
nox --force-color --python=${{ matrix.python-version }}
- name: Upload documentation
if: matrix.session == 'docs-build'
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/codecov-action@v1.0.13
Loading

0 comments on commit 0512205

Please sign in to comment.