Bonsai_Tutorials/transcriber/.github/workflows/main.yml

123 lines
3.5 KiB
YAML

name: Main
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Set up the environment
uses: ./.github/actions/setup-python-env
- name: Run checks
run: make check
tests-and-type-check:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
fail-fast: false
defaults:
run:
shell: bash
steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up the environment
uses: ./.github/actions/setup-python-env
with:
python-version: ${{ matrix.python-version }}
- name: Run tests
# Your 'make test' target: @uv run python -m pytest --cov --cov-config=pyproject.toml -vv
# Your pyproject.toml already defines all cov-reports (term-missing, json, lcov, xml, html).
# So, 'make test' *will* generate htmlcov/ and coverage.xml.
run: make test
- name: Upload coverage artifacts
uses: actions/upload-artifact@v4
with:
name: coverage-report-${{ matrix.python-version }}
path: |
htmlcov/
coverage.xml
- name: Check typing
run: uv run mypy
# - name: Upload coverage reports to Codecov with GitHub Action on Python 3.11
# uses: codecov/codecov-action@v4
# if: ${{ matrix.python-version == '3.11' }}
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
check-docs:
runs-on: ubuntu-latest
needs: tests-and-type-check
steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up the environment
uses: ./.github/actions/setup-python-env
- name: Download coverage artifacts
uses: actions/download-artifact@v4
with:
name: coverage-report-3.12
path: . # Downloads htmlcov/ and coverage.xml to the root of the runner
- name: List downloaded files
run: |
ls -F
ls -F htmlcov/ # Check inside the downloaded htmlcov directory
- name: Check if documentation can be built
run: make docs-test
deploy-docs:
runs-on: ubuntu-latest
# This job should only run after 'check-docs' is successful
needs: check-docs
# Only deploy on pushes to the 'main' branch
if: github.ref == 'refs/heads/main' && success() # 'success()' ensures it only runs if 'needs' jobs succeeded
permissions:
contents: write # Grant write permission to the GITHUB_TOKEN for this job
steps:
- name: Check out
uses: actions/checkout@v4
# Need to fetch history for actions-gh-pages if it's operating on specific branches
with:
fetch-depth: 0
- name: Set up the environment
uses: ./.github/actions/setup-python-env
# To deploy, we first need to build the actual documentation site files
- name: Build documentation site
run: uv run mkdocs build # This generates the 'site/' directory by default
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site
publish_branch: gh-pages
commit_message: 'Deploy transcriber docs to GitHub Pages'