Skip to content

Commit 2a7f3ec

Browse files
authored
Ty client folder (#177)
* install ty and and separate ruff.toml with more settings * update client folder files * bug fixes * use a shared venv cache
1 parent bb9d150 commit 2a7f3ec

19 files changed

Lines changed: 1485 additions & 717 deletions

.github/workflows/ci-pipeline.yml

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,82 @@ on:
1010
- main
1111

1212
jobs:
13+
setup-venv:
14+
name: set up shared virtual environment
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: set up python 3.13
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.13"
25+
26+
- name: install uv
27+
run: curl -LsSf https://astral.sh/uv/install.sh | sh
28+
29+
- name: cache virtual environment
30+
uses: actions/cache@v4
31+
with:
32+
path: .venv
33+
key: ${{ runner.os }}-shared-venv-${{ github.run_id }}
34+
35+
- name: sync virtual environment
36+
run: |
37+
uv sync --group all
38+
1339
codestyle:
1440
name: ruff codestyle check/linting
1541
runs-on: ubuntu-latest
42+
needs: setup-venv
43+
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
tool: [ruff, ty, ruff-extensive]
1648

1749
steps:
1850
- name: checkout code
1951
uses: actions/checkout@v4
2052

21-
- name: set up python 3.11
22-
uses: actions/setup-python@v3
53+
- name: set up python 3.13
54+
uses: actions/setup-python@v5
2355
with:
24-
python-version: 3.11
56+
python-version: "3.13"
2557

26-
- name: install ruff
27-
run: pip install ruff
58+
- name: restore virtual environment
59+
uses: actions/cache@v4
60+
with:
61+
path: .venv
62+
key: ${{ runner.os }}-shared-venv-${{ github.run_id }}
63+
restore-keys: |
64+
${{ runner.os }}-shared-venv-
2865
2966
- name: run ruff linter src directory
30-
run: ruff check hololinked
67+
if: matrix.tool == 'ruff'
68+
run: |
69+
source .venv/bin/activate
70+
ruff check --config pyproject.toml hololinked
3171
3272
- name: run ruff linter tests directory
33-
run: ruff check tests/*.py tests/things/*.py tests/helper-scripts/*.py
73+
if: matrix.tool == 'ruff'
74+
run: |
75+
source .venv/bin/activate
76+
ruff check --config pyproject.toml tests/*.py tests/things/*.py tests/helper-scripts/*.py
77+
78+
- name: run ruff linter src directory
79+
if: matrix.tool == 'ruff-extensive'
80+
run: |
81+
source .venv/bin/activate
82+
ruff check --config ruff.toml hololinked/client
83+
84+
- name: run ty type checker
85+
if: matrix.tool == 'ty'
86+
run: |
87+
source .venv/bin/activate
88+
ty check hololinked/client
3489
3590
scan:
3691
name: security scan (${{ matrix.tool }})
@@ -49,25 +104,32 @@ jobs:
49104
fetch-depth: 0
50105

51106
# ---------------- Bandit branch ----------------
52-
- name: set up python 3.11
107+
- name: set up python 3.13
53108
if: matrix.tool == 'bandit'
54109
uses: actions/setup-python@v5
55110
with:
56-
python-version: "3.11"
111+
python-version: "3.13"
57112

58-
- name: install bandit
113+
- name: restore virtual environment
59114
if: matrix.tool == 'bandit'
60-
run: pip install bandit
115+
uses: actions/cache@v4
116+
with:
117+
path: .venv
118+
key: ${{ runner.os }}-shared-venv-${{ github.run_id }}
119+
restore-keys: |
120+
${{ runner.os }}-shared-venv-
61121
62122
- name: run bandit scan
63123
if: matrix.tool == 'bandit'
64124
run: |
125+
source .venv/bin/activate
65126
bandit -c pyproject.toml -r hololinked/ -b .bandit-baseline.json
66127
# this is the step that will fail the job if new issues are found
67128
68129
- name: generate JSON report
69130
if: matrix.tool == 'bandit'
70131
run: |
132+
source .venv/bin/activate
71133
echo "Rerunning to generate bandit report in JSON format..."
72134
bandit -c pyproject.toml -r hololinked/ -f json -b .bandit-baseline.json -o bandit-report.json
73135
@@ -81,6 +143,7 @@ jobs:
81143
- name: display existing issues, which have already been accounted
82144
if: matrix.tool == 'bandit'
83145
run: |
146+
source .venv/bin/activate
84147
echo "Rerunning to display existing issues which are included in the baseline..."
85148
bandit -c pyproject.toml -r hololinked/ || true
86149

hololinked/client/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""expose client objects per protocol using the Thing Description."""
2+
13
from ..config import global_config # noqa: F401
24
from .factory import ClientFactory as ClientFactory
35
from .proxy import ObjectProxy as ObjectProxy

0 commit comments

Comments
 (0)