Skip to content

Commit

Permalink
feat: use uv
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Dec 27, 2024
1 parent 0ac7ded commit 66f9edf
Show file tree
Hide file tree
Showing 3 changed files with 1,236 additions and 58 deletions.
34 changes: 23 additions & 11 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
id: cpython_setup
- uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
enable-cache: true
cache-dependency-glob: "uv.lock"
# - uses: actions/setup-python@v5
# id: cpython_setup
# with:
# python-version: ${{ matrix.python-version }}
# cache: pip

- run: pip install '.[lint]'
- run: ruff check --diff src tests
- run: ruff format --diff src tests
# - run: pip install '.[lint]'
- run: uv sync --group lint
- run: uv run ruff check --diff src tests
- run: uv run ruff format --diff src tests

type:
strategy:
Expand All @@ -36,11 +42,17 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
id: cpython_setup
- uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
enable-cache: true
cache-dependency-glob: "uv.lock"
# - uses: actions/setup-python@v5
# id: cpython_setup
# with:
# python-version: ${{ matrix.python-version }}
# cache: pip

- run: pip install '.[types]'
- run: mypy src
# - run: pip install '.[types]'
- run: uv sync --group types
- run: uv run mypy src
112 changes: 65 additions & 47 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,43 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
id: cpython_setup
- uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
enable-cache: true
cache-dependency-glob: "uv.lock"
# - uses: actions/setup-python@v5
# id: cpython_setup
# with:
# python-version: ${{ matrix.python-version }}
# cache: pip

- name: pytest (linux/macos)
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
run: |
python -m venv .venv
source .venv/bin/activate
echo "VIRTUAL_ENV: $VIRTUAL_ENV"
pip install --upgrade pip
pip install '.[test]'
coverage run -m pytest -s -vv
coverage html
# - name: pytest (linux/macos)
# if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
# run: |
# python -m venv .venv
# source .venv/bin/activate
# echo "VIRTUAL_ENV: $VIRTUAL_ENV"
# pip install --upgrade pip
# pip install '.[test]'
# coverage run -m pytest -s -vv
# coverage html
#
# - name: pytest (windows)
# if: ${{ matrix.os == 'windows-latest' }}
# run: |
# python -m venv .venv
# .venv/Scripts/Activate.ps1
# echo "VIRTUAL_ENV: $VIRTUAL_ENV"
# python -m pip install --upgrade pip
# pip install '.[test]'
# coverage run -m pytest -s -vv
# coverage html

- name: pytest (windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
python -m venv .venv
.venv/Scripts/Activate.ps1
echo "VIRTUAL_ENV: $VIRTUAL_ENV"
python -m pip install --upgrade pip
pip install '.[test]'
coverage run -m pytest -s -vv
coverage html
- run: uv sync --group test
- run: uv run coverage run -m pytest -s -vv
- run: uv run coverage report
- run: uv run coverage html

- name: Archive code coverage results
uses: actions/upload-artifact@v4
Expand All @@ -61,31 +71,39 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
id: cpython_setup
- uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
enable-cache: true
cache-dependency-glob: "uv.lock"
# - uses: actions/setup-python@v5
# id: cpython_setup
# with:
# python-version: ${{ matrix.python-version }}
# cache: pip

# Note: I'm using pip, for faster CI. But you can also uses pipx:
# Example:
# - run: pipx install creosote --python '${{ steps.cpython_setup.outputs.python-path }}'
- run: pip install --upgrade creosote
# # Note: I'm using pip, for faster CI. But you can also uses pipx:
# # Example:
# # - run: pipx install creosote --python '${{ steps.cpython_setup.outputs.python-path }}'
# - run: pip install --upgrade creosote
#
# - name: run creosote (linux/macos)
# if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
# run: |
# python -m venv .venv
# source .venv/bin/activate
# echo "VIRTUAL_ENV: $VIRTUAL_ENV"
# pip install --upgrade .
# creosote --venv .venv --exclude-dep tomli
#
# - name: run creosote (windows)
# if: ${{ matrix.os == 'windows-latest' }}
# run: |
# python -m venv .venv
# .venv/Scripts/Activate.ps1
# Write-Host "VIRTUAL_ENV: $env:VIRTUAL_ENV"
# pip install --upgrade .
# creosote --venv .venv --exclude-dep tomli

- name: run creosote (linux/macos)
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
run: |
python -m venv .venv
source .venv/bin/activate
echo "VIRTUAL_ENV: $VIRTUAL_ENV"
pip install --upgrade .
creosote --venv .venv --exclude-dep tomli
- name: run creosote (windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
python -m venv .venv
.venv/Scripts/Activate.ps1
Write-Host "VIRTUAL_ENV: $env:VIRTUAL_ENV"
pip install --upgrade .
creosote --venv .venv --exclude-dep tomli
- run: uv sync
- run: uv run creosote --venv .venv --exclude-dep tomli
Loading

0 comments on commit 66f9edf

Please sign in to comment.