-
Notifications
You must be signed in to change notification settings - Fork 1
95 lines (84 loc) · 2.51 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
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
name: test CI
on:
pull_request:
branches:
- main
# only trigger unit test CI when src or tests changed
paths:
- "src/**"
- "tests/**"
- ".github/workflows/test.yaml"
push:
branches:
- main
# only trigger unit test CI when src or tests changed
paths:
- "src/**"
- "tests/**"
- ".github/workflows/test.yaml"
# allow the test CI to be manually triggerred
workflow_dispatch:
jobs:
pytest_with_coverage_on_supported_os:
strategy:
fail-fast: true
matrix:
# currently we only need to ensure it is running on the following OS
# with OS-shipped python interpreter.
os: ["ubuntu-20.04", "ubuntu-22.04"]
include:
- os: ubuntu-22.04
python_version: "3.10"
- os: ubuntu-20.04
python_version: "3.8"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout commit
uses: actions/checkout@v4
with:
# sonarcloud needs main branch's ref
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
cache: "pip"
- name: Install package
run: |
python -m pip install -q -U pip
pip install -q .[dev]
- name: Execute pytest with coverage
run: |
coverage run -m pytest --junit-xml=test_result/pytest.xml
coverage xml -o test_result/coverage.xml
# export the coverage report to the comment!
- name: Add coverage report to PR comment
continue-on-error: true
uses: MishaKav/pytest-coverage-comment@v1.1.51
with:
pytest-xml-coverage-path: test_result/coverage.xml
junitxml-path: test_result/pytest.xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
pytest_on_supported_python_vers:
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- name: Checkout commit
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install package
run: |
python -m pip install -q -U pip
pip install -q .[dev]
- name: Execute pytest
run: pytest