Using uvx in GitHub Actions in a cache-friendly way
Simon Willison's article explains how to use uvx in GitHub Actions in a cache-friendly manner. uvx is a tool that runs Python packages without installing them, but it downloads packages each time by default. To avoid this, Willison recommends setting the UV_CACHE_DIR environment variable to a path within the GitHub Actions workspace, then using the actions/cache action to persist that directory between workflow runs. This approach ensures that subsequent runs reuse previously downloaded packages, significantly reducing execution time. The article provides a concrete example workflow snippet, demonstrating how to configure the cache key based on the runner's operating system and the uv version. This method is particularly beneficial for projects that frequently use uvx in CI/CD pipelines, as it minimizes redundant network requests and speeds up overall workflow execution.
Caching uvx in GitHub Actions reduces workflow run times by avoiding repeated package downloads.