-
Notifications
You must be signed in to change notification settings - Fork 1
195 lines (168 loc) · 5.22 KB
/
CI.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# Copyright 2023 Jan-Hendrik Ewers
# SPDX-License-Identifier: GPL-3.0-only
name: CI
on:
push:
branches: [master, dev]
pull_request:
workflow_dispatch:
jobs:
run-tests:
name: Run tests
runs-on: ${{ matrix.platform }}
defaults:
run:
shell: bash -l {0}
strategy:
max-parallel: 1
matrix:
include:
- python-version: "3.11"
pytest-flags: ""
codecov: true
platform: "ubuntu-latest"
- python-version: "3.11"
pytest-flags: ""
codecov: false
platform: "ubuntu-latest"
- python-version: "3.10"
pytest-flags: ""
codecov: false
platform: "ubuntu-latest"
- python-version: "3.11"
pytest-flags: "--only-integration"
codecov: false
platform: "ubuntu-latest"
- python-version: "3.10"
pytest-flags: "--only-integration"
codecov: false
platform: "ubuntu-latest"
- python-version: "3.11"
pytest-flags: "--only-slow-integration"
codecov: false
platform: "ubuntu-latest"
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
cache: "pip"
python-version: ${{ matrix.python-version }}
cache-dependency-path: |
**/requirements*.txt
- uses: syphar/restore-virtualenv@v1
id: cache-virtualenv
- name: Install dependencies
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
run: |
pip install -r requirements.txt -r tests/requirements.txt
- name: Install jdrones
run: pip install .
- name: Run tests
run: |
NUMBA_DISABLE_JIT=${{ matrix.codecov }} \
PYTHONPATH=tests \
pytest tests \
--cov-report=xml \
--cov-branch \
--cov jdrones \
--cov-report term-missing \
${{ matrix.pytest-flags }}
- name: Upload code test coverage report
uses: codecov/[email protected]
if: ${{ ! contains(github.actor, '[bot]') && ( matrix.codecov ) && ( !env.ACT ) }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml,./coverage.info
fail_ci_if_error: true
build-python:
name: Build python
needs: run-tests
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Build wheels
run: pip wheel . --no-deps
run-doc-tests:
name: Run doctests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
cache: "pip"
python-version: "3.11"
cache-dependency-path: |
docs/requirements.txt
- name: Install dependencies
run: |
pip install . -r requirements.txt -r tests/requirements.txt
- name: Run doctests
run : |
python -m doctest $(\
find src/jdrones -iname "*.py" -not -iname "__main__.py" -not -iname "__init__.py"| \
tr '\n' ' ' \
)
docstr-cov:
runs-on: ubuntu-latest
if: ${{ ! contains(github.actor, '[bot]') }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: |
.github/workflows/requirements.docstr-cov.txt
- name: Install docstr-coverage
run: pip install -r .github/workflows/requirements.docstr-cov.txt
- name: Get SHAs
run: |
git config advice.detachedHead false
if [[ ${{ github.event_name }} == 'push' ]]; then
echo "BASE=$(git rev-parse --short HEAD^)" >> $GITHUB_ENV
echo "HEAD=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
elif [[ ${{ github.event_name }} == 'pull_request' ]]; then
echo "BASE=$(git rev-parse --short ${{ github.event.pull_request.base.sha }})" >> $GITHUB_ENV
echo "HEAD=$(git rev-parse --short ${{ github.event.pull_request.head.sha }})" >> $GITHUB_ENV
else
echo "Unexpected event trigger"
exit 1
fi
- name: Get $HEAD coverage
run: |
P=$(docstr-coverage -F0 -p)
if [ -z "$P" ]
then
P=0
fi
echo "HEAD_COV=$P" >> $GITHUB_ENV
- name: Get $BASE coverage
run: |
git checkout $BASE
P=$(docstr-coverage -F0 -p)
if [ -z "$P" ]
then
P=0
fi
echo "BASE_COV=$P" >> $GITHUB_ENV
- name: Test $HEAD coverage
run: |
printf "%s coverage was: %.2f%%\n" $BASE $BASE_COV
printf "%s coverage was: %.2f%%\n" $HEAD $HEAD_COV
printf "Difference: %.2f%%\n" $(python -c "print($HEAD_COV - $BASE_COV)")
git checkout $HEAD
docstr-coverage --fail-under=$BASE_COV