-
Notifications
You must be signed in to change notification settings - Fork 76
106 lines (84 loc) · 2.96 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
# 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:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Setup up Linter
run: |
pip install toml yapf
- name: Lint code formatting
# make yapf fail if any file needs to be formatted
run: |
yapf -r --diff examples/ odxtools/ tests/
static-type-checking:
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.11"]
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 -r requirements.txt
pip install -r test-requirements.txt
- name: Static type checking with mypy
run: |
python -m mypy --ignore-missing-imports odxtools examples tests
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.11"]
# 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 -r requirements.txt
pip install -r test-requirements.txt
- 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