V2 only custom jobs #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "ci" | |
on: # rebuild any PRs and main branch changes | |
pull_request: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.repository_owner }}-${{ github.repository }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
FORCE_COLOR: "1" | |
PYTHONUNBUFFERED: "1" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
matrix: | |
python-version: ["3.10", "3.11", "3.12"] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup PDM | |
uses: pdm-project/setup-pdm@v4 | |
with: | |
cache: false # project doesn't use pdm lock files | |
python-version: ${{ matrix.python-version }} | |
- name: Setup UV | |
uses: astral-sh/setup-uv@v5 | |
- name: Configure PDM to use UV | |
run: pdm config use_uv true | |
- name: Cache Huggingface assets | |
uses: actions/cache@v4 | |
with: | |
key: huggingface-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }} | |
path: ~/.cache/huggingface | |
restore-keys: | | |
huggingface-${{ runner.os }}-${{ matrix.python-version }}- | |
- name: Install dependencies | |
run: pdm install --group dev --no-lock | |
# TODO: re-enable when we have pre-commit hooks | |
# - name: Install pre-commit hooks | |
# run: pdm run pre-commit install | |
# - name: Ensure pre-commit hooks pass | |
# run: pdm run pre-commit run --all-files | |
# TODO: tests don't currently pass due to missing torch dependency | |
# see: https://github.com/longtermrisk/openweights/actions/runs/13210898278/job/36883965796?pr=11#step:8:29 | |
# - name: Run tests | |
# env: | |
# HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
# run: pdm run python -m pytest tests | |
release: | |
needs: build | |
environment: pypi | |
permissions: | |
contents: write | |
id-token: write | |
# https://github.community/t/how-do-i-specify-job-dependency-running-in-another-workflow/16482 | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'chore') | |
runs-on: ubuntu-latest | |
concurrency: release | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: pdm-project/setup-pdm@v4 | |
with: | |
cache: true | |
python-version: "3.12" | |
- name: build | |
run: pdm build | |
- name: Semantic Release | |
id: release | |
uses: python-semantic-release/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
# - name: Publish package distributions to PyPI | |
# uses: pypa/gh-action-pypi-publish@release/v1 | |
# if: steps.release.outputs.released == 'true' | |
- name: Publish package distributions to GitHub Releases | |
uses: python-semantic-release/upload-to-gh-release@main | |
if: steps.release.outputs.released == 'true' | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
# TODO: build and deploy docs to gh-pages | |
# do this as part of the semantic release step to ensure version is bumped |