-
Notifications
You must be signed in to change notification settings - Fork 119
181 lines (151 loc) · 5.11 KB
/
test.yml
File metadata and controls
181 lines (151 loc) · 5.11 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
name: unit tests
on:
push:
branches: [ master ]
tags:
- '*'
pull_request:
# Set minimal permissions by default
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: 3.13
- name: Install linters
run: python -m pip install --upgrade pip black zizmor pydoctor
- name: Black
run: black . --check
- name: Zizmor
run: find .github/workflows -name '*.yml' | xargs zizmor --config .github/zizmor.yml
- name: Pydoctor
run: pydoctor ./configargparse.py --intersphinx=https://docs.python.org/3/objects.inv --docformat=google -W
test:
name: ${{ matrix.os }} py${{ matrix.python-version }} ${{ matrix.use-docker && '(docker)' || '' }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: Legacy Python on Ubuntu
os: ubuntu-latest
python-version: '3.6'
use-docker: true
- name: Legacy Python on Ubuntu
os: ubuntu-latest
python-version: '3.7'
use-docker: true
- name: Legacy Python on Ubuntu
os: ubuntu-latest
python-version: '3.8'
use-docker: true
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9','3.10','3.11','3.12','3.13']
use-docker: [false]
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }}
if: ${{ !matrix.use-docker }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Run tests with Docker
if: ${{ matrix.use-docker }}
run: |
docker run --rm -v ${{ github.workspace }}:/app -w /app python:${{ matrix.python-version }} bash -c "
python -m pip install --upgrade pip setuptools wheel tox
python -m pip install '.[test]'
pytest --cov-branch --cov-context=test --cov=.
"
- name: Run tests
if: ${{ !matrix.use-docker }}
run: |
python -m pip install --upgrade pip setuptools wheel tox
python -m pip install '.[test]'
pytest --cov-branch --cov-context=test --cov=.
- name: Set artifact name
shell: bash
run: |
ARTIFACT_NAME="coverage-${{ runner.os }}-py-${{ matrix.python-version }}"
ARTIFACT_NAME="${ARTIFACT_NAME//./}"
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> "$GITHUB_ENV"
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
include-hidden-files: true
if-no-files-found: error
name: ${{ env.ARTIFACT_NAME }}
path: .coverage
retention-days: 1
coverage:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: 3.13
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: downloaded_artifacts
- name: Clean up temporary artifacts
uses: geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b # v5.1.0
with:
name: coverage-*
- name: Install dependencies
run: pip install coverage
- name: Combine coverage.py
run: |
coverage combine $(find downloaded_artifacts/ -type f | xargs)
coverage xml
coverage html
coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
cp coverage.xml htmlcov/coverage.xml
cp .coverage htmlcov/.coverage
- name: Upload single coverage artifact
uses: actions/upload-artifact@v4
with:
include-hidden-files: true
if-no-files-found: error
name: htmlcov
path: htmlcov
# Retention days for main branch is 90 days, for other branches is 1 day
retention-days: ${{ github.ref == 'refs/heads/master' && 90 || 1 }}
release:
needs: [test, coverage]
name: PyPI
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install build dependencies
run: |
python -m pip install -U setuptools wheel setuptools-scm
- name: Build
run: |
python setup.py --quiet build check sdist bdist_wheel
ls -alh ./dist/
- name: Publish to PyPI - on tag
if: startsWith(github.ref, 'refs/tags/')
uses: pypa/gh-action-pypi-publish@release/v1