Skip to content

Refactor encoding, part 6 (requiem) #1097

Refactor encoding, part 6 (requiem)

Refactor encoding, part 6 (requiem) #1097

Workflow file for this run

# 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