Skip to content

Commit

Permalink
fix: actions
Browse files Browse the repository at this point in the history
  • Loading branch information
phi-friday committed Aug 26, 2024
1 parent 3da0b8e commit 2aba888
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 35 deletions.
37 changes: 29 additions & 8 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,52 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
UV_CACHE_DIR: /tmp/.uv-cache
strategy:
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: Set up Python ${{ matrix.python-version }}
id: setup-python
run: |
uv python install ${{ matrix.python-version }}
uv python pin ${{ matrix.python-version }}
uv lock
PY=$(uv run python -VV | shasum -a 256 | cut -d' ' -f1)
echo PY: $PY
echo "PY=$PY" >> "$GITHUB_OUTPUT"
- name: Install rye
uses: phi-friday/install-rye@v2
id: install-rye
with:
python_version: ${{ matrix.python-version }}

- 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: ${{ env.UV_CACHE_DIR }}
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: Test with pytest
run: |
rye run pytest
uv run pytest
- name: Minimize uv cache
run: uv cache prune --ci
47 changes: 34 additions & 13 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,49 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
PYTHON_VERSION: 3.9
UV_CACHE_DIR: /tmp/.uv-cache

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
PY=$(uv run python -VV | shasum -a 256 | cut -d' ' -f1)
echo PY: $PY
echo "PY=$PY" >> "$GITHUB_OUTPUT"
- 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: ${{ env.UV_CACHE_DIR }}
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
- name: Minimize uv cache
run: uv cache prune --ci
22 changes: 8 additions & 14 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ jobs:
publish:
runs-on: ubuntu-latest
name: "Publish library"
strategy:
matrix:
python-version: ["3.8"]

steps:
- name: Check out
Expand All @@ -19,20 +16,17 @@ 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: 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 2aba888

Please sign in to comment.