Skip to content

[pre-commit.ci] pre-commit autoupdate #198

[pre-commit.ci] pre-commit autoupdate

[pre-commit.ci] pre-commit autoupdate #198

name: test-and-publish-doit
on:
# run on all pushes to any branch
push:
paths:
- "**.py"
- "**.rst"
- "pyproject.toml"
- "poetry.lock"
- ".pre-commit-config.yaml"
- ".github/workflows/*.yaml"
# Ignore small changes to documentation files
# (ReadTheDocs will build based on new README anyway.)
- "!README.rst"
- "!CHANGELOG.md"
# run only on master pull requests
pull_request:
branches: [master]
# also run periodically
schedule:
- cron: "41 7 * * 5"
jobs:
pytest-coverage-doit:
name: Test and check coverage of 🐍 code
strategy:
matrix:
python-version: [3.8, 3.9]
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Resolve absolute python version (debug)
run: |
python --version
echo ${{ env.pythonLocation }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install nox doit toml pre-commit
- name: Cache .nox and .doit.db
uses: actions/cache@v2
with:
path: |
.nox
.doit.db
key: "\
${{ runner.os }}-\
${{ matrix.python-version }}-\
${{ env.pythonLocation }}-\
nox-\
${{ hashFiles('noxfile.py') }}-\
${{ hashFiles('poetry.lock') }}-\
ci_test\
"
- name: Test with doit -> nox -> pytest
run: doit ci_test:${{ matrix.python-version }}
doit:
name: Run auxiliary doit tasks to lint and make docs & citation.
strategy:
matrix:
python-version: [3.8]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
needs: [pytest-coverage-doit]
steps:
- uses: actions/checkout@v2
- name: Set up Python 🐍 ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install nox doit toml pre-commit
- name: Install pandoc
run: sudo apt install pandoc
- name: Cache .nox and .doit.db
uses: actions/cache@v2
with:
# We can cache .doit.db and it will be significant as
# most doit util tasks are run here in the same github actions job
path: |
.nox
.doit.db
key: "\
${{ runner.os }}-\
${{ env.pythonLocation }}-\
nox-\
${{ hashFiles('noxfile.py') }}-\
${{ hashFiles('poetry.lock') }}-\
"
- name: Run commands
# These could be better parallelized with a matrix
# but as some tasks are dependent on others it is
# (probably) more efficient to run all here
# (move efficient for github.com at least)
run: |
doit pre_commit lint docs citation build:${{ matrix.python-version }}
- name: Publish distribution πŸ“¦ to PyPI on tagged commit pushes
# Publish to PyPI on tagged commit pushes on master
if: >
github.event_name == 'push'
&& startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
release:
runs-on: ubuntu-latest
needs: [pytest-coverage-doit, doit]
name: Release on GitHub
steps:
- uses: actions/checkout@v2
- name: Create incremental changelog
run: >
cat CHANGELOG.md
| sed -n '1,/github/p'
> RELEASE_CHANGELOG.md
- name: Echo RELEASE_CHANGELOG.md
run: cat RELEASE_CHANGELOG.md
- name: Publish release on GitHub
if: >
github.event_name == 'push'
&& startsWith(github.ref, 'refs/tags')
uses: softprops/action-gh-release@v1
with:
files: |
CHANGELOG.md
body_path: RELEASE_CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}