Skip to content

Commit

Permalink
feat: use uv and dependency groups
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Dec 27, 2024
1 parent 69bdadc commit 7a62cc9
Show file tree
Hide file tree
Showing 4 changed files with 1,243 additions and 65 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
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ dependencies = [
[tool.hatch.version]
path = "src/creosote/__about__.py"

[project.optional-dependencies]
# PEP-440
lint = ["ruff>=0.5.0,<0.8"]
types = ["mypy", "loguru-mypy"]
test = ["pytest", "pytest-mock", "coverage"]
dev = ["creosote[lint,types,test]"]

[project.urls]
Source = "https://github.com/fredrikaverpil/creosote"
Tracker = "https://github.com/fredrikaverpil/creosote/issues"

[project.scripts]
creosote = "creosote.cli:main"

[dependency-groups]
lint = ["ruff>=0.7.4"]
types = ["loguru-mypy>=0.0.4", "mypy>=1.14.0"]
test = ["pytest-mock>=3.14.0", "pytest>=8.3.4", "coverage>=7.6.1"]
lsp = ["basedpyright>=1.23.1"]
dap = ["debugpy>=1.8.11"]

[tool.ruff]
src = ["src", "tests"]
line-length = 88 # black default
Expand Down
Loading

0 comments on commit 7a62cc9

Please sign in to comment.