-
Notifications
You must be signed in to change notification settings - Fork 19
147 lines (121 loc) · 4.54 KB
/
pytest.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
147
name: Pytest
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#packaging-workflow-data-as-artifacts
on:
pull_request:
paths:
- '**/*.py' # Watch for changes in any Python files
- 'pyproject.yml' # Watch for changes in the pyproject.yml file
push:
paths:
- '**/*.py' # Watch for changes in any Python files
- 'pyproject.yml' # Watch for changes in the pyproject.yml file
workflow_dispatch:
release:
types: [published]
jobs:
pytest:
if: github.event_name == 'pull_request' || (github.event_name == 'push' && !github.event.pull_request)
runs-on: ${{ matrix.os }}
strategy:
matrix:
# os: [ubuntu-latest, macos-latest, windows-latest]
# python-version: ["3.9", "3.10", "3.11", "3.12", "pypy3.9", "pypy3.10"]
os: [ubuntu-latest]
python-version: ["3.9", "3.13"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
- name: Install apt packages
run: |
sudo apt-get update
sudo apt-get install -y xvfb
- name: Test with pytest
id: pytest
continue-on-error: true
run: |
export DISPLAY=:99
Xvfb :99 -screen 0 1024x768x16 &
pytest --cov=ardupilot_methodic_configurator --cov-report=xml:tests/coverage.xml --md=tests/results-${{ matrix.python-version }}.md
- name: Display test results as github job summary
run: cat tests/results-${{ matrix.python-version }}.md >> $GITHUB_STEP_SUMMARY
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
- name: Upload coverage xml report
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}-xml
path: tests/coverage.xml
retention-days: 1
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}
path: .coverage
include-hidden-files: true
retention-days: 1
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
upload_coverage_to_coveralls:
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') && (success() || failure())
runs-on: ubuntu-latest
needs: pytest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download coverage xml report
uses: actions/download-artifact@v4
with:
name: coverage-3.9-xml
- name: Upload coverage xml report to coveralls.io
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
files: coverage.xml
# TODO: create a badge that presents the result of the Upload coverage xml report step
check_coverage:
if: success() || failure()
runs-on: ubuntu-latest
needs: pytest # This will ensure this job runs after 'pytest'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download coverage report
uses: actions/download-artifact@v4
with:
name: coverage-3.9
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9' # Match with the coverage report Python version
- name: Install dependencies
run: |
python -m pip install --upgrade pip coverage
- name: Check coverage
run: |
coverage report --fail-under=40
add_coverage_to_pullrequest:
if: github.event_name == 'pull_request' && (success() || failure())
runs-on: ubuntu-latest
needs: pytest # This will ensure this job runs after 'pytest'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download coverage xml report
uses: actions/download-artifact@v4
with:
name: coverage-3.9-xml
- name: Get Cover
uses: orgoro/[email protected]
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}