-
Notifications
You must be signed in to change notification settings - Fork 3
208 lines (166 loc) · 4.95 KB
/
workflow.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
196
197
198
199
200
201
202
203
204
205
206
207
208
name: Extension-Template
on:
push:
branches: [master]
pull_request:
types: [assigned, opened, reopened, synchronize, ready_for_review]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache tests
uses: actions/cache@v4
with:
path: |
poetry.lock
pyproject.toml
key: tests-${{ github.sha }}
- name: Cache build
id: cache-build
uses: actions/cache@v4
with:
path: dist
key: build-${{ hashFiles('poetry.lock') }}-${{ github.sha }}
- name: Install Poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9.20
cache: 'poetry'
- name: Install dependencies
run: poetry install --all-extras --sync
- name: Build package
if: steps.cache-build.outputs.cache-hit != 'true'
run: poetry build
lint:
runs-on: ubuntu-24.04
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore tests
uses: actions/cache@v4
with:
path: |
poetry.lock
pyproject.toml
key: tests-${{ github.sha }}
- name: Install Poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9.20
cache: 'poetry'
- name: Lint files
run: |
poetry run codespell .
poetry run isort .
poetry run ruff check .
poetry run yamllint .github/. src/. tests/.
poetry run mdformat --check $(git ls-files "*.md")
poetry run shellcheck $(git ls-files "*.sh")
test:
runs-on: ubuntu-24.04
needs: [build]
strategy:
matrix:
python: [3.9.x, 3.10.x, 3.11.x, 3.12.x, 3.13.x]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore tests
uses: actions/cache@v4
with:
path: |
poetry.lock
pyproject.toml
key: tests-${{ github.sha }}
- name: Install Tox
run: pipx install tox
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Test python files
run: tox -r -e py
dist:
runs-on: ubuntu-24.04
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore tests
uses: actions/cache@v4
with:
path: |
poetry.lock
pyproject.toml
key: tests-${{ github.sha }}
- name: Install Tox
run: pipx install tox
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9.20
- name: Check built package
run: tox -r -e dist
check-version-and-changelog:
runs-on: ubuntu-22.04
needs: [lint, test, dist] # Last job to run
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all the tags
- name: Install Poetry
run: pipx install poetry
- name: Check version number has been properly updated
run: ./.github/is-version-number-acceptable.sh
# GitHub Actions does not have a halt job option, to stop from deploying if
# no functional changes were found. We build a separate job to substitute the
# halt option. The `deploy` job is dependent on the output of the
# `check-for-functional-changes`job.
check-for-functional-changes:
runs-on: ubuntu-22.04
needs: [check-version-and-changelog]
# Only triggered for the `master` branch
if: github.ref == 'refs/heads/master'
outputs:
status: ${{ steps.stop-early.outputs.status }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all the tags
- id: stop-early
run: |
if "./.github/has-functional-changes.sh" ; then
echo "::set-output name=status::success"
fi
deploy:
runs-on: ubuntu-22.04
needs: [check-for-functional-changes]
if: needs.check-for-functional-changes.outputs.status == 'success'
env:
PYPI_USERNAME: __token__
PYPI_PASSWORD: ${{ secrets.PYPI_TOKEN_OPENFISCA_BOT }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all the tags
- name: Install Poetry
run: pipx install poetry
- name: Restore build
uses: actions/cache@v4
with:
path: dist
key: build-${{ hashFiles('poetry.lock') }}-${{ github.sha }}
- name: Upload dist to PyPi
run: poetry publish --username $PYPI_USERNAME --password $PYPI_PASSWORD
- name: Publish a git tag
run: |
git tag $(poetry version --short)
git push --tags # update the repository version