Skip to content

Commit 6c176c1

Browse files
authored
Merge pull request #96 from labthings/ci-improvements
Use pinned dependencies for testing and update CI script.
2 parents b446f8d + 7d877b9 commit 6c176c1

File tree

8 files changed

+220
-73
lines changed

8 files changed

+220
-73
lines changed

.github/workflows/test.yml

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
mv coverage.lcov base-coverage.lcov
2626
2727
- name: Upload code coverage for base branch
28-
uses: actions/upload-artifact@v3
28+
uses: actions/upload-artifact@v4
2929
with:
3030
name: base-coverage.lcov
3131
path: ./base-coverage.lcov
@@ -34,7 +34,7 @@ jobs:
3434
runs-on: ubuntu-latest
3535
strategy:
3636
matrix:
37-
python: ["3.9", "3.10", "3.11", "3.12"]
37+
python: ["3.10", "3.11", "3.12", "3.13"]
3838

3939
steps:
4040
- uses: actions/checkout@v3
@@ -45,7 +45,7 @@ jobs:
4545
python-version: ${{ matrix.python }}
4646

4747
- name: Install Dependencies
48-
run: pip install -e .[dev,server]
48+
run: pip install -e . -r dev-requirements.txt
4949

5050
- name: Lint with Ruff
5151
run: ruff check .
@@ -57,25 +57,57 @@ jobs:
5757
run: pytest --cov=src --cov-report=lcov
5858

5959
- name: Upload code coverage
60-
uses: actions/upload-artifact@v3
60+
uses: actions/upload-artifact@v4
6161
with:
62-
name: coverage.lcov
62+
name: coverage-${{ matrix.python }}
6363
path: ./coverage.lcov
6464

6565
- name: Analyse with MyPy
6666
run: mypy src
6767

68+
test-with-unpinned-deps:
69+
runs-on: ubuntu-latest
70+
strategy:
71+
matrix:
72+
python: ["3.10", "3.11", "3.12", "3.13"]
73+
74+
steps:
75+
- uses: actions/checkout@v3
76+
77+
- name: Set up Python
78+
uses: actions/setup-python@v4
79+
with:
80+
python-version: ${{ matrix.python }}
81+
82+
- name: Install Dependencies
83+
run: pip install -e .[dev,server]
84+
85+
- name: Lint with Ruff
86+
run: ruff check .
87+
88+
- name: Format with Ruff
89+
if: success() || failure()
90+
run: ruff format --check .
91+
92+
- name: Analyse with MyPy
93+
if: success() || failure()
94+
run: mypy src
95+
96+
- name: Test with pytest
97+
if: success() || failure()
98+
run: pytest --cov=src --cov-report=lcov
99+
68100
coverage:
69101
runs-on: ubuntu-latest
70102
needs: [base_coverage, test]
71103
steps:
72104
- name: Download code coverage report
73-
uses: actions/download-artifact@v3
105+
uses: actions/download-artifact@v4
74106
with:
75-
name: coverage.lcov
107+
name: coverage-3.12
76108

