-
-
Notifications
You must be signed in to change notification settings - Fork 182
191 lines (182 loc) · 5.79 KB
/
ci.yml
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: CI
on:
pull_request:
push:
branches: [master]
tags: ["*"]
workflow_dispatch:
inputs:
pytest_addopts:
description:
Extra options for pytest; use -vv for full details; see
https://docs.pytest.org/en/latest/example/simple.html#how-to-change-command-line-options-defaults
required: false
env:
LANG: "en_US.utf-8"
LC_ALL: "en_US.utf-8"
PIP_CACHE_DIR: ${{ github.workspace }}/.cache/pip
POETRY_CACHE_DIR: ${{ github.workspace }}/.cache/pypoetry
POETRY_VIRTUALENVS_IN_PROJECT: "true"
PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit
PYTEST_ADDOPTS: ${{ github.event.inputs.pytest_addopts }}
PYTHONIOENCODING: "UTF-8"
jobs:
build:
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
runs-on: ${{ matrix.os }}
steps:
# HACK https://github.com/actions/cache/issues/315
- name: Enable msys binaries
if: ${{ runner.os == 'Windows' }}
run: |
echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
rm C:\msys64\usr\bin\bash.exe
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needs all tags to compute dynamic version
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Get full Python version
id: full-python-version
shell: bash # Required for use of $GITHUB_OUTPUT in windows
run:
echo version=$(python -c "import sys; print('-'.join(str(v) for v in
sys.version_info))") >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: |
.cache
.venv
# prettier-ignore
key:
cache-
${{ runner.os }}-
${{ runner.arch }}-
${{ steps.full-python-version.outputs.version }}-
${{ hashFiles('pyproject.toml') }}-
${{ hashFiles('poetry.lock') }}-
${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install dependencies
run: |
python -m pip install poetry poetry-dynamic-versioning
poetry install --with dev,docs -v
- name: Run pytest
run: poetry run poe test --cov=./ --cov-report=xml -ra .
- name: Upload coverage to Codecov
continue-on-error: true
uses: codecov/codecov-action@v4
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
with:
env_vars: OS,PYTHON
fail_ci_if_error: true
file: ./coverage.xml
flags: unittests
name: copier
token: ${{ secrets.CODECOV_TOKEN }}
flake-check:
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
runs-on: ${{ matrix.os }}
permissions:
contents: write # Allow pushing back pre-commit changes
steps:
- uses: actions/checkout@v4
# Install Nix and set up Cachix
- uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v15
with:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
extraPullNames: devenv
name: copier
pushFilter: (-source$|nixpkgs\.tar\.gz$)
# Cache for poetry venv when using direnv
- uses: actions/cache@v4
with:
path: |
.cache
.devenv
.direnv
.venv
# prettier-ignore
key:
direnv-
${{ runner.os }}-
${{ runner.arch }}-
${{ hashFiles('pyproject.toml', '*.lock', '*.nix') }}
# Check direnv works as expected
- uses: JRMurr/direnv-nix-action@v3
with:
install-nix: "false"
cache-store: "false"
- run: copier --version
# Run nix checks
- run: nix flake check -L --accept-flake-config --impure
publish:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
needs:
- build
- flake-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needs all tags to compute dynamic version
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Get full Python version
id: full-python-version
run:
echo version=$(python -c "import sys; print('-'.join(str(v) for v in
sys.version_info))") >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: |
.cache
.venv
# prettier-ignore
key:
cache-
${{ runner.os }}-
${{ runner.arch }}-
${{ steps.full-python-version.outputs.version }}-
${{ hashFiles('pyproject.toml') }}-
${{ hashFiles('poetry.lock') }}-
${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install dependencies
shell: bash
run: |
python -m pip install poetry poetry-dynamic-versioning
- name: Build dist
run: |
poetry build
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.test_pypi_token_copier }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_token_copier }}