-
Notifications
You must be signed in to change notification settings - Fork 22
198 lines (159 loc) · 5.19 KB
/
tests.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
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
192
193
194
195
196
197
198
# Try to get a short workflow name and a job name that start with Python
# version to make it easier to check the status inside GitHub UI.
name: CI
on:
push:
# Make sure to not enable `push` events for other branches as this will
# trigger the publishing to gh-pages from any branch.
# If you need to enable more branches look below and update
# the conditions for which gh-pages are updated.
branches: [ trunk ]
tags:
- "incremental-*"
pull_request:
branches: [ trunk, "90-pyproject.toml" ]
permissions:
contents: read
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install build twine
- run: python3 -m build
- run: twine check dist/*.*
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/*.*
testing:
runs-on: ubuntu-24.04
needs: [build]
env:
TOXENV: "${{ matrix.tox-env }}"
name: ${{ matrix.python-version }}-${{ matrix.tox-env }}
strategy:
fail-fast: false
matrix:
# Run on the minimum micro Python version that we can get on CI.
# When updating the minimum Python version here, also update the
# `python_requires` from `setup.cfg`.
# Run on latest minor release of each major python version.
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']
tox-env: ['tests']
include:
# Run non-python version specific jobs.
- python-version: 3.9
tox-env: mypy,apidocs
skip-coverage: true
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: twisted/python-info-action@v1
- name: Install dependencies
run: |
python -m pip install --upgrade pip tox
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Run job via tox
run: |
# GitHub Actions VM have 2 CPUs.
TOX_PARALLEL_NO_SPINNER=1 tox --parallel 2 --installpkg dist/*.whl
- name: Prepare GitHub Pages
if: contains(matrix['tox-env'], 'apidocs')
run: |
mkdir website
touch website/index.html
mv apidocs website/docs
- name: Publish documentation for push on trunk
# Since we don't have a separate job for apidocs gh-pages updating
# hijack the normal apidoc test and publish the resulting files.
if: contains(matrix['tox-env'], 'apidocs') && github.event_name == 'push'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_message: Publish docs for ${{ github.sha }}
publish_dir: ./website
- name: Prepare coverage results
if: ${{ !cancelled() && !matrix.skip-coverage }}
run: |
# Assign the coverage file a name unique to this job so that the
# uploads don't collide.
mv .coverage ".coverage-job-${{ matrix.python-version }}-${{ matrix.tox-env }}"
- name: Store coverage file
if: ${{ !cancelled() && !matrix.skip-coverage }}
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}-${{ matrix.tox-env }}
path: .coverage-job-*
coverage-report:
name: Coverage report
runs-on: ubuntu-latest
# We want to always run the coverage, even when the
# tests failed.
if: always()
needs:
- testing # Wait for test jobs.
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade coverage[toml] diff_cover
- name: Download coverage reports
uses: actions/download-artifact@v4
with:
pattern: coverage-*
merge-multiple: true
path: .
- name: Prepare coverage
run: |
coverage combine .coverage-job-*
# XML is needed for the diff-cover.
coverage xml
- name: Report coverage
run: |
# Report for the job log.
coverage report --skip-covered --skip-empty >> $GITHUB_STEP_SUMMARY
diff-cover --markdown-report coverage-report.md --compare-branch origin/trunk coverage.xml
- name: Enforce diff coverage
run: |
diff-cover --fail-under=100 --compare-branch origin/trunk coverage.xml
- name: Generate HTML report on failure
if: ${{ failure() }}
run: |
coverage html --skip-covered --skip-empty
- name: Upload HTML report on failure
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: html-report
path: htmlcov
pypi-publish:
runs-on: ubuntu-24.04
if: startsWith(github.ref, 'refs/tags/incremental-')
needs: [build, testing]
environment:
name: release
url: https://pypi.org/p/incremental
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1