-
Notifications
You must be signed in to change notification settings - Fork 39
146 lines (131 loc) · 4.29 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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", "6.30"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
exclude:
- root-version: "6.24"
python-version: "3.10"
- root-version: "6.24"
python-version: "3.11"
- root-version: "6.26"
python-version: "3.6"
- root-version: "6.26"
python-version: "3.7"
- root-version: "6.26"
python-version: "3.11"
- root-version: "6.28"
python-version: "3.6"
- root-version: "6.28"
python-version: "3.7"
- root-version: "6.30"
python-version: "3.6"
- root-version: "6.30"
python-version: "3.7"
include:
- os: macos-latest
root-version: "6.30"
python-version: "3.11"
steps:
- uses: actions/checkout@v4
- name: Setup Micromamba environment
if: ${{ matrix.root-version }}
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: Setup Micromamba environment without ROOT
if: ${{ !matrix.root-version }}
uses: mamba-org/setup-micromamba@v1
with:
environment-name: ci
create-args: >-
python=${{ matrix.python-version }}
imagemagick
ghostscript
pip
condarc: |
channels:
- conda-forge
- name: ROOT info
if: ${{ matrix.root-version }}
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' \
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
if: ${{ matrix.root-version }}
run: |
python -m pytest tests
- name: Run pytest without ROOT
if: ${{ !matrix.root-version }}
run: |
python -m pytest tests -m 'not needs_root'
- name: Report coverage with Codecov
if: ${{ matrix.root-version }}
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
flags: unittests-${{ matrix.python-version }}
- name: Save notebooks
if: ${{ always() && matrix.root-version }}
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() && matrix.root-version }}
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() && !startsWith(matrix.python-version, '3.6') && !startsWith(matrix.python-version, '3.7') }}
run: |
python -m pylint hepdata_lib/*.py
python -m pylint tests/*.py