-
Notifications
You must be signed in to change notification settings - Fork 77
116 lines (93 loc) · 3.23 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
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
# SPDX-License-Identifier: MIT
# Copyright (c) 2023 MBition GmbH
name: odxtools CI pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
lint-coding-style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Setup up YaPF formatting linter
run: |
pip install toml yapf
- name: Lint coding style (yapf)
# make yapf fail if any file needs to be re-formatted
run: |
yapf -r --diff examples/ odxtools/ tests/
linting:
runs-on: ubuntu-latest
strategy:
matrix:
# restrict the matrix to the oldest and the latest Python
# version being supported by odxtools
python-version: ["3.8", "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}}
cache: "pip"
- name: Install odxtools development and testing dependencies
run: |
pip install --upgrade pip
pip install .
pip install .[test]
- name: Static type checking (mypy)
run: |
# remove '# type:' comments in version.py which mypy-3.8
# stumbles over. for some reason, mypy cannot be
# instructed to ignore 'version.py'
sed -i "s/# type:.*//" odxtools/version.py
python -m mypy .
- name: Lint code quality (ruff)
run: |
ruff .
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
# restrict the matrix to the oldest and the latest Python
# version being supported by odxtools
python-version: ["3.8", "3.12"]
# due to the slow windows runners, we refrain from testing every python
# version on windows-latest
exclude:
- os: windows-latest
python-version: "3.8"
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{matrix.python-version}}
uses: actions/setup-python@v4
with:
python-version: ${{matrix.python-version}}
cache: "pip"
# dependency are likely cached on ubuntu-latest
- name: Install odxtools development and testing dependencies
run: |
pip install --upgrade pip
pip install .
pip install .[test]
- name: Create somersault.pdx
run: |
python -m examples.mksomersaultpdx examples/somersault.pdx
- name: Run unit tests and report line coverage
# use `python -m pytest ...` instead of `pytest ...` to avoid setting the
# PYTHONPATH environment variable. This works independently of the OS.
# For some reason, pytest-cov reports invalid line coverage. As a remedy,
# we utilize the `coverage` module instead of `pytest-cov`. Line coverage
# shall be only reported for the odxtools package, i.e., the tests package
# should be ignored.
run: |
coverage run --source=odxtools --omit=tests -m pytest
coverage report