From 2aba888277ea7ad08614bf023637dd934f1d66d2 Mon Sep 17 00:00:00 2001 From: phi Date: Tue, 27 Aug 2024 01:03:33 +0900 Subject: [PATCH] fix: actions --- .github/workflows/check.yaml | 37 ++++++++++++++++++++------ .github/workflows/lint.yaml | 47 ++++++++++++++++++++++++---------- .github/workflows/publish.yaml | 22 ++++++---------- 3 files changed, 71 insertions(+), 35 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 24867e3..038c474 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -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 diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index a0af68f..0ac6872 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -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 \ No newline at end of file + uv run pre-commit run --all-files --show-diff-on-failure + + - name: Minimize uv cache + run: uv cache prune --ci \ No newline at end of file diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index ad08dab..363fe65 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -8,9 +8,6 @@ jobs: publish: runs-on: ubuntu-latest name: "Publish library" - strategy: - matrix: - python-version: ["3.8"] steps: - name: Check out @@ -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 }} \ No newline at end of file + uvx twine upload dist/* --non-interactive \ + --username __token__ --password ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file