Enable trusted publishing workflow to PyPI #534
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: tests | |
#Running tests on all branches | |
on: | |
push: | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
# Needed for micromamba pickup | |
defaults: | |
run: | |
shell: bash -l {0} | |
jobs: | |
test: | |
# Setup the Python that the ROOT binary was built against | |
runs-on: ${{ matrix.os }} | |
# On push events run the CI only on main by default, but run on any branch if the commit message contains '[ci all]' | |
if: >- | |
github.event_name != 'push' | |
|| (github.event_name == 'push' && github.ref == 'refs/heads/main') | |
|| (github.event_name == 'push' && github.ref != 'refs/heads/main' && contains(github.event.head_commit.message, '[ci all]')) | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
root-version: ["6.24", "6.26", "6.28"] | |
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"] | |
exclude: | |
- root-version: "6.24" | |
python-version: "3.10" | |
- root-version: "6.26" | |
python-version: "3.6" | |
- root-version: "6.26" | |
python-version: "3.7" | |
- root-version: "6.28" | |
python-version: "3.6" | |
- root-version: "6.28" | |
python-version: "3.7" | |
include: | |
- os: macos-latest | |
root-version: "6.28" | |
python-version: "3.10" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Micromamba environment | |
uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-name: ci | |
create-args: >- | |
python=${{ matrix.python-version }} | |
root=${{ matrix.root-version }} | |
imagemagick | |
ghostscript | |
pip | |
condarc: | | |
channels: | |
- conda-forge | |
- name: ROOT info | |
run: | | |
root-config --version | |
root-config --python-version | |
# Install dependencies | |
- name: Install python dependencies | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
python -m pip install --upgrade \ | |
'pylint==2.9.6' \ | |
pytest_pylint \ | |
configparser \ | |
astroid \ | |
pyyml \ | |
papermill \ | |
nbconvert \ | |
jupyter \ | |
pytest \ | |
pytest-cov | |
- name: Install hepdata_lib | |
run: python -m pip install '.[test]' | |
# Use python -m pytest to add current working dir as src/ dir layout not used | |
- name: Run pytest | |
run: | | |
python -m pytest tests | |
- name: Report coverage with Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
files: ./coverage.xml | |
flags: unittests-${{ matrix.python-version }} | |
- name: Save notebooks | |
if: ${{ always() }} | |
run: | | |
python -m jupyter kernelspec list | |
python -m jupyter nbconvert --ExecutePreprocessor.timeout=600 --ExecutePreprocessor.allow_errors=True --to html --execute examples/*.ipynb | |
- name: Upload notebooks | |
if: ${{ always() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: notebooks-${{ matrix.root-version }}-${{ matrix.python-version }}-${{ matrix.os }} py3-${{ matrix.root-version }}-${{ matrix.python-version }}-${{ matrix.os }} | |
path: examples/*.html | |
- name: Run pylint | |
if: ${{ always() }} | |
run: | | |
python -m pylint hepdata_lib/*.py | |
python -m pylint tests/*.py --rcfile=tests/pylintrc |