@@ -13,73 +13,97 @@ jobs:
1313 build-test :
1414 strategy :
1515 matrix :
16- python-version : [3.11]
16+ python-version : [" 3.11" ]
1717 platform :
18- - { runner: ubuntu-latest, python_exec: ".venv/bin/python" }
19- - { runner: ubuntu-24.04-arm, python_exec: ".venv/bin/python" }
20- - { runner: macos-latest, python_exec: ".venv/bin/python", extra_rustflags: "-C split-debuginfo=off"}
21- - { runner: macos-15-intel, python_exec: ".venv/bin/python", extra_rustflags: "-C split-debuginfo=off"}
22- - { runner: windows-latest, python_exec: ".venv\\Scripts\\python" }
18+ - { runner: ubuntu-latest }
19+ - { runner: ubuntu-24.04-arm }
20+ - { runner: macos-latest, extra_rustflags: "-C split-debuginfo=off" }
21+ - { runner: macos-15-intel, extra_rustflags: "-C split-debuginfo=off" }
22+ - { runner: windows-latest }
2323 runs-on : ${{ matrix.platform.runner }}
2424 env :
25- RUSTFLAGS : " -C debuginfo=0 ${{ matrix.platform.extra_rustflags }}"
26- CARGO_INCREMENTAL : " 0"
2725 SCCACHE_GHA_ENABLED : " true"
28- RUSTC_WRAPPER : " sccache"
2926
3027 steps :
31- - uses : actions/checkout@v4
28+ - uses : actions/checkout@v6
3229 with :
3330 fetch-depth : 1
3431
35- - name : Run sccache-cache
32+ - name : Setup sccache
3633 uses : mozilla-actions/sccache-action@v0.0.9
34+ with :
35+ # Latest version doesn't work well because of https://github.com/mozilla/sccache/issues/2554
36+ version : " v0.12.0"
37+
38+ - run : rustup toolchain install stable --profile minimal
39+
40+ - name : Setup Rust Cache
41+ uses : Swatinem/rust-cache@v2
42+ with :
43+ key : rust-${{ matrix.platform.runner }}
44+ cache-targets : ' true'
45+ cache-all-crates : ' false'
46+ cache-workspace-crates : ' false'
3747
38- - uses : actions/setup-python@v5
48+ - uses : actions/setup-python@v6
3949 id : setup_python
4050 with :
4151 python-version : ${{ matrix.python-version }}
4252 # Python cache is huge and saves little time, so disabled for now, until we have higher cache size limits
4353 # cache: 'pip'
4454
45- - run : rustup toolchain install stable --profile minimal
55+ - name : Install uv
56+ uses : astral-sh/setup-uv@v7
4657
47- # Disable Rust cache until we have higher cache size limits
48- # - name: Rust Cache
49- # uses: Swatinem/rust-cache@v2
50- # with:
51- # key: rust-${{ matrix.platform.runner }}-${{ matrix.python-version }}
52- # cache-targets: 'false'
53- # cache-all-crates: 'false'
54- # cache-workspace-crates: 'false'
58+ - name : Sync Python dependencies
59+ run : uv sync --no-dev --group ci
5560
56- - name : Rust tests (no default features)
57- run : cargo test --no-default-features --verbose
61+ - name : Cache pre-commit
62+ uses : actions/cache@v4
63+ with :
64+ path : ~/.cache/pre-commit
65+ key : precommit-${{ matrix.platform.runner }}-${{ matrix.python-version }}
5866
59- - name : Rust tests
60- run : cargo test --verbose
67+ - name : Install pre-commit
68+ run : pip install pre-commit
6169
62- - name : Setup venv
63- run : |
64- python -m venv .venv
65- - name : Install Python toolchains
66- run : |
67- ${{ matrix.platform.python_exec }} -m pip install maturin
68- - name : Python build
69- run : |
70- ${{ matrix.platform.python_exec }} -m maturin develop --strip -E all-ci
71- - name : Python type check (mypy)
72- run : |
73- ${{ matrix.platform.python_exec }} -m mypy python
74- ${{ matrix.platform.python_exec }} -m mypy --namespace-packages --explicit-package-bases --ignore-missing-imports examples
75- - name : Python tests
70+ - name : Run build-test hooks
71+ env :
72+ RUSTFLAGS : " -C debuginfo=0 ${{ matrix.platform.extra_rustflags }}"
73+ CARGO_INCREMENTAL : " 0"
74+ RUSTC_WRAPPER : " sccache"
75+ UV_NO_SYNC : " 1"
76+ # Skip mypy-check - it runs in e2e_type_check workflow
77+ SKIP : mypy-check
78+ shell : bash
7679 run : |
77- ${{ matrix.platform.python_exec }} -m pytest --capture=no python/cocoindex/tests
80+ set +e
81+
82+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
83+ echo "Running pre-commit on PR diff against target branch: ${{ github.base_ref }}"
84+ git fetch --no-tags --prune --depth=1 origin \
85+ "${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}"
86+
87+ pre-commit run \
88+ --from-ref "origin/${{ github.base_ref }}" \
89+ --to-ref "${{ github.sha }}" \
90+ --show-diff-on-failure
91+ status=$?
92+ else
93+ echo "Running pre-commit on all files (event: ${{ github.event_name }})"
94+ pre-commit run --all-files --show-diff-on-failure
95+ status=$?
96+ fi
97+
98+ if [ $status -ne 0 ]; then
99+ echo "::error::Build-test checks failed. Please run 'uv run pre-commit run --all-files' locally."
100+ exit $status
101+ fi
78102
79103 validate-3p-notices :
80104 runs-on : ubuntu-latest
81105 steps :
82- - uses : actions/checkout@v4
106+ - uses : actions/checkout@v6
83107 with :
84108 fetch-depth : 1
85109 - name : Install Rust toolchain
0 commit comments