1- name : frequenz-channels-python
1+ name : CI
22
33on :
44 merge_group :
55 pull_request :
66 push :
7+ # We need to explicitly include tags because otherwise when adding
8+ # `branches-ignore` it will only trigger on branches.
79 tags :
810 - ' *'
911 branches-ignore :
1416 workflow_dispatch :
1517
1618env :
17- DEFAULT_PYTHON_VERSION : " 3.11"
19+ # Please make sure this version is included in the `matrix`, as the
20+ # `matrix` section can't use `env`, so it must be entered manually
21+ DEFAULT_PYTHON_VERSION : ' 3.11'
22+ # It would be nice to be able to also define a DEFAULT_UBUNTU_VERSION
23+ # but sadly `env` can't be used either in `runs-on`.
1824
1925jobs :
20- test :
26+ nox :
27+ name : Test with nox
2128 strategy :
29+ fail-fast : false
2230 matrix :
2331 os :
2432 - ubuntu-20.04
25- python-version :
33+ python :
2634 - " 3.11"
2735 runs-on : ${{ matrix.os }}
2836
2937 steps :
30- - name : Fetch sources
31- uses : actions/checkout@v3
32-
33- - name : Set up Python
34- uses : actions/setup-python@v4
35- with :
36- python-version : ${{ matrix.python-version }}
37-
38- - uses : actions/cache@v3
39- with :
40- path : ~/.cache/pip
41- key : ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('pyproject.toml') }}
42- restore-keys : |
43- ${{ runner.os }}-${{ matrix.python-version }}-pip-
44-
45- - name : Install required Python packages
46- run : |
47- python -m pip install --upgrade pip
48- python -m pip install nox
49-
50- - name : run nox
51- run : nox
52- timeout-minutes : 10
53-
54- build-dist :
38+ - name : Fetch sources
39+ uses : actions/checkout@v3
40+
41+ - name : Set up Python
42+ uses : actions/setup-python@v4
43+ with :
44+ python-version : ${{ matrix.python }}
45+ cache : ' pip'
46+
47+ - name : Install required Python packages
48+ run : |
49+ python -m pip install --upgrade pip
50+ python -m pip install -e .[dev-noxfile]
51+
52+ - name : Run nox
53+ # To speed things up a bit we use the speciall ci_checks_max session
54+ # that uses the same venv to run multiple linting sessions
55+ run : nox -e ci_checks_max pytest_min
56+ timeout-minutes : 10
57+
58+ build :
59+ name : Build distribution packages
5560 runs-on : ubuntu-20.04
5661 steps :
5762 - name : Fetch sources
@@ -61,23 +66,25 @@ jobs:
6166 uses : actions/setup-python@v4
6267 with :
6368 python-version : ${{ env.DEFAULT_PYTHON_VERSION }}
69+ cache : ' pip'
6470
65- - name : Install build dependencies
71+ - name : Install required Python packages
6672 run : |
6773 python -m pip install -U pip
6874 python -m pip install -U build
6975
7076 - name : Build the source and binary distribution
7177 run : python -m build
7278
73- - name : Upload dist files
79+ - name : Upload distribution files
7480 uses : actions/upload-artifact@v3
7581 with :
76- name : frequenz-channels-python- dist
82+ name : dist-packages
7783 path : dist/
7884 if-no-files-found : error
7985
80- test-generate-docs :
86+ test-docs :
87+ name : Test documentation website generation
8188 if : github.event_name != 'push'
8289 runs-on : ubuntu-20.04
8390 steps :
@@ -91,11 +98,12 @@ jobs:
9198 uses : actions/setup-python@v4
9299 with :
93100 python-version : ${{ env.DEFAULT_PYTHON_VERSION }}
101+ cache : ' pip'
94102
95103 - name : Install build dependencies
96104 run : |
97105 python -m pip install -U pip
98- python -m pip install .[docs ]
106+ python -m pip install .[dev-mkdocs ]
99107
100108 - name : Generate the documentation
101109 env :
@@ -107,12 +115,13 @@ jobs:
107115 - name : Upload site
108116 uses : actions/upload-artifact@v3
109117 with :
110- name : frequenz-channels-python -site
118+ name : docs -site
111119 path : site/
112120 if-no-files-found : error
113121
114122 publish-docs :
115- needs : ["test", "build-dist"]
123+ name : Publish documentation website to GitHub pages
124+ needs : ["nox", "build"]
116125 if : github.event_name == 'push'
117126 runs-on : ubuntu-20.04
118127 permissions :
@@ -168,12 +177,13 @@ jobs:
168177 uses : actions/setup-python@v4
169178 with :
170179 python-version : ${{ env.DEFAULT_PYTHON_VERSION }}
180+ cache : ' pip'
171181
172182 - name : Install build dependencies
173183 if : steps.mike-metadata.outputs.version
174184 run : |
175185 python -m pip install -U pip
176- python -m pip install .[docs ]
186+ python -m pip install .[dev-mkdocs ]
177187
178188 - name : Fetch the gh-pages branch
179189 if : steps.mike-metadata.outputs.version
@@ -188,20 +198,21 @@ jobs:
188198 mike deploy --push --update-aliases "$VERSION" $ALIASES
189199
190200 create-github-release :
201+ name : Create GitHub release
191202 needs : ["publish-docs"]
192203 # Create a release only on tags creation
193- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
204+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v ')
194205 permissions :
195206 # We need write permissions on contents to create GitHub releases and on
196207 # discussions to create the release announcement in the discussion forums
197208 contents : write
198209 discussions : write
199210 runs-on : ubuntu-20.04
200211 steps :
201- - name : Download dist files
212+ - name : Download distribution files
202213 uses : actions/download-artifact@v3
203214 with :
204- name : frequenz-channels-python- dist
215+ name : dist-packages
205216 path : dist
206217
207218 - name : Download RELEASE_NOTES.md
@@ -225,7 +236,6 @@ jobs:
225236 if echo "$REF_NAME" | grep -- -; then extra_opts=" --prerelease"; fi
226237 gh release create \
227238 -R "$REPOSITORY" \
228- --discussion-category announcements \
229239 --notes-file RELEASE_NOTES.md \
230240 --generate-notes \
231241 $extra_opts \
@@ -237,17 +247,18 @@ jobs:
237247 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
238248
239249 publish-to-pypi :
250+ name : Publish packages to PyPI
240251 needs : ["create-github-release"]
241252 runs-on : ubuntu-20.04
242253 permissions :
243254 # For trusted publishing. See:
244255 # https://blog.pypi.org/posts/2023-04-20-introducing-trusted-publishers/
245256 id-token : write
246257 steps :
247- - name : Download dist files
258+ - name : Download distribution files
248259 uses : actions/download-artifact@v3
249260 with :
250- name : frequenz-channels-python- dist
261+ name : dist-packages
251262 path : dist
252263
253264 - name : Publish the Python distribution to PyPI
0 commit comments