-
Notifications
You must be signed in to change notification settings - Fork 6
156 lines (149 loc) · 5.25 KB
/
main.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
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 }}