.github/workflows/main.yaml #198
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
# run on pushed to master only | |
# make pull request to run jobs for other branches | |
push: | |
paths: | |
- "**.py" | |
- "**.rst" | |
- "**.nix" | |
- "**.lock" | |
- "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" | |
branches: [master] | |
# run on all pull requests | |
pull_request: | |
# also run periodically | |
schedule: | |
- cron: "41 7 * * 5" | |
jobs: | |
ci: | |
name: Test, check coverage of 🐍 code and run auxiliary tasks on Python 3.8 | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11"] | |
platform: [ubuntu-latest] | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: cachix/install-nix-action@v17 | |
with: | |
nix_path: nixpkgs=channel:nixos-unstable | |
extra_nix_config: "accept-flake-config = true" | |
install_url: https://releases.nixos.org/nix/nix-2.13.3/install | |
- uses: cachix/cachix-action@v12 | |
with: | |
name: fractopo | |
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" | |
- name: Cache poetry cache-dir | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pypoetry | |
key: ${{ runner.os }}-${{ hashFiles('poetry.lock') }}-${{ hashFiles('flake.lock') }}-${{ matrix.python-version }} | |
- name: Test with doit -> nix | |
run: | | |
nix develop -c poetry install | |
nix develop -c poetry run doit -v 3 ci_test:${{ matrix.python-version }} | |
- name: Run auxiliary tasks on Python 3.8 | |
if: > | |
matrix.python-version == '3.8' | |
&& matrix.platform == 'ubuntu-latest' | |
run: | | |
nix develop -c poetry run doit -v 3 -n 2 auxiliary | |
# Check that no files have changed (ignore coverage.svg) | |
git restore docs_src/imgs/coverage.svg | |
git diff --exit-code | |
- name: Publish distribution 📦 to PyPI on tagged commit pushes | |
# Publish to PyPI on tagged commit pushes on master | |
# TODO: Currently does not depend that all python-version builds succeed! | |
if: > | |
github.event_name == 'push' | |
&& startsWith(github.ref, 'refs/tags') | |
&& matrix.python-version == '3.8' | |
uses: pypa/gh-action-pypi-publish@master | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_PASSWORD }} | |
# auxiliary: | |
# name: Run auxiliary doit tasks to lint and make docs & citation. | |
# strategy: | |
# matrix: | |
# platform: [ubuntu-latest] | |
# runs-on: ${{ matrix.platform }} | |
# needs: [pytest-with-coverage] | |
# steps: | |
# - uses: actions/checkout@v3 | |
# - uses: cachix/install-nix-action@v17 | |
# with: | |
# nix_path: nixpkgs=channel:nixos-unstable | |
# - name: Cache poetry cache-dir | |
# uses: actions/cache@v3 | |
# with: | |
# path: ~/.cache/pypoetry | |
# key: ${{ runner.os }}-${{ hashFiles('poetry.lock') }}-${{ hashFiles('flake.lock') }}-${{ hashFiles('flake.nix') }} | |
# - name: Cache .nox and .doit.db | |
# uses: actions/cache@v3 | |
# 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') }}-\ | |
# ${{ hashFiles('flake.lock') }}-\ | |
# ${{ hashFiles('flake.nix') }}-\ | |
# " | |
# - 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 | |
# # (more efficient for github.com at least) | |
# run: | | |
# nix develop -c poetry install | |
# nix develop -c poetry run doit -v 3 -n 2 pre_commit lint docs build | |
# # Check that no files have changed | |
# git diff --exit-code | |
# - 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: [ci] | |
name: Release on GitHub | |
steps: | |
- uses: actions/checkout@v3 | |
- 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 }} |