Skip to content

Run unit tests with coverage analysis #38

Run unit tests with coverage analysis

Run unit tests with coverage analysis #38

Workflow file for this run

# Copyright (c) 2023-2024 tracetronic GmbH
#
# SPDX-License-Identifier: MIT
name: Test
run-name: Run unit tests with coverage analysis
on:
push:
branches:
- main
pull_request:
jobs:
test:
strategy:
matrix:
py_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py_version }}
- name: Install virtual environment
run: pip3 install poetry
- name: Ensure Python version
run: poetry env use ${{ matrix.py_version }}
- name: Install dependencies
run: poetry install --without workflow --no-root
- name: Execute Tests and create test coverage report
run: poetry run pytest tests --cov=testguide_report_generator --cov-report=xml:coverage.xml
- name: Execute Test
run: poetry run pytest tests
- name: Upload test coverage report
uses: actions/upload-artifact@v3
with:
name: test-coverage-report
path: coverage.xml
publish-coverage:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
needs: test
steps:
- name: Download test coverage report
uses: actions/download-artifact@v3
with:
name: test-coverage-report
- name: Get Cover
uses: orgoro/coverage@v3
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
thresholdAll: 0.99