-
Notifications
You must be signed in to change notification settings - Fork 7
188 lines (164 loc) · 5.36 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
name: Test and Release
on:
push:
branches: [ "main" ]
pull_request:
workflow_dispatch:
inputs:
do_release:
description: 'Create a new release'
required: true
type: boolean
schedule:
# Every friday at 22:00 UTC (Every saturday at 07:00 KST/JST)
- cron: "0 22 * * FRI"
env:
FORCE_COLOR: 1
jobs:
test:
name: Test Python ${{ matrix.python-version }} [${{ matrix.qt-api }}]
runs-on: ubuntu-latest
env:
DISPLAY: ':99.0'
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
qt-api: ["pyqt6", "pyside6"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: tlambert03/setup-qt-libs@v1
- name: Setup for Qt testing
run: |
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1920x1200x24 -ac +extension GLX
- name: Install pytest and dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -v .[viz,io,perf,misc,dev] ${{ matrix.qt-api }}
python -m pip list
export QT_API=${{ matrix.qt-api }}
- name: Test with pytest
if: matrix.python-version != '3.12' || matrix.qt-api != 'pyqt6'
run: |
python -u -m pytest -vv --full-trace
- name: Test with pytest with coverage
if: matrix.python-version == '3.12' && matrix.qt-api == 'pyqt6'
run: |
python -u -m pytest -vv --full-trace --cov erlab --junitxml=junit.xml
- name: Upload coverage to Codecov
if: matrix.python-version == '3.12' && matrix.qt-api == 'pyqt6'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
if: ${{ matrix.python-version == '3.12' && matrix.qt-api == 'pyqt6' && !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
mypy:
name: Static type checking
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install mypy and dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[viz,io,perf,misc,dev] mypy[reports,faster-cache] pyqt6
python -m pip list
- name: Run mypy
run: mypy --install-types --non-interactive --html-report mypy-report .
- name: Upload mypy results
uses: actions/upload-artifact@v4
if: always()
with:
name: mypy-report
path: mypy-report/
if-no-files-found: error
changelog:
name: Update changelog
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.repository == 'kmnhan/erlabpy'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install commitizen cz-changeup
- name: Generate changelog
run: |
cz changelog
- name: Commit and push changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
if ! git diff-index --quiet HEAD; then
git commit -m "chore: update changelog"
git push
else
echo "nothing to commit, working tree clean"
fi
release:
name: Release
runs-on: ubuntu-latest
concurrency:
group: release
needs: [test, mypy]
if: |
github.event_name == 'workflow_dispatch' &&
github.repository == 'kmnhan/erlabpy' &&
inputs.do_release
environment:
name: pypi
url: https://pypi.org/p/erlab
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run commitizen
id: cz
uses: commitizen-tools/commitizen-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
changelog_increment_filename: body.md
extra_requirements : "cz-changeup"
- name: Build package distributions
id: build
if: env.REVISION != env.PREVIOUS_REVISION
run: |
python -m venv venv
source venv/bin/activate
python -m pip install --upgrade build
python -m build
- name: Publish package distributions to PyPI
id: pypi-publish
if: env.REVISION != env.PREVIOUS_REVISION
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
- name: Publish package distributions to GitHub Releases
id: github-release
if: env.REVISION != env.PREVIOUS_REVISION
uses: softprops/action-gh-release@v2
with:
body_path: "body.md"
tag_name: v${{ steps.cz.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
files: dist/*