1010 - main
1111
1212jobs :
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
1643
1744 strategy :
1845 fail-fast : false
@@ -23,38 +50,42 @@ jobs:
2350 - name : checkout code
2451 uses : actions/checkout@v4
2552
26- - name : set up python 3.11
27- uses : actions/setup-python@v3
53+ - name : set up python 3.13
54+ uses : actions/setup-python@v5
2855 with :
29- python-version : 3.11
56+ python-version : " 3.13 "
3057
31- - name : install ruff
32- if : matrix.tool == 'ruff'
33- run : pip install ruff==0.14.2
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-
3465
3566 - name : run ruff linter src directory
3667 if : matrix.tool == 'ruff'
37- run : ruff check --config pyproject.toml hololinked
68+ run : |
69+ source .venv/bin/activate
70+ ruff check --config pyproject.toml hololinked
3871
3972 - name : run ruff linter tests directory
4073 if : matrix.tool == 'ruff'
41- run : ruff check --config pyproject.toml tests/*.py tests/things/*.py tests/helper-scripts/*.py
42-
43- - name : install ruff
44- if : matrix.tool == 'ruff-extensive'
45- run : pip install ruff
74+ run : |
75+ source .venv/bin/activate
76+ ruff check --config pyproject.toml tests/*.py tests/things/*.py tests/helper-scripts/*.py
4677
4778 - name : run ruff linter src directory
4879 if : matrix.tool == 'ruff-extensive'
49- run : ruff check --config ruff.toml hololinked/client
50-
51- - name : install ty
52- if : matrix.tool == 'ty'
53- run : pip install ty==0.0.24
80+ run : |
81+ source .venv/bin/activate
82+ ruff check --config ruff.toml hololinked/client
5483
5584 - name : run ty type checker
5685 if : matrix.tool == 'ty'
57- run : ty check hololinked/client
86+ run : |
87+ source .venv/bin/activate
88+ ty check hololinked/client
5889
5990 scan :
6091 name : security scan (${{ matrix.tool }})
@@ -73,25 +104,32 @@ jobs:
73104 fetch-depth : 0
74105
75106 # ---------------- Bandit branch ----------------
76- - name : set up python 3.11
107+ - name : set up python 3.13
77108 if : matrix.tool == 'bandit'
78109 uses : actions/setup-python@v5
79110 with :
80- python-version : " 3.11 "
111+ python-version : " 3.13 "
81112
82- - name : install bandit
113+ - name : restore virtual environment
83114 if : matrix.tool == 'bandit'
84- 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-
85121
86122 - name : run bandit scan
87123 if : matrix.tool == 'bandit'
88124 run : |
125+ source .venv/bin/activate
89126 bandit -c pyproject.toml -r hololinked/ -b .bandit-baseline.json
90127 # this is the step that will fail the job if new issues are found
91128
92129 - name : generate JSON report
93130 if : matrix.tool == 'bandit'
94131 run : |
132+ source .venv/bin/activate
95133 echo "Rerunning to generate bandit report in JSON format..."
96134 bandit -c pyproject.toml -r hololinked/ -f json -b .bandit-baseline.json -o bandit-report.json
97135
@@ -105,6 +143,7 @@ jobs:
105143 - name : display existing issues, which have already been accounted
106144 if : matrix.tool == 'bandit'
107145 run : |
146+ source .venv/bin/activate
108147 echo "Rerunning to display existing issues which are included in the baseline..."
109148 bandit -c pyproject.toml -r hololinked/ || true
110149
0 commit comments