-
Notifications
You must be signed in to change notification settings - Fork 8
74 lines (65 loc) · 2.89 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
name: Tests
on: [ pull_request ]
env:
MODULE_NAME: amid
jobs:
test:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Check the version
if: "! github.event.pull_request.head.repo.fork "
run: |
VERSION=$(python -c "from pathlib import Path; import runpy; folder, = {d.parent for d in Path().resolve().glob('*/__init__.py') if d.parent.is_dir() and (d.parent / '__version__.py').exists()}; print(runpy.run_path(folder / '__version__.py')['__version__'])")
MATCH=$(pip index versions $MODULE_NAME | grep "Available versions:" | grep $VERSION) || echo
echo $MATCH
if [ "$GITHUB_BASE_REF" = "master" ] && [ "$MATCH" != "" ]; then exit 1; fi
- name: Build the package
run: |
pip install build
python -m build --sdist
- name: Install
run: |
pip install dist/*
pip install -r tests/requirements.txt
cd tests
export MODULE_PARENT=$(python -c "import $MODULE_NAME, os; print(os.path.dirname($MODULE_NAME.__path__[0]))")
export MODULE_PARENT=${MODULE_PARENT%"/"}
cd ..
echo $MODULE_PARENT
echo "MODULE_PARENT=$(echo $MODULE_PARENT)" >> $GITHUB_ENV
- name: Test with pytest
if: "! github.event.pull_request.head.repo.fork "
run: |
# pytest tests -m "not raw" --junitxml=reports/junit-${{ matrix.python-version }}.xml --cov="$MODULE_PARENT/$MODULE_NAME" --cov-report=xml --cov-branch
# for now we only test that everything is importable
pip install setuptools # needed for pylidc to work
python -c "from $MODULE_NAME import *"
# - name: Generate coverage report
# if: "! github.event.pull_request.head.repo.fork "
# run: |
# coverage xml -o reports/coverage-${{ matrix.python-version }}.xml
# sed -i -e "s|$MODULE_PARENT/||g" reports/coverage-${{ matrix.python-version }}.xml
# sed -i -e "s|$(echo $MODULE_PARENT/ | tr "/" .)||g" reports/coverage-${{ matrix.python-version }}.xml
#
# - name: Upload artifacts
# if: "! github.event.pull_request.head.repo.fork "
# uses: actions/upload-artifact@v3
# with:
# name: reports-${{ matrix.python-version }}
# path: reports/*-${{ matrix.python-version }}.xml
# TODO: coverage is not informative in the CI anyway
# - name: Upload coverage results
# if: "! github.event.pull_request.head.repo.fork "
# uses: codecov/codecov-action@v3
# with:
# fail_ci_if_error: true
# files: reports/coverage-${{ matrix.python-version }}.xml
# verbose: true