-
Notifications
You must be signed in to change notification settings - Fork 3
68 lines (59 loc) · 1.63 KB
/
test.yaml
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
name: Test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.10']
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev,test]
pip install pytest pytest-cov codecov
- name: Check for test files
id: check_tests
run: |
if ls tests/*_test.py 1> /dev/null 2>&1; then
echo "Tests found."
echo "tests-found=true" >> $GITHUB_ENV
else
echo "No tests found. Skipping pytest."
echo "tests-found=false" >> $GITHUB_ENV
fi
- name: Run tests
if: env.tests-found == 'true'
env:
MPLBACKEND: agg
PLATFORM: ${{ matrix.os }}
run: |
pytest -v --cov=./ --cov-report=xml
- name: Check for coverage report
if: env.tests-found == 'true'
run: |
if [ -f ./coverage.xml ]; then
echo "coverage-found=true" >> $GITHUB_ENV
else
echo "coverage-found=false" >> $GITHUB_ENV
fi
- name: Upload coverage to Codecov
if: env.coverage-found == 'true'
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: true