forked from bids-standard/bids-specification
-
Notifications
You must be signed in to change notification settings - Fork 0
174 lines (152 loc) · 4.79 KB
/
Copy pathschemacode_ci.yml
File metadata and controls
174 lines (152 loc) · 4.79 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
name: "schemacode_ci"
on:
push:
branches:
- "master"
- "maint/*"
tags:
- "schema-*"
pull_request:
branches:
- "master"
- "maint/*"
- "*"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
build:
name: Build & verify package
runs-on: ubuntu-latest
permissions:
attestations: write
id-token: write
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v6
if: ${{ startsWith(github.ref, 'refs/tags/schema-') }}
- name: "Build archive on tag"
run: |
uv run --extra=tests pytest -k make_archive
working-directory: tools/schemacode
env:
BIDSSCHEMATOOLS_RELEASE: 1
if: ${{ startsWith(github.ref, 'refs/tags/schema-') }}
- uses: hynek/build-and-inspect-python-package@v2
with:
path: tools/schemacode
attest-build-provenance-github: ${{ github.event_name != 'pull_request' }}
test:
runs-on: ${{ matrix.os }}
needs: [build]
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
include:
- os: macos-latest
python-version: 3.13
- os: windows-latest
python-version: 3.13
name: ${{ matrix.os }} with Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }} (uv)
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}
activate-environment: true
- name: "Display Python version"
run: python -c "import sys; print(sys.version)"
- name: "Fetch packages"
uses: actions/download-artifact@v5
with:
name: Packages
path: dist
- name: "Install package"
run: |
uv pip install $( ls dist/*.whl )[all]
- name: "Run tests"
run: |
python -m pytest -vs --doctest-modules -m "not validate_schema" \
--cov-append --cov-report=xml --cov-report=term --cov=src/bidsschematools
working-directory: tools/schemacode
- name: "Validate generated types"
run: |
uvx --with=. mypy tests
working-directory: tools/schemacode
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: unit_${{ matrix.os }}_${{ matrix.python-version }}
path: tools/schemacode/coverage.xml
if: success()
publish:
name: Publish Python Package
if: github.event_name == 'push'
runs-on: ubuntu-latest
needs: [test]
permissions:
attestations: write
id-token: write
steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v5
with:
name: Packages
path: dist
- name: "Test PyPI upload"
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
skip-existing: true
- name: "Upload to PyPI (on tags)"
if: startsWith(github.ref, 'refs/tags/schema-')
uses: pypa/gh-action-pypi-publish@release/v1
validate_schema:
runs-on: ubuntu-latest
name: Validate schema
steps:
- uses: actions/checkout@v5
- name: Set Up Python environment
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install the schemacode package
run: |
python -m pip install --progress-bar off --upgrade pip setuptools wheel
python -m pip install -e ./tools/schemacode[all]
- name: Run schema validation tests
run: |
python -m pytest -vs --doctest-modules -m "validate_schema" \
--cov-append --cov-report=xml --cov-report=term --cov=src/bidsschematools
working-directory: tools/schemacode
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: schema_validation
path: tools/schemacode/coverage.xml
if: success()
upload_to_codecov:
runs-on: "ubuntu-latest"
name: Upload coverage
needs: [test, validate_schema]
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Download artifacts
uses: actions/download-artifact@v5
- name: Upload to CodeCov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required but might help API rate limits
fail_ci_if_error: true