77109
- name: Download code coverage report for base branch
78-
uses: actions/download-artifact@v3
110+
uses: actions/download-artifact@v4
79111
with:
80112
name: base-coverage.lcov
81113

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ You can install this repository with `pip`, either clone it and run `pip install
3434

3535
The code is linted with `ruff .`, type checked with `mypy src`, and tested with `pytest`. These all run in CI with GitHub Actions. The codebase is not even `v0.1` yet so it's still subject to summary rearrangement.
3636

37+
Dependencies are defined in `pyproject.toml` and can be compiled to `dev-requirements.txt` with:
38+
```
39+
uv pip compile --extra dev --extra server pyproject.toml --output-file dev-requirements.txt
40+
```
41+
If you're not using `uv`, just regular `pip-compile` from `pip-tools` will do the same thing.
42+
43+
All changes to the codebase should go via pull requests, and should only be merged once all the checks in the `test` job are passing. It is preferable to merge code where the `test-with-unpinned-dependencies` job fails, and deal with the dependency issues in another PR, particularly where the required changes are distinct from the code in the PR.
44+
3745
## Demo
3846

3947
See the [examples folder](./examples/) for a runnable demo.

dev-requirements.txt

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# This file was autogenerated by uv via the following command:
2+
# uv pip compile --extra dev --extra server pyproject.toml --output-file dev-requirements.txt
3+
annotated-types==0.7.0
4+
# via pydantic
5+
anyio==4.8.0
6+
# via
7+
# labthings-fastapi (pyproject.toml)
8+
# httpx
9+
# starlette
10+
# watchfiles
11+
attrs==25.1.0
12+
# via
13+
# jsonschema
14+
# referencing
15+
certifi==2025.1.31
16+
# via
17+
# httpcore
18+
# httpx
19+
click==8.1.8
20+
# via
21+
# rich-toolkit
22+
# typer
23+
# uvicorn
24+
colorama==0.4.6
25+
# via
26+
# click
27+
# pytest
28+
# uvicorn
29+
coverage==7.6.12
30+
# via pytest-cov
31+
dnspython==2.7.0
32+
# via email-validator
33+
email-validator==2.2.0
34+
# via fastapi
35+
fastapi==0.115.11
36+
# via labthings-fastapi (pyproject.toml)
37+
fastapi-cli==0.0.7
38+
# via fastapi
39+
h11==0.14.0
40+
# via
41+
# httpcore
42+
# uvicorn
43+
httpcore==1.0.7
44+
# via httpx
45+
httptools==0.6.4
46+
# via uvicorn
47+
httpx==0.28.1
48+
# via
49+
# labthings-fastapi (pyproject.toml)
50+
# fastapi
51+
idna==3.10
52+
# via
53+
# anyio
54+
# email-validator
55+
# httpx
56+
ifaddr==0.2.0
57+
# via zeroconf
58+
iniconfig==2.0.0
59+
# via pytest
60+
itsdangerous==2.2.0
61+
# via fastapi
62+
jinja2==3.1.6
63+
# via fastapi
64+
jsonschema==4.23.0
65+
# via labthings-fastapi (pyproject.toml)
66+
jsonschema-specifications==2024.10.1
67+
# via jsonschema
68+
markdown-it-py==3.0.0
69+
# via rich
70+
markupsafe==3.0.2
71+
# via jinja2
72+
mdurl==0.1.2
73+
# via markdown-it-py
74+
mypy==1.15.0
75+
# via labthings-fastapi (pyproject.toml)
76+
mypy-extensions==1.0.0
77+
# via mypy
78+
numpy==2.2.3
79+
# via labthings-fastapi (pyproject.toml)
80+
orjson==3.10.15
81+
# via fastapi
82+
packaging==24.2
83+
# via pytest
84+
pluggy==1.5.0
85+
# via pytest
86+
pydantic==2.10.6
87+
# via
88+
# labthings-fastapi (pyproject.toml)
89+
# fastapi
90+
# pydantic-extra-types
91+
# pydantic-settings
92+
pydantic-core==2.27.2
93+
# via pydantic
94+
pydantic-extra-types==2.10.2
95+
# via fastapi
96+
pydantic-settings==2.8.1
97+
# via fastapi
98+
pygments==2.19.1
99+
# via rich
100+
pytest==7.4.4
101+
# via
102+
# labthings-fastapi (pyproject.toml)
103+
# pytest-cov
104+
pytest-cov==6.0.0
105+
# via labthings-fastapi (pyproject.toml)
106+
python-dotenv==1.0.1
107+
# via
108+
# pydantic-settings
109+
# uvicorn
110+
python-multipart==0.0.20
111+
# via fastapi
112+
pyyaml==6.0.2
113+
# via
114+
# fastapi
115+
# uvicorn
116+
referencing==0.36.2
117+
# via
118+
# jsonschema
119+
# jsonschema-specifications
120+
# types-jsonschema
121+
rich==13.9.4
122+
# via
123+
# rich-toolkit
124+
# typer
125+
rich-toolkit==0.13.2
126+
# via fastapi-cli
127+
rpds-py==0.23.1
128+
# via
129+
# jsonschema
130+
# referencing
131+
ruff==0.9.10
132+
# via labthings-fastapi (pyproject.toml)
133+
shellingham==1.5.4
134+
# via typer
135+
sniffio==1.3.1
136+
# via anyio
137+
starlette==0.46.0
138+
# via fastapi
139+
typer==0.15.2
140+
# via fastapi-cli
141+
types-jsonschema==4.23.0.20241208
142+
# via labthings-fastapi (pyproject.toml)
143+
typing-extensions==4.12.2
144+
# via
145+
# labthings-fastapi (pyproject.toml)
146+
# anyio
147+
# fastapi
148+
# mypy
149+
# pydantic
150+
# pydantic-core
151+
# pydantic-extra-types
152+
# referencing
153+
# rich-toolkit
154+
# typer
155+
ujson==5.10.0
156+
# via fastapi
157+
uvicorn==0.34.0
158+
# via
159+
# fastapi
160+
# fastapi-cli
161+
watchfiles==1.0.4
162+
# via uvicorn
163+
websockets==15.0.1
164+
# via uvicorn
165+
zeroconf==0.146.1
166+
# via labthings-fastapi (pyproject.toml)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = [
66
]
77
description = "A test implementation of LabThings using FastAPI"
88
readme = "README.md"
9-
requires-python = ">=3.9"
9+
requires-python = ">=3.10"
1010
classifiers = [
1111
"Programming Language :: Python :: 3",
1212
"License :: OSI Approved :: MIT License",

requirements.txt

Lines changed: 0 additions & 57 deletions
This file was deleted.

src/labthings_fastapi/actions/invocation_model.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ def generate_message(cls, data: Any):
4343
# it will cause 500 errors when retrieving
4444
# the invocation.
4545
# This way, you can find and fix the source.
46-
data.message = (
47-
f"Error constructing message ({e}) " f"from {data!r}."
48-
)
46+
data.message = f"Error constructing message ({e}) from {data!r}."
4947
return data
5048

5149

src/labthings_fastapi/thing_description/validation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def validate_thing_description(td: dict) -> None:
2727
jsonschema.validate(instance=td, schema=schema)
2828
validated_td = time.time()
2929
logging.info(
30-
f"Thing Description validated OK (schema load: {loaded_schema-start:.1f}s, "
31-
f"schema validation: {validated_schema-loaded_schema:.1f}s, TD validation: "
32-
f"{validated_td-validated_schema:.1f}s)"
30+
f"Thing Description validated OK (schema load: {loaded_schema - start:.1f}s, "
31+
f"schema validation: {validated_schema - loaded_schema:.1f}s, TD validation: "
32+
f"{validated_td - validated_schema:.1f}s)"
3333
)

src/labthings_fastapi/types/numpy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def np_to_listoflists(arr: np.ndarray) -> NestedListOfNumbers:
6060
NB this will not be quick! Large arrays will be much better
6161
serialised by dumping to base64 encoding or similar.
6262
"""
63-
return arr.tolist()
63+
return arr.tolist() # type: ignore[return-value]
6464

6565

6666
def listoflists_to_np(lol: Union[NestedListOfNumbers, np.ndarray]) -> np.ndarray:

0 commit comments

Comments
 (0)