Skip to content

CI

CI #264

Workflow file for this run

name: CI
on:
push:
pull_request:
workflow_call:
# Run weekly Sundays at 12:37am
schedule:
- cron: "37 0 * * 0"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Setup
id: setup
uses: ./.github/actions/setup
with:
setup-pre-commit: true
# lint group will be installed anyways because it is not optional
install-options: --with lint --all-extras
- name: Run linters
run: make lint
generate_test_matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: setup python
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
python-version: "3.11"
- name: Extract extras from `pyproject.toml`
id: set-matrix
shell: python
run: |
import tomllib
import os
import json
with open('pyproject.toml', 'rb') as f:
manifest = tomllib.load(f)
yaml = { 'include' : [{ 'extras' : extra} for extra in [''] + list(manifest['tool']['poetry']['extras'])]}
out = json.dumps(yaml)
print(out)
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
f.write('matrix=' + out)
test:
name: test ${{ matrix.extras && 'with' || '' }} ${{ matrix.extras }}
runs-on: ubuntu-latest
needs: generate_test_matrix
strategy:
matrix: ${{ fromJson(needs.generate_test_matrix.outputs.matrix) }}
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Setup
id: setup
uses: ./.github/actions/setup
with:
install-options: --without lint ${{ matrix.extras && format('--extras "{0}"', matrix.extras) || '' }}
- name: Run Tests
run: make test
docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Setup
id: setup
uses: ./.github/actions/setup
with:
install-options: --with docs
- name: Build Docs
run: make docs
- name: Publish Docs
id: publish-docs
if: github.ref_name == 'main' || startswith(github.ref_name, 'doc') || github.ref_type == 'tag'
uses: ./.github/actions/publish-docs
with:
token: ${{ secrets.GITHUB_TOKEN }}
publish:
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Setup
id: setup
uses: ./.github/actions/setup
with:
install-options: --without lint
- name: Publish to PyPI
run: poetry publish --build -u __token__ -p ${{ secrets.PYPI_TOKEN }}