Merge pull request #31 from scipp/update-ci #128
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
# SPDX-License-Identifier: BSD-3-Clause | |
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp) | |
name: Mpltoolbox | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
pull_request: | |
branches: | |
- '*' | |
env: | |
PY_VERSION: '3.10' | |
jobs: | |
formatting: | |
name: Formatting and static analysis | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PY_VERSION }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install flake8 black[jupyter] | |
- name: Check black formatting | |
run: | | |
black --check --diff . | |
- name: Lint with flake8 | |
run: | | |
flake8 . --count --statistics | |
tests: | |
needs: formatting | |
name: Unit tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PY_VERSION }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install pytest | |
python -m pip install -r docs/requirements.txt | |
python -m pip install -e . | |
- name: Run python tests | |
run: | | |
python -m pytest tests | |
docs: | |
needs: tests | |
name: Documentation | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PY_VERSION }} | |
- name: Install dependencies | |
run: | | |
sudo apt install pandoc | |
python -m pip install --upgrade pip | |
python -m pip install -r docs/requirements.txt | |
python -m pip install -e . | |
- name: Build documentation | |
run: | | |
sphinx-build -b html docs/. docs/build | |
- name: Archive documentation artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: DocumentationHTML | |
path: docs/build | |
publish: | |
needs: docs | |
name: Publish to PyPI | |
runs-on: ubuntu-latest | |
environment: release | |
permissions: | |
id-token: write | |
if: github.event_name == 'release' && github.event.action == 'published' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PY_VERSION }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install build toml | |
- name: Build wheel | |
run: | | |
python -m build --sdist --wheel --outdir dist/ . | |
- name: Upload to PyPI | |
uses: pypa/[email protected] |