Calmcode - uv: github actions

UV and Github Actions

1 2 3 4

There is a good chance that you can speed up your Github Actions with UV too. Here's an example of a Github Actions workflow that uses UV to install dependencies and run tests.

name: Code Checks

on:
  push:
    branches:
    - main
  pull_request:
    branches:
    - main

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.11", "3.12"]

    steps:
    - uses: actions/checkout@v2
    - name: Install uv
      uses: astral-sh/setup-uv@v2
    - name: Set up Python ${{ matrix.python-version }}
      run: uv python install ${{ matrix.python-version }}
    - name: Install Venv
      run: uv venv
    - name: Install Dependencies
      run: uv pip install -e ".[dev]"
    - name: Test
      run: uv run pytest

Note that you are using the astral-sh/setup-uv@v2 step to ensure that uv is installed in the runner. From there you can use UV as you would normally.

Also note that the uv run command can also be useful in this context.