Skip to content

Commit

Permalink
fix: actions using uv
Browse files Browse the repository at this point in the history
  • Loading branch information
phi-friday committed Aug 26, 2024
1 parent 54e06a0 commit 3f72b1b
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 42 deletions.
42 changes: 28 additions & 14 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,44 @@ jobs:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]

name: check ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4

- name: Set up uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Install rye
uses: phi-friday/install-rye@v2
id: install-rye
with:
python_version: ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }}
id: setup-python
run: |
uv python install ${{ matrix.python-version }}
uv python pin ${{ matrix.python-version }}
uv lock
echo "PY=$(uv run python -VV | shasum -a 256 | cut -d' ' -f1)" >> $GIHUB_OUPUT
- name: Load cached venv
id: cached-venv-dependencies
- name: Restore uv cache
uses: actions/cache@v4
id: uv-cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.install-rye.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}

path: /tmp/.uv-cache
key: uv-${{ steps.setup-python.outputs.PY }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ steps.setup-python.outputs.PY }}-${{ hashFiles('uv.lock') }}
uv-${{ steps.setup-python.outputs.PY }}
- name: Install dependencies
if: steps.cached-venv-dependencies.outputs.cache-hit != 'true'
run: |
rye sync
if: steps.uv-cache.outputs.cache-hit != 'true'
run: uv sync

- name: Restore pre-commit cache
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ steps.setup-python.outputs.PY }}-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Test with pytest
run: |
rye run pytest
uv run pytest
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
Expand Down
43 changes: 29 additions & 14 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,43 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
PYTHON_VERSION: 3.9

steps:
- uses: actions/checkout@v4

- name: Install rye
uses: phi-friday/install-rye@v2
id: install-rye
with:
python_version: "3.9"
- name: Set up uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Set up Python
id: setup-python
run: |
uv python install ${{ env.PYTHON_VERSION }}
uv python pin ${{ env.PYTHON_VERSION }}
uv lock
echo "PY=$(uv run python -VV | shasum -a 256 | cut -d' ' -f1)" >> $GIHUB_OUPUT
- name: Load cached venv
id: cached-venv-dependencies
- name: Restore uv cache
uses: actions/cache@v4
id: uv-cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.install-rye.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}

path: /tmp/.uv-cache
key: uv-${{ steps.setup-python.outputs.PY }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ steps.setup-python.outputs.PY }}-${{ hashFiles('uv.lock') }}
uv-${{ steps.setup-python.outputs.PY }}
- name: Install dependencies
if: steps.cached-venv-dependencies.outputs.cache-hit != 'true'
run: |
rye sync
if: steps.uv-cache.outputs.cache-hit != 'true'
run: uv sync

- name: Restore pre-commit cache
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ steps.setup-python.outputs.PY }}-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Code checks
run: |
rye run pre-commit run --all-files --show-diff-on-failure
uv run pre-commit run --all-files --show-diff-on-failure
30 changes: 16 additions & 14 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ jobs:
publish:
runs-on: ubuntu-latest
name: "Publish library"
strategy:
matrix:
python-version: ["3.12"]
env:
PYTHON_VERSION: 3.12

steps:
- name: Check out
Expand All @@ -19,20 +18,23 @@ jobs:
token: "${{ secrets.GITHUB_TOKEN }}"
fetch-depth: 0

- name: Install rye
uses: phi-friday/install-rye@v2
id: install-rye
with:
python_version: ${{ matrix.python-version }}
- name: Set up uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Set up Python
id: setup-python
run: |
uv python install ${{ env.PYTHON_VERSION }}
uv python pin ${{ env.PYTHON_VERSION }}
- name: Build package
run: |
rye install dunamai
VERSION=$(dunamai from any --no-metadata --style pep440)
rye version $VERSION
rye build
VERSION=$(uvx dunamai from any --no-metadata --style pep440)
echo $VERSION
sed -i'' -E "s/version = \"0.0.0\"/version = \"$VERSION\"/g" pyproject.toml
uvx --from build pyproject-build --installer uv
- name: Release to PyPI
run: |
rye publish --yes \
--username __token__ --token ${{ secrets.PYPI_API_TOKEN }}
uvx twine upload dist/* --non-interactive \
--username __token__ --password ${{ secrets.PYPI_API_TOKEN }}

0 comments on commit 3f72b1b

Please sign in to comment.