ci: add dependency caching and split lint from test matrix#190
ci: add dependency caching and split lint from test matrix#190framsouza wants to merge 7 commits intomistralai:mainfrom
Conversation
Linting (ruff, mypy) was running on all 4 Python versions even though it produces identical results regardless of version. Split it into a separate job that runs once on 3.12, and added needs: lint so the test matrix doesn't spin up if linting fails. Also enabled setup-uv's built-in caching in all jobs — the docs workflow already had this but the test workflow didn't. And the coverage.xml that pytest was generating was just getting thrown away, so added an artifact upload to make it accessible after runs.
Default settings should be correct here and take care of this. Might be worth to update the action but not the rest.
Don't think it's true, there are issues rising only for some Py versions so we need to ensure everything works as expected for all. |
|
thanks @juliendenize , you've raised two valid points that I had overlooked. You're right that setup-uv handles caching well by default. I've removed the explicit cache-dependency-glob since the default already covers About linting, I moved Ruff stays in the single-version lint job because AFAIU (please correct me if i'm wrong) it works differently, it determines its target python version from requires-python in oh, and I also moved |
|
Great improvement! Separating lint from the test matrix is a solid optimization — running ruff 4 times across Python versions when the result is identical wastes CI minutes. The coverage artifact upload is also valuable — it makes coverage data available for future integration with tools like Codecov. I reviewed the changes and they look clean. +1 for merging. |
juliendenize
left a comment
There was a problem hiding this comment.
There are still adjustments to make as now we support 3.14 and i don't think we should split linting from tests as we want the linter to work on all versions.
Co-authored-by: Julien Denize <40604584+juliendenize@users.noreply.github.com>
test_from_url made live HTTP requests to example.com and download.samplelib.com. On macOS with uv-managed Python, SSL cert verification fails before the request completes, causing the test to hit the wrong error branch and fail. Beyond the local failure, live network calls in unit tests are fragile by design, they depend on external availability and can cause non-deterministic CI failures. Replace all three cases with mocked responses: - failed request: mock requests.get raising RequestException - invalid content: mock a 200 response with HTML body - valid audio: mock a 200 response with a real wav file built in memory No behavior changes to production code.
Dependency caching:
setup-uvhas built-in cache support keyed onuv.lockbut it wasn't enabled in the test or docs jobs. Addedenable-cache: trueandcache-dependency-glob: "uv.lock"to all jobs. The docs workflow already had its own caching setup so this makes things consistent.Lint runs once: ruff and mypy were running inside the 4-version test matrix, which means they were running 4 times and producing the same result every time. Moved them into a separate
lintjob on Python 3.12. The test job now hasneeds: lintso if linting fails nothing else starts.Coverage artifact: pytest was generating
coverage.xmlon every run but the file was never saved anywhere. Added an artifact upload so it's accessible from the Actions tab per Python version.Each PR commit currently triggers 4 redundant package downloads and runs linting 4 times for no gain. With caching and the lint split, subsequent runs skip the downloads entirely and linting consumes one job instead of four. This translates directly to faster feedback and fewer GitHub Actions compute minutes burned, which at scale has a real cost impact.
Testing
Tested locally with
act pull_request. All jobs pass.NOTE:
test_from_urlwill show as failing on this PR in CI until #188 is merged into main first.