Skip to content

Commit

Permalink
chore: update ci-cd.yml to use uv as the package manager and cache uv…
Browse files Browse the repository at this point in the history
… dependencies
  • Loading branch information
MountainGod2 committed Sep 28, 2024
1 parent 7dec331 commit 9de0a6e
Showing 1 changed file with 31 additions and 24 deletions.
55 changes: 31 additions & 24 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,56 @@ on:
branches: [ main ]

jobs:

ci:
runs-on: ubuntu-latest
env:
# Configure a constant location for the uv cache
UV_CACHE_DIR: /tmp/.uv-cache

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-[email protected]
with:
python-version: "3.12"
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: false
virtualenvs-in-project: true
- name: Set up Python
id: setup-python
run: uv python install

- name: Load cached venv
id: cached-poetry-dependencies
- name: Restore uv cache
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Install library
run: poetry install --no-interaction
- name: Install dependencies and project
if: steps.setup-python.outputs.cache-hit != 'true'
run: uv sync

- name: Format with ruff
run: poetry run ruff format ./
run: uv run ruff format ./

- name: Lint with ruff and fix issues
run: poetry run ruff check --fix ./
run: uv run ruff check --fix ./

- name: Type check with mypy
run: poetry run mypy ./
run: uv run mypy ./

- name: Test with pytest
env:
CB_USERNAME: ${{ secrets.CB_USERNAME }}
CB_TOKEN: ${{ secrets.CB_TOKEN }}
run: poetry run pytest --cov-report term --cov-report xml:coverage.xml --cov=chaturbate_poller
run: uv run pytest

- name: Scan with SonarCloud
uses: SonarSource/[email protected]
Expand All @@ -68,14 +71,16 @@ jobs:
fail_ci_if_error: true

- name: Build documentation
run: poetry run make clean html --directory docs/
run: uv run make clean html --directory docs/

- name: Upload documentation to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
personal_token: ${{ secrets.PERSONAL_TOKEN }}
publish_dir: docs/_build/html

- name: Minimize uv cache
run: uv cache prune --ci
cd:
permissions:
id-token: write
Expand Down Expand Up @@ -148,6 +153,7 @@ jobs:
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Checkout repository
uses: actions/checkout@v4
with:
Expand All @@ -173,7 +179,8 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ steps.meta.outputs.tags }}
${{ steps.release.outputs.version }}
# Add version tag
${{ steps.meta.outputs.tags }}-v${{ steps.meta.outputs.version }}
labels: ${{ steps.meta.outputs.labels }}

Expand Down

0 comments on commit 9de0a6e

Please sign in to comment.