Skip to content

Commit 358e002

Browse files
authored
[CI] Use uv for type-check (#222)
**TODO**: - [repo admin] After merge, remove required PR check `type-check (3.9)` > error: The current Python platform is not compatible with the lockfile's supported environments: `python_full_version >= '3.10'` --------- Signed-off-by: Christian Kadner <[email protected]>
1 parent 2ae1108 commit 358e002

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed

.github/workflows/type_check.yaml

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,52 @@
11
name: Type Check
22

33
on:
4-
# Trigger the workflow on push or pull request, but only for the main branch.
5-
# Don't use pull_request.paths filter since this workflow is required for
6-
# all pull requests on main irrespective of file type or location.
4+
# Don't use `paths` or `paths-ignore` filter since this workflow is required
5+
# for all pull requests on main irrespective of file type or location
6+
# Use `changed-src-files` step to determine if source code was changed
77
pull_request:
88
branches:
99
- main
1010
push:
1111
branches:
1212
- main
13-
paths:
14-
- '**/*.py'
15-
- '.github/workflows/type_check.yaml'
16-
- 'tools/type_check.sh'
17-
- 'pyproject.toml'
1813

1914
jobs:
2015
type-check:
2116
runs-on: ubuntu-latest
2217
strategy:
2318
matrix:
24-
python-version: ["3.9", "3.10", "3.11", "3.12"]
19+
python-version: ["3.10", "3.11", "3.12"]
2520
steps:
26-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27-
- name: Set up Python ${{ matrix.python-version }}
28-
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
21+
- name: "Checkout"
22+
uses: actions/checkout@v4
23+
24+
- name: "Get changed source files"
25+
id: changed-src-files
26+
uses: tj-actions/changed-files@v46
27+
with: # Avoid using single or double quotes for multiline patterns
28+
files: |
29+
.github/workflows/type_check.yaml
30+
tools/type_check.sh
31+
pyproject.toml
32+
**.py
33+
34+
- name: "Set up Python ${{ matrix.python-version }}"
35+
if: steps.changed-src-files.outputs.any_changed == 'true'
36+
uses: astral-sh/setup-uv@v5
2937
with:
3038
python-version: ${{ matrix.python-version }}
31-
- name: Install dependencies
32-
run: |
33-
# TODO: use `uv`
34-
python -m pip install --upgrade pip
35-
pip install mypy==1.11.1
36-
pip install types-setuptools
37-
pip install types-PyYAML
38-
pip install types-requests
39-
pip install types-setuptools
40-
- name: Mypy
39+
enable-cache: true
40+
ignore-nothing-to-cache: true
41+
cache-dependency-glob: |
42+
pyproject.toml
43+
44+
- name: "Install dependencies"
45+
if: steps.changed-src-files.outputs.any_changed == 'true'
46+
run: uv sync --frozen --only-group lint
47+
48+
- name: "Run mypy"
49+
if: steps.changed-src-files.outputs.any_changed == 'true'
4150
run: |
4251
echo "::add-matcher::.github/workflows/matchers/mypy.json"
4352
tools/type_check.sh 1 ${{ matrix.python-version }}

0 commit comments

Comments
 (0)