-
Notifications
You must be signed in to change notification settings - Fork 0
256 lines (213 loc) · 8.08 KB
/
Copy pathci.yml
File metadata and controls
256 lines (213 loc) · 8.08 KB
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
name: Continuous Integration (uv)
on: [push, pull_request]
# Note: Environment variables (PROJECT_NAME and vars from [tool.wads.ci.env])
# are set by the read-ci-config action in the setup job and made available
# to all subsequent jobs via GITHUB_ENV
jobs:
# First job: Read configuration from pyproject.toml
setup:
name: Read Configuration
runs-on: ubuntu-latest
outputs:
project-name: ${{ steps.config.outputs.project-name }}
python-versions: ${{ steps.config.outputs.python-versions }}
pytest-args: ${{ steps.config.outputs.pytest-args }}
coverage-enabled: ${{ steps.config.outputs.coverage-enabled }}
exclude-paths: ${{ steps.config.outputs.exclude-paths }}
test-on-windows: ${{ steps.config.outputs.test-on-windows }}
build-sdist: ${{ steps.config.outputs.build-sdist }}
build-wheel: ${{ steps.config.outputs.build-wheel }}
metrics-enabled: ${{ steps.config.outputs.metrics-enabled }}
metrics-config-path: ${{ steps.config.outputs.metrics-config-path }}
metrics-storage-branch: ${{ steps.config.outputs.metrics-storage-branch }}
metrics-python-version: ${{ steps.config.outputs.metrics-python-version }}
metrics-force-run: ${{ steps.config.outputs.metrics-force-run }}
steps:
- uses: actions/checkout@v6
- name: Set up uv
uses: astral-sh/setup-uv@v7
- name: Set up Python
run: uv python install 3.11
- name: Read CI Config
id: config
uses: i2mint/wads/actions/read-ci-config@master
with:
pyproject-path: .
# Second job: Validation using the config
validation:
name: Validation
if: "!contains(github.event.head_commit.message, '[skip ci]')"
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ${{ fromJson(needs.setup.outputs.python-versions) }}
steps:
- uses: actions/checkout@v6
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
run: |
uv python install ${{ matrix.python-version }}
uv venv --python ${{ matrix.python-version }}
- name: Install System Dependencies
uses: i2mint/wads/actions/install-system-deps@master
with:
pyproject-path: .
- name: Install Dependencies
run: |
source .venv/bin/activate
uv pip install -e ".[dev]"
- name: Format Source Code
run: uvx ruff format .
- name: Lint Validation
run: uvx ruff check --output-format=github ${{ needs.setup.outputs.project-name }}
- name: Run Tests
run: |
source .venv/bin/activate
PYTEST_ARGS="${{ needs.setup.outputs.pytest-args }}"
EXCLUDE="${{ needs.setup.outputs.exclude-paths }}"
COVERAGE="${{ needs.setup.outputs.coverage-enabled }}"
ROOT_DIR="${{ needs.setup.outputs.project-name }}"
CMD="python -m pytest"
# Add coverage flags
if [ "$COVERAGE" = "true" ]; then
uv pip install pytest-cov
CMD="$CMD --cov=$ROOT_DIR --cov-report=term-missing"
fi
# Add doctest flags
CMD="$CMD --doctest-modules"
CMD="$CMD -o doctest_optionflags='ELLIPSIS IGNORE_EXCEPTION_DETAIL'"
# Add exclude paths
if [ -n "$EXCLUDE" ]; then
IFS=',' read -ra PATHS <<< "$EXCLUDE"
for path in "${PATHS[@]}"; do
path=$(echo "$path" | xargs)
CMD="$CMD --ignore=$path"
done
fi
# Add extra pytest args
if [ -n "$PYTEST_ARGS" ]; then
CMD="$CMD $PYTEST_ARGS"
fi
echo "Running: $CMD"
eval $CMD
- name: Track Code Metrics
if: needs.setup.outputs.metrics-enabled == 'true'
uses: i2mint/umpyre/actions/track-metrics@master
continue-on-error: true
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
config-path: ${{ needs.setup.outputs.metrics-config-path }}
storage-branch: ${{ needs.setup.outputs.metrics-storage-branch }}
python-version: ${{ needs.setup.outputs.metrics-python-version }}
force-run: ${{ needs.setup.outputs.metrics-force-run }}
# Optional Windows testing (if enabled in config)
windows-validation:
name: Windows Tests
if: "!contains(github.event.head_commit.message, '[skip ci]') && needs.setup.outputs.test-on-windows == 'true'"
needs: setup
runs-on: windows-latest
continue-on-error: true
steps:
- uses: actions/checkout@v6
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Set up Python
run: |
uv python install ${{ fromJson(needs.setup.outputs.python-versions)[0] }}
uv venv
- name: Install System Dependencies
uses: i2mint/wads/actions/install-system-deps@master
with:
pyproject-path: .
- name: Install Dependencies
run: |
.venv\Scripts\activate
uv pip install -e ".[dev]"
- name: Run tests
id: test
continue-on-error: true
run: |
.venv\Scripts\activate
pytest
- name: Report test results
if: always()
run: |
if ("${{ steps.test.outcome }}" -eq "failure") {
echo "::warning::Windows tests failed but workflow continues"
echo "## ⚠️ Windows Tests Failed" >> $env:GITHUB_STEP_SUMMARY
echo "Tests failed on Windows but this is informational only." >> $env:GITHUB_STEP_SUMMARY
} else {
echo "## ✅ Windows Tests Passed" >> $env:GITHUB_STEP_SUMMARY
}
# Publishing job
publish:
name: Publish
permissions:
contents: write
if: "!contains(github.event.head_commit.message, '[skip ci]') && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')"
needs: [setup, validation]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up uv
uses: astral-sh/setup-uv@v7
- name: Set up Python
run: uv python install ${{ fromJson(needs.setup.outputs.python-versions)[0] }}
- name: Format Source Code
run: uvx ruff format .
- name: Update Version Number
id: version
uses: i2mint/isee/actions/bump-version-number@master
- name: Build Distribution
run: |
BUILD_ARGS=""
if [ "${{ needs.setup.outputs.build-sdist }}" = "false" ]; then
BUILD_ARGS="$BUILD_ARGS --no-sdist"
fi
if [ "${{ needs.setup.outputs.build-wheel }}" = "false" ]; then
BUILD_ARGS="$BUILD_ARGS --no-wheel"
fi
uv build $BUILD_ARGS
- name: Publish to PyPI
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_PASSWORD }}
run: uv publish dist/*
- name: Force SSH for git remote
run: |
git remote set-url origin git@github.com:${{ github.repository }}.git
- name: Commit Changes
uses: i2mint/wads/actions/git-commit@master
with:
commit-message: "**CI** Formatted code + Updated version to ${{ env.VERSION }} [skip ci]"
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
push: true
- name: Tag Repository
uses: i2mint/wads/actions/git-tag@master
with:
tag: ${{ env.VERSION }}
message: "Release version ${{ env.VERSION }}"
push: true
# Optional GitHub Pages
github-pages:
name: Publish GitHub Pages
permissions:
contents: write
pages: write
id-token: write
if: "!contains(github.event.head_commit.message, '[skip ci]') && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)"
needs: publish
runs-on: ubuntu-latest
steps:
- uses: i2mint/epythet/actions/publish-github-pages@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
ignore: "tests/,scrap/,examples/"