-
Notifications
You must be signed in to change notification settings - Fork 100
86 lines (81 loc) · 2.93 KB
/
ci-test.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
name: Python package
on:
push:
branches: [ master ]
pull_request_target:
jobs:
test:
name: Check tests
runs-on: ${{ matrix.os }}
env:
# fix the python version and the operating system for codecoverage commentator
USING_COVERAGE_PY: '3.8'
USING_COVERAGE_OS: 'ubuntu-latest'
outputs:
# fix the results of pytest for unix
output1: ${{ steps.pytest.outputs.exit_code }}
strategy:
matrix:
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
python-version: ['3.6', '3.7', '3.8', '3.9']
# GitHub does not cancel all in-progress jobs if any matrix job fails
fail-fast: false
steps:
- uses: actions/checkout@v2
# Install python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
# Update pip and install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install . -r test_requirements.txt -r requirements.txt
# Pytest in windows
- name: Run PyTest windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
pytest | tee pytest-coverage.txt
# Pytest in unix. Exit code of this run captures the exit status of tee and not of pytest
# So, use $PIPESTATUS that holds the exit status of each command in pipeline
- name: Run PyTest unix
if: ${{ matrix.os != 'windows-latest' }}
id: pytest
run: |
pytest | tee pytest-coverage.txt;
exit_code=${PIPESTATUS[0]};
echo "::set-output name=exit_code::$exit_code"
# Сomment on the results of the test coverage
- name: Comment coverage
if: contains(env.USING_COVERAGE_PY, matrix.python-version) && contains(env.USING_COVERAGE_OS, matrix.os)
uses: MishaKav/[email protected]
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
# For unix workflow should have failed if exit code of pytest were 1
- name: Check fail of pytest unix
if: ${{ matrix.os != 'windows-latest' && steps.pytest.outputs.exit_code == 1 }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('Some tests failed!')
check_sphinx_build:
name: Check Sphinx build for docs
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Update pip and install dependencies
run: |
python -m pip install --upgrade pip
pip install -r docs/requirements.txt -r requirements.txt
- name: Run Sphinx
run: sphinx-build -W -b html docs /tmp/_docs_build