Skip to content

Commit b796b23

Browse files
authored
Merge pull request #107 from MaineDSA/astral-sh/setup-uv
Call reusable CI workflow from bmos
2 parents d3bcd14 + 4eb1cba commit b796b23

File tree

4 files changed

+63
-314
lines changed

4 files changed

+63
-314
lines changed

.github/workflows/python.yml

Lines changed: 17 additions & 288 deletions
Original file line numberDiff line numberDiff line change
@@ -12,297 +12,26 @@ on:
1212
permissions: read-all
1313

1414
jobs:
15-
pytest:
16-
runs-on: ${{ matrix.os }}
17-
strategy:
18-
fail-fast: false
19-
matrix:
20-
python-version:
21-
- '3.11'
22-
- '3.12'
23-
- '3.13'
24-
- '3.14'
25-
os:
26-
- ubuntu-latest
27-
- windows-latest
28-
- macos-latest
29-
resolution:
30-
- highest
31-
- lowest-direct
32-
15+
lint:
16+
uses: bmos/bmos/.github/workflows/python-lint.yml@main
17+
secrets: inherit
18+
with:
19+
src_folder: "src"
20+
python_version: "3.13"
3321
permissions:
22+
# Write
3423
contents: write
35-
36-
steps:
37-
- uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b
38-
with:
39-
egress-policy: audit
40-
41-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
42-
43-
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548
44-
with:
45-
python-version: ${{ matrix.python-version }}
46-
cache: pip
47-
48-
- uses: install-pinned/uv@0590ea0c73b1fdb765847c94975e71c97d9ad0b1
49-
50-
- run: |
51-
uv pip install --system --resolution ${{ matrix.resolution }} -e .[dev]
52-
53-
- run: |
54-
patchright install chrome
55-
56-
- id: cache-pytest
57-
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306
58-
with:
59-
path: .pytest_cache
60-
key: pytest-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.resolution }}-${{ hashFiles('pyproject.toml') }}
61-
62-
- run: pytest
63-
env:
64-
COVERAGE_FILE: ".coverage.${{ matrix.os }}.${{ matrix.python-version }}.${{ matrix.resolution }}"
65-
66-
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
67-
with:
68-
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.resolution }}
69-
path: .coverage.${{ matrix.os }}.${{ matrix.python-version }}.${{ matrix.resolution }}
70-
include-hidden-files: true
71-
72-
ruff-format:
73-
runs-on: ubuntu-latest
74-
75-
steps:
76-
- uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b
77-
with:
78-
disable-sudo: true
79-
egress-policy: block
80-
allowed-endpoints: >
81-
files.pythonhosted.org:443
82-
github.com:443
83-
pypi.org:443
84-
85-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
86-
87-
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548
88-
with:
89-
python-version: 3.13
90-
cache: pip
91-
92-
- uses: install-pinned/uv@0590ea0c73b1fdb765847c94975e71c97d9ad0b1
93-
94-
- run: uv pip install --system .[dev]
95-
96-
- id: cache-ruff
97-
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306
98-
with:
99-
path: .ruff_cache
100-
key: ruff-${{ hashFiles('pyproject.toml') }}
101-
102-
- id: run-ruff
103-
run: ruff format --diff .
104-
105-
ruff-check:
106-
runs-on: ubuntu-latest
107-
108-
permissions:
10924
security-events: write
11025

