build: Use hatchling as build backend #1950
Workflow file for this run
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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: CI | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
workflow_dispatch: | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- uses: pre-commit/[email protected] | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ['3.8', '3.9', '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: Install cabinetry and dependencies | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
python -m pip install .[test] | |
- name: List installed Python packages | |
run: python -m pip list | |
- name: Static code analysis with flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 src/cabinetry --select=E9,F63,F7,F82 --show-source | |
# check for additional issues flagged by flake8 | |
flake8 | |
- name: Format with Black | |
run: | | |
black --check --diff --verbose . | |
- name: Run example | |
run: | | |
python utils/create_ntuples.py | |
python example.py | |
- name: Install pyhf backends | |
run: | | |
python -m pip install .[pyhf_backends] # install pyhf backends | |
- name: List installed Python packages | |
run: python -m pip list | |
- name: Test with pytest, generate coverage report (skipping typeguard) | |
if: matrix.python-version == '3.8' | |
run: | | |
# https://github.com/scikit-hep/cabinetry/issues/428 | |
pip install --upgrade typing_extensions | |
# skip typeguard for coverage https://github.com/agronholm/typeguard/issues/356 | |
pytest --runslow --cov-report=xml --typeguard-packages="" | |
- name: Test with pytest | |
if: matrix.python-version != '3.8' | |
run: | | |
pytest --runslow | |
- name: Upload coverage to codecov | |
if: matrix.python-version == '3.8' | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: ./coverage.xml | |
name: codecov-umbrella | |
fail_ci_if_error: true | |
verbose: true | |
- name: Build docs with sphinx | |
run: | | |
python -m pip install .[docs] | |
sphinx-build -W docs docs/_build |