-
-
Notifications
You must be signed in to change notification settings - Fork 29
195 lines (162 loc) · 5.17 KB
/
tests.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
189
190
191
192
193
194
195
# Run scriv CI
name: "Test Suite"
on:
push:
pull_request:
workflow_dispatch:
defaults:
run:
shell: bash
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
PANDOC_VER: 2.18
jobs:
tests:
name: "Test on ${{ matrix.os }}"
runs-on: "${{ matrix.os }}-latest"
strategy:
fail-fast: false
matrix:
os:
- ubuntu
- macos
- windows
steps:
- name: "Check out the repo"
uses: "actions/checkout@v4"
- name: "Set up Python"
id: "setup-python"
uses: "actions/setup-python@v5"
with:
# The last listed Python version is the default.
python-version: |
pypy-3.9
3.7
3.8
3.9
3.10
3.11
3.12
- name: "Restore cache"
id: "restore-cache"
uses: "actions/cache@v3"
with:
path: |
.tox/
.venv/
key: "cache-python-${{ steps.setup-python.outputs.python-version }}-os-${{ runner.os }}-hash-${{ hashFiles('tox.ini', 'requirements/*.txt') }}"
- name: "Identify venv path"
shell: "bash"
run: "echo 'venv-path=${{ runner.os == 'Windows' && '.venv/Scripts' || '.venv/bin' }}' >> $GITHUB_ENV"
- name: "Install dependencies"
if: "steps.restore-cache.outputs.cache-hit == false"
run: |
python -m venv .venv
${{ env.venv-path }}/python -m pip install -U setuptools
${{ env.venv-path }}/python -m pip install -r requirements/tox.txt
- name: "Install pandoc on Linux"
# sudo apt-get pandoc: will install a version from 2018!
if: runner.os == 'Linux'
run: |
wget -nv -O pandoc.deb https://github.com/jgm/pandoc/releases/download/${PANDOC_VER}/pandoc-${PANDOC_VER}-1-amd64.deb
sudo apt install ./pandoc.deb
- name: "Install pandoc on Mac"
if: runner.os == 'macOS'
run: |
brew install pandoc
- name: "Install pandoc on Windows"
if: runner.os == 'Windows'
run: |
choco install -y -r --no-progress pandoc
- name: "Run tox"
run: |
${{ env.venv-path }}/python -m tox -m ci-tests
- name: "Upload coverage data"
uses: actions/upload-artifact@v4
with:
name: covdata-${{ matrix.os }}
path: .coverage.*
coverage:
name: Coverage
needs: tests
runs-on: ubuntu-latest
steps:
- name: "Check out the repo"
uses: "actions/checkout@v4"
- name: "Set up Python"
uses: "actions/setup-python@v5"
with:
python-version: "3.12"
cache: pip
cache-dependency-path: 'requirements/*.txt'
- name: "Install dependencies"
run: |
python -m pip install -U setuptools
python -m pip install -r requirements/tox.txt
- name: "Download coverage data"
uses: actions/download-artifact@v4
with:
pattern: covdata-*
merge-multiple: true
- name: "Combine and report"
run: |
python -m tox -e coverage
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "total=$TOTAL" >> $GITHUB_ENV
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
- name: "Make badge"
if: (github.repository == 'nedbat/scriv') && (github.ref == 'refs/heads/main')
# https://gist.github.com/nedbat/5a304c1c779d4bcc57be95f847e9327f
uses: schneegans/[email protected]
with:
# GIST_TOKEN is a GitHub personal access token with scope "gist".
# https://github.com/settings/tokens/969369418
auth: ${{ secrets.GIST_TOKEN }}
gistID: 5a304c1c779d4bcc57be95f847e9327f
filename: covbadge.json
label: Coverage
message: ${{ env.total }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.total }}
docs:
name: Docs
runs-on: ubuntu-latest
steps:
- name: "Check out the repo"
uses: "actions/checkout@v4"
- name: "Set up Python"
uses: "actions/setup-python@v5"
with:
python-version: "3.7"
cache: pip
cache-dependency-path: 'requirements/*.txt'
- name: "Install dependencies"
run: |
python -m pip install -U setuptools
python -m pip install -r requirements/tox.txt
- name: "Build docs"
run: |
python -m tox -e docs
quality:
name: Linters etc
runs-on: ubuntu-latest
steps:
- name: "Check out the repo"
uses: "actions/checkout@v4"
- name: "Set up Python"
uses: "actions/setup-python@v5"
with:
python-version: "3.7"
cache: pip
cache-dependency-path: 'requirements/*.txt'
- name: "Install dependencies"
run: |
python -m pip install -U setuptools
python -m pip install -r requirements/tox.txt
- name: "Linters etc"
run: |
python -m tox -e quality