111-
steps:
112-
- uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b
113-
with:
114-
disable-sudo: true
115-
egress-policy: block
116-
allowed-endpoints: >
117-
api.github.com:443
118-
files.pythonhosted.org:443
119-
github.com:443
120-
pypi.org:443
121-
122-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
123-
124-
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548
125-
with:
126-
python-version: 3.13
127-
cache: pip
128-
129-
- uses: install-pinned/uv@0590ea0c73b1fdb765847c94975e71c97d9ad0b1
130-
131-
- run: uv pip install --system .[dev]
132-
133-
- id: cache-ruff
134-
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306
135-
with:
136-
path: .ruff_cache
137-
key: ruff-${{ hashFiles('pyproject.toml') }}
138-
139-
- id: run-ruff-sarif
140-
run: |
141-
ruff check --output-format=sarif -o results.sarif .
142-
143-
- uses: github/codeql-action/upload-sarif@89a39a4e59826350b863aa6b6252a07ad50cf83e
144-
if: ( success() || failure() ) && contains('["success", "failure"]', steps.run-ruff-sarif.outcome)
145-
with:
146-
sarif_file: results.sarif
147-
148-
- id: run-ruff
149-
if: failure() && contains('["failure"]', steps.run-ruff-sarif.outcome)
150-
run: |
151-
ruff check --output-format=github .
152-
153-
154-
bandit:
155-
runs-on: ubuntu-latest
156-
26+
test:
27+
uses: bmos/bmos/.github/workflows/python-test.yml@main
28+
needs: lint
29+
secrets: inherit
30+
with:
31+
src_folder: "src"
32+
test_folder: "tests"
33+
python_version: "['3.11', '3.12', '3.13', '3.14']"
15734
permissions:
158-
security-events: write
159-
160-
steps:
161-
- uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b
162-
with:
163-
disable-sudo: true
164-
egress-policy: block
165-
allowed-endpoints: >
166-
api.github.com:443
167-
files.pythonhosted.org:443
168-
github.com:443
169-
pypi.org:443
170-
171-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
172-
173-
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548
174-
with:
175-
python-version: 3.13
176-
cache: pip
177-
178-
- uses: install-pinned/uv@0590ea0c73b1fdb765847c94975e71c97d9ad0b1
179-
180-
- run: uv pip install --system .[dev]
181-
182-
- id: run-bandit-sarif
183-
run: |
184-
bandit --confidence-level 'medium' --severity-level 'medium' --recursive 'src' --format 'sarif' --output 'results.sarif'
185-
186-
- uses: github/codeql-action/upload-sarif@89a39a4e59826350b863aa6b6252a07ad50cf83e
187-
if: ( success() || failure() ) && contains('["success", "failure"]', steps.run-bandit-sarif.outcome)
188-
with:
189-
sarif_file: results.sarif
190-
191-
- id: run-bandit
192-
if: failure() && contains('["failure"]', steps.run-bandit-sarif.outcome)
193-
run: |
194-
bandit --confidence-level 'medium' --severity-level 'medium' --recursive 'src'
195-
196-
197-
mypy:
198-
runs-on: ubuntu-latest
199-
200-
steps:
201-
- uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b
202-
with:
203-
disable-sudo: true
204-
egress-policy: block
205-
allowed-endpoints: >
206-
files.pythonhosted.org:443
207-
github.com:443
208-
pypi.org:443
209-
210-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
211-
212-
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548
213-
with:
214-
python-version: '3.13'
215-
cache: pip
216-
217-
- uses: install-pinned/uv@0590ea0c73b1fdb765847c94975e71c97d9ad0b1
218-
219-
- run: uv pip install --system -e .[dev]
220-
221-
- id: cache-mypy
222-
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306
223-
with:
224-
path: .mypy_cache
225-
key: ${{ runner.os }}-mypy-${{ hashFiles('pyproject.toml') }}
226-
227-
- run: mypy .
228-
229-
coverage:
230-
runs-on: ubuntu-latest
231-
needs: pytest
232-
233-
permissions:
234-
pull-requests: write
35+
# Write
23536
contents: write
236-
237-
steps:
238-
- uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b
239-
with:
240-
disable-sudo: true
241-
egress-policy: block
242-
allowed-endpoints: >
243-
api.github.com:443
244-
github.com:443
245-
img.shields.io:443
246-
247-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
248-
249-
- uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3
250-
with:
251-
pattern: coverage-*
252-
merge-multiple: true
253-
254-
- id: coverage_comment
255-
uses: py-cov-action/python-coverage-comment-action@e623398c19eb3853a5572d4a516e10b15b5cefbc
256-
with:
257-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
258-
MERGE_COVERAGE_FILES: true
259-
260-
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
261-
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
262-
with:
263-
name: python-coverage-comment-action
264-
path: python-coverage-comment-action.txt
265-
266-
pre-commit:
267-
runs-on: ubuntu-latest
268-
needs:
269-
- ruff-format
270-
- ruff-check
271-
- bandit
272-
273-
permissions:
274-
contents: write
275-
276-
steps:
277-
- uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b
278-
with:
279-
disable-sudo: true
280-
egress-policy: block
281-
allowed-endpoints: >
282-
files.pythonhosted.org:443
283-
github.com:443
284-
proxy.golang.org:443
285-
pypi.org:443
286-
287-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
288-
289-
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548
290-
with:
291-
python-version: 3.13
292-
cache: pip
293-
294-
- uses: install-pinned/uv@0590ea0c73b1fdb765847c94975e71c97d9ad0b1
295-
296-
- run: uv pip install --system .[dev]
297-
298-
- id: cache-pre-commit
299-
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306
300-
with:
301-
path: .pre-commit-cache
302-
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}-${{ hashFiles('pyproject.toml') }}
303-
304-
- run: |
305-
pre-commit install
306-
pre-commit run --all-files
307-
env:
308-
PRE_COMMIT_HOME: .pre-commit-cache
37+
pull-requests: write

.pre-commit-config.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ repos:
1313
- id: check-toml
1414
- id: debug-statements
1515
- id: mixed-line-ending
16-
- repo: https://github.com/bwhmather/ssort
17-
rev: 0.15.0
16+
- repo: https://github.com/PyCQA/bandit
17+
rev: 1.9.4
1818
hooks:
19-
- id: ssort
19+
- id: bandit
20+
args: ['--confidence-level', 'medium']
21+
files: '^src'
2022
- repo: https://github.com/astral-sh/ruff-pre-commit
21-
rev: 'v0.14.7'
23+
rev: v0.15.4
2224
hooks:
2325
- id: ruff
2426
- id: ruff-format
25-
- repo: https://github.com/PyCQA/bandit
26-
rev: '1.9.2'
27+
- repo: https://github.com/bwhmather/ssort
28+
rev: 0.15.0
2729
hooks:
28-
- id: bandit
29-
args: ['--confidence-level', 'medium']
30-
files: '^src'
30+
- id: ssort

0 commit comments

Comments
 (0)