Skip to content

Commit da55cfd

Browse files
committed
Add full action suite
1 parent d70288b commit da55cfd

File tree

3 files changed

+172
-6
lines changed

3 files changed

+172
-6
lines changed

.github/workflows/verify.yml

Lines changed: 163 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,163 @@ jobs:
2424
- name: Run ShellCheck
2525
uses: ludeeus/action-shellcheck@master
2626

27+
ruff:
28+
runs-on: ubuntu-latest
29+
name: Ruff check and force
30+
steps:
31+
- name: Check out committed code
32+
uses: actions/checkout@v4
33+
with:
34+
persist-credentials: false
35+
- name: Prepare python
36+
run: |
37+
pip install uv
38+
uv venv --seed venv
39+
. venv/bin/activate
40+
uv pip install ruff -r requirements.txt -r requirements-test.txt
41+
- name: Ruff (with fix)
42+
run: |
43+
. venv/bin/activate
44+
ruff check plugwise/ tests/
45+
- name: If needed, commit ruff changes to the pull request
46+
if: failure()
47+
run: |
48+
. venv/bin/activate
49+
ruff format plugwise/ tests/
50+
git config --global user.name 'autoruff'
51+
git config --global user.email '[email protected]'
52+
git remote set-url origin https://x-access-token:${{ secrets.PAT_CT }}@github.com/$GITHUB_REPOSITORY
53+
git checkout $GITHUB_HEAD_REF
54+
git commit -am "fixup: ${GITHUB_REF##*/} Python code fixed using ruff"
55+
git push origin ${GITHUB_REF##*/}
56+
57+
commitcheck:
58+
runs-on: ubuntu-latest
59+
name: Check commit
60+
needs:
61+
- ruff
62+
steps:
63+
- name: Check out committed code
64+
uses: actions/checkout@v4
65+
- name: Prepare python
66+
run: |
67+
pip install uv
68+
uv venv --seed venv
69+
. venv/bin/activate
70+
uv pip install pre-commit -r requirements.txt -r requirements-test.txt
71+
pre-commit install
72+
pre-commit install-hooks
73+
- name: Verify commit
74+
run: |
75+
. venv/bin/activate
76+
pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual pylint
77+
- name: Biome lint
78+
run: |
79+
. venv/bin/activate
80+
mkdir -p ./tmp && curl -sL "https://github.com/biomejs/biome/releases/latest/download/biome-linux-x64" -o ./tmp/biome && chmod +x ./tmp/biome
81+
pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual biome
82+
- name: Lint markdown files
83+
run: |
84+
. venv/bin/activate
85+
pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual markdownlint
86+
87+
pytest:
88+
runs-on: ubuntu-latest
89+
name: Run pytest using Python ${{ matrix.python-version }}
90+
needs:
91+
- ruff
92+
- commitcheck
93+
strategy:
94+
matrix:
95+
python-version: ["3.13"]
96+
steps:
97+
- name: Check out committed code
98+
uses: actions/checkout@v4
99+
- name: Prepare python
100+
run: |
101+
pip install uv
102+
uv venv --seed venv
103+
. venv/bin/activate
104+
uv pip install -r requirements.txt -r requirements-test.txt
105+
- name: Run all tests
106+
run: |
107+
. venv/bin/activate
108+
pytest --log-level info tests/*.py --cov='.'
109+
- name: Upload coverage artifact
110+
uses: actions/upload-artifact@v4
111+
with:
112+
name: coverage-${{ matrix.python-version }}
113+
path: .coverage
114+
if-no-files-found: error
115+
include-hidden-files: true
116+
117+
mypy:
118+
runs-on: ubuntu-latest
119+
name: Run mypy
120+
needs:
121+
- ruff
122+
- pytest
123+
steps:
124+
- name: Check out committed code
125+
uses: actions/checkout@v4
126+
with:
127+
persist-credentials: false
128+
- name: Prepare python
129+
run: |
130+
pip install uv
131+
uv venv --seed venv
132+
. venv/bin/activate
133+
uv pip install -r requirements.txt -r requirements-test.txt
134+
- name: Run mypy
135+
run: |
136+
. venv/bin/activate
137+
pip list | grep -i mypy
138+
mypy plugwise/
139+
140+
coverage:
141+
name: Process test coverage
142+
runs-on: ubuntu-latest
143+
needs:
144+
- ruff
145+
- pytest
146+
- mypy
147+
steps:
148+
- name: Check out committed code
149+
uses: actions/checkout@v4
150+
- name: Restore cached environment
151+
id: cache-reuse
152+
uses: plugwise/gh-actions/restore-venv@v1
153+
with:
154+
cache-key: ${{ needs.cache.outputs.cache-key }}
155+
python-version: ${{ env.DEFAULT_PYTHON }}
156+
venv-dir: ${{ env.VENV }}
157+
precommit-home: ${{ env.PRE_COMMIT_HOME }}
158+
- name: Download all coverage artifacts
159+
uses: actions/download-artifact@v4
160+
- name: Combine coverage results
161+
run: |
162+
. venv/bin/activate
163+
coverage combine coverage*/.coverage*
164+
coverage report --fail-under=94
165+
coverage xml
166+
- name: Upload coverage to Codecov
167+
uses: codecov/codecov-action@v5
168+
env:
169+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
170+
27171
test-publishing:
28172
name: Build and publish Python 🐍 distributions 📦 to TestPyPI
29173
runs-on: ubuntu-latest
30174
environment: testpypi
31175
permissions:
32176
id-token: write
177+
needs:
178+
- coverage
179+
- mypy
33180
steps:
34181
- name: Check out committed code
35182
uses: actions/checkout@v4
36-
- name: Prepare uv
183+
- name: Prepare python
37184
run: |
38185
pip install uv
39186
uv venv --seed venv
@@ -68,3 +215,18 @@ jobs:
68215
run: |
69216
. venv/bin/activate
70217
uv publish --publish-url https://test.pypi.org/legacy/
218+
219+
220+
complexity:
221+
name: Process test complexity
222+
runs-on: ubuntu-latest
223+
needs:
224+
- coverage
225+
steps:
226+
- name: Check out committed code
227+
uses: actions/checkout@v4
228+
- name: Run complexity report (click to view details)
229+
run: |
230+
. venv/bin/activate
231+
echo "Showing complexity higher or equal to 'C'"
232+
radon cc plugwise/ tests/ -s -nc --no-assert

requirements-test.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
pytest
2-
pytest-asyncio
3-
aiohttp
1+
ruff==0.12.3
2+
pytest==8.4.1
3+
pytest-asyncio==1.0.0
4+
pytest-cov==6.2.1
5+
coverage==7.9.2
46
aioresponses
7+
aioresponses==0.7.8
8+
aiofiles==24.1.0

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
asyncio
2-
aiohttp
1+
aiohttp==3.12.14
2+
asyncio==3.4.3

0 commit comments

Comments
 (0)