Structure CI workflows to minimize execution time and resource usage through strategic job organization, caching, and elimination of redundant operations.
Key optimization strategies:
Example of optimized job structure:
jobs:
# Fast parallel checks (each ~20sec)
syntax-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
- run: uv run ruff check --no-fix --select PLE
format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
- run: uv run ruff format
- run: uv run pre-commit run --all-files
type-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
- run: uv run pyright
# Build once, test across matrix
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
- run: uv build
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
test-import:
needs: build
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.11", "3.12", "3.13"]
runs-on: $
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- run: python -c "import browser_use; print('Success!')"
This approach reduces total CI time from sequential execution to parallel execution, with all checks completing in under 30 seconds instead of several minutes.
Enter the URL of a public GitHub repository