JSON writer has been refactored for reusability and readability #171
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: | |
pull_request: | |
branches: | |
- "**" | |
push: | |
branches: | |
- "**" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.10", "3.11", "3.12"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- 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: Load cached Poetry installation | |
id: cached-poetry | |
uses: actions/cache@v4 | |
with: | |
path: ~/.local # the path depends on the OS | |
key: poetry-${{ runner.os }}-${{ matrix.python-version }}-0 # increment to reset cache | |
- name: Install Poetry | |
if: steps.cached-poetry.outputs.cache-hit != 'true' | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }} | |
restore-keys: | | |
venv-${{ runner.os }}-${{ matrix.python-version }}- | |
- name: Install dependencies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction | |
- name: check linting | |
run: poetry run flake8 . | |
- name: check formatting | |
run: poetry run black --check . | |
- name: check types | |
run: poetry run pyright . | |
- name: test | |
run: poetry run pytest --cov=sae_dashboard --cov-report=term-missing tests/unit | |
- name: build | |
run: poetry build | |
release: | |
needs: build | |
permissions: | |
contents: write | |
id-token: write | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'chore(release):') | |
runs-on: ubuntu-latest | |
concurrency: release | |
environment: | |
name: pypi | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- 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 }} |