Skip to content

ci: fix test breaks and cleanup unneeded python_lint_check action (#10) #43

ci: fix test breaks and cleanup unneeded python_lint_check action (#10)

ci: fix test breaks and cleanup unneeded python_lint_check action (#10) #43

Workflow file for this run

name: test CI
on:
pull_request:
branches:
- main
# only trigger unit test CI when src or tests changed
paths:
- "src/**"
- "tests/**"
- ".github/workflows/test.yaml"
push:
branches:
- main
# only trigger unit test CI when src or tests changed
paths:
- "src/**"
- "tests/**"
- ".github/workflows/test.yaml"
# allow the test CI to be manually triggerred
workflow_dispatch:
jobs:
pytest_with_coverage_on_supported_os:
strategy:
fail-fast: true
matrix:
# currently we only need to ensure it is running on the following OS
# with OS-shipped python interpreter.
os: ["ubuntu-20.04", "ubuntu-22.04"]
include:
- os: ubuntu-22.04
python_version: "3.10"
- os: ubuntu-20.04
python_version: "3.8"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout commit
uses: actions/checkout@v4
with:
# sonarcloud needs main branch's ref
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
cache: "pip"
- name: Install package
run: |
python -m pip install -q -U pip
pip install -q .[dev]
- name: Execute pytest with coverage
run: |
coverage run -m pytest --junit-xml=test_result/pytest.xml
coverage xml -o test_result/coverage.xml
# export the coverage report to the comment!
- name: Add coverage report to PR comment
continue-on-error: true
uses: MishaKav/pytest-coverage-comment@v1.1.51
with:
pytest-xml-coverage-path: test_result/coverage.xml
junitxml-path: test_result/pytest.xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
pytest_on_supported_python_vers:
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- name: Checkout commit
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install package
run: |
python -m pip install -q -U pip
pip install -q .[dev]
- name: Execute pytest
run: pytest