Skip to content

Add Github actions for CI #4

Add Github actions for CI

Add Github actions for CI #4

Workflow file for this run

name: CI (uv)
on:
push:
branches: ["main", "master"]
pull_request:
branches: ["*"]
jobs:
lint:
name: Lint (ruff)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup uv environment
uses: ./.github/actions/setup-uv
with:
dependency-group: dev
- name: Ruff format (check)
run: uv run ruff format --check
- name: Ruff check
run: uv run ruff check --output-format=github
test:
name: Test (pytest)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup uv environment
uses: ./.github/actions/setup-uv
with:
dependency-group: test
- name: Run pytest with coverage
run: uv run pytest --cov=src/sw_metadata_bot --cov-report=term-missing tests/
- name: Generate coverage badge
run: uv run coverage-badge -o coverage.svg -f
continue-on-error: true
- name: Commit coverage badge
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add coverage.svg
git diff --quiet && git diff --staged --quiet || git commit -m "chore: update coverage badge"
git push
continue-on-error: true
docs:
name: Docs (Sphinx)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup uv environment
uses: ./.github/actions/setup-uv
with:
dependency-group: docs
- name: Build Sphinx HTML
run: uv run sphinx-build -b html docs docs/_build/html
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/_build/html
publish-docs:
name: Publish Docs
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
needs: docs
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4