Migrate to uv's preview APIs #916
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
env: | |
RUFF_UNRELEASED_REF: "main" | |
UV_SYSTEM_PYTHON: "true" | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
check: | |
name: Check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: extractions/setup-just@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- uses: hynek/setup-cached-uv@v1 | |
- name: Install dependencies | |
run: just sync | |
- name: Run checks | |
run: just check | |
ruff-versions: | |
name: Generate test versions | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: | | |
sudo apt-get install -y ripgrep | |
- name: Determine test versions | |
id: set-versions | |
run: | | |
# Get the latest release version from GitHub | |
LATEST=$( \ | |
curl -L \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/astral-sh/ruff/releases/latest \ | |
| jq '.tag_name' --raw-output \ | |
| cut -c2- \ | |
) | |
# Get the oldest supported version from the pyproject.toml | |
OLDEST=$(rg -No '"ruff>=(.*)"' -r '$1' pyproject.toml) | |
UNRELEASED=${{ env.RUFF_UNRELEASED_REF }} | |
echo "::set-output name=latest::$LATEST" | |
echo "::set-output name=oldest::$OLDEST" | |
echo "::set-output name=dev::$UNRELEASED" | |
outputs: | |
latest: ${{ steps.set-versions.outputs.latest }} | |
oldest: ${{ steps.set-versions.outputs.oldest }} | |
dev: ${{ steps.set-versions.outputs.dev }} | |
test: | |
name: Test (python-${{ matrix.python-version }}, ruff-${{ matrix.ruff-version }}, ${{ matrix.os }}) | |
needs: ruff-versions | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] | |
os: [ubuntu-latest, macos-13, windows-latest] | |
include: | |
- ruff-version: ${{ needs.ruff-versions.outputs.latest }} | |
- ruff-version: ${{ needs.ruff-versions.outputs.oldest }} | |
os: ubuntu-latest | |
python-version: "3.7" | |
- ruff-version: ${{ needs.ruff-versions.outputs.dev }} | |
os: ubuntu-latest | |
python-version: "3.12" | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: extractions/setup-just@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- uses: hynek/setup-cached-uv@v1 | |
- name: Install dependencies | |
run: just sync | |
- name: Install test Ruff version from PyPI | |
if: ${{ matrix.ruff-version != env.RUFF_UNRELEASED_REF }} | |
run: | | |
uv pip install --reinstall ruff==${{ matrix.ruff-version }} | |
ruff --version | |
- name: "Install test Ruff version from GitHub" | |
if: ${{ matrix.ruff-version == env.RUFF_UNRELEASED_REF }} | |
run: | | |
uv pip install --reinstall "ruff @ git+https://github.com/astral-sh/ruff@${{ matrix.ruff-version }}" | |
ruff version | |
- name: Run tests | |
run: just test |