-
-
Notifications
You must be signed in to change notification settings - Fork 50
273 lines (258 loc) · 8.24 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
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
name: tests
on:
push:
branches: [main]
tags:
- 'v*'
pull_request_target:
branches: [main]
jobs:
linux:
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.8, 3.9, "3.10", 3.11, 3.12, 3.13]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: pip
- name: without optional dependencies
run: |
pip install .[coverage]
pytest --cov --cov-report=term --cov-report=xml --junit-xml=junit.xml
mv coverage.xml coverage_py${{ matrix.python }}_bare.xml
mv junit.xml junit_py${{ matrix.python }}_bare.xml
- name: with all optional dependencies
run: |
pip install .[test,all]
pytest --cov --cov-report=term --cov-report=xml --junit-xml=junit.xml
mv coverage.xml coverage_py${{ matrix.python }}_all.xml
mv junit.xml junit_py${{ matrix.python }}_all.xml
- name: without future annotations
run: |
sed -i '/^from __future__ import annotations$/d' jsonargparse_tests/test_*.py
pytest --cov --cov-report=term --cov-report=xml --junit-xml=junit.xml
mv coverage.xml coverage_py${{ matrix.python }}_types.xml
mv junit.xml junit_py${{ matrix.python }}_types.xml
- uses: actions/upload-artifact@v4
with:
name: coverage_py${{ matrix.python }}
path: ./coverage_py*
- uses: actions/upload-artifact@v4
with:
name: junit_py${{ matrix.python }}
path: ./junit_py*
windows:
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
python: [3.8, 3.9, "3.10", 3.11, 3.12, 3.13]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: pip
- run: pip install tox
- run: tox -e py-all-extras
macos:
runs-on: macOS-15
strategy:
fail-fast: false
matrix:
python: [3.8, "3.10", 3.12]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: pip
- run: pip install tox
- run: tox -e py-all-extras
omegaconf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
- run: pip install tox
- run: tox -e omegaconf
pydantic-v1:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
- name: With pydantic<2
run: |
pip install .[coverage]
pip install "pydantic<2"
pytest --cov --cov-report=term --cov-report=xml --junit-xml=junit.xml jsonargparse_tests/test_dataclass_like.py
mv coverage.xml coverage_pydantic1.xml
mv junit.xml junit_pydantic1.xml
- name: with pydantic>=2
run: |
sed -i "s|import pydantic|import pydantic.v1 as pydantic|" jsonargparse_tests/test_dataclass_like.py
sed -i "s|^annotated = .*|annotated = False|" jsonargparse_tests/test_dataclass_like.py
sed -i "s|test_pydantic_types|_test_pydantic_types|" jsonargparse_tests/test_dataclass_like.py
pip install "pydantic>=2"
pytest --cov --cov-report=term --cov-report=xml --junit-xml=junit.xml jsonargparse_tests/test_dataclass_like.py
mv coverage.xml coverage_pydantic2.xml
mv junit.xml junit_pydantic2.xml
- uses: actions/upload-artifact@v4
with:
name: coverage_pydantic
path: ./coverage_py*
- uses: actions/upload-artifact@v4
with:
name: junit_pydantic
path: ./junit_py*
without-pyyaml:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
- run: |
pip install .[test,all]
pip uninstall -y argcomplete omegaconf pyyaml reconplogger responses ruyaml types-PyYAML
pytest
build-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Build package
run: |
pip install -U build
python -m build
- uses: actions/upload-artifact@v4
with:
name: package
path: ./dist/*
installed-package:
runs-on: ubuntu-latest
needs: [build-package]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
- uses: actions/download-artifact@v4
with:
name: package
path: dist
- name: Test without optional dependencies
run: |
cd dist
pip install $(ls *.whl)[test-no-urls]
python -m jsonargparse_tests
- name: Test with all optional dependencies
run: |
cd dist
pip install $(ls *.whl)[test,all]
python -m jsonargparse_tests
doctest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
- run: pip install -e .[all,doc]
- name: Run doc tests
run: sphinx-build -M doctest sphinx sphinx/_build sphinx/index.rst
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
- uses: actions/cache@v4
with:
key: pre-commit-cache
path: ~/.cache/pre-commit
- run: pip install pre-commit
- run: pre-commit run -a --hook-stage pre-push mypy
codecov:
runs-on: ubuntu-latest
needs: [linux, pydantic-v1]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
merge-multiple: true
- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
files: ./coverage_*.xml
token: ${{ secrets.CODECOV_TOKEN }}
- uses: codecov/test-results-action@v1
with:
fail_ci_if_error: true
files: ./junit_*.xml
token: ${{ secrets.CODECOV_TOKEN }}
sonarcloud:
runs-on: ubuntu-latest
needs: [linux, pydantic-v1]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clone disabled for a better relevancy of analysis
- uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Get version
run: |
TAG=$(git describe --tags --exact-match 2>/dev/null | sed 's/^v//')
if [ -n "$TAG" ]; then
VERSION="$TAG"
else
VERSION="$(git describe --tags --abbrev=0 | sed 's/^v//')+$(git rev-parse --short HEAD)"
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
- uses: SonarSource/sonarqube-scan-action@v4
with:
args: >
-Dsonar.organization=omni-us
-Dsonar.projectKey=omni-us_jsonargparse
-Dsonar.projectVersion=${{ env.VERSION }}
-Dsonar.sources=jsonargparse
-Dsonar.exclusions=sphinx/**
-Dsonar.tests=jsonargparse_tests
-Dsonar.python.coverage.reportPaths=coverage_*.xml
-Dsonar.python.version=3.8,3.9,3.10,3.11,3.12,3.13
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
pypi-publish:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [linux, windows, macos, omegaconf, pydantic-v1, without-pyyaml, installed-package, doctest, mypy]
environment:
name: pypi
url: https://pypi.org/p/jsonargparse
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: package
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1