Skip to content

Commit

Permalink
Merge pull request #101 from wmalgadey/show-code-coverage
Browse files Browse the repository at this point in the history
test to output code coverage in PR and action summary
  • Loading branch information
wmalgadey authored Dec 20, 2024
2 parents 8c5cf4d + d60ba28 commit f5fd83f
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL Advanced"

on:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package
name: Lint and test multiple Python versions

on:
push:
Expand All @@ -10,7 +10,7 @@ on:
branches: [ master ]

jobs:
build:
lint:

runs-on: ubuntu-latest
strategy:
Expand All @@ -37,17 +37,37 @@ jobs:
options: "--check --verbose"
src: "./PyTado"
use_pyproject: true


test:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
- name: Run Tests with Coverage
run: |
pip install coverage pytest pytest-cov
coverage run -m pytest --maxfail=1 --disable-warnings -q
coverage report -m
coverage html
# Optionally upload coverage reports as an artifact.
- name: Upload coverage report
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-html-report
name: coverage-html-report-${{ matrix.python-version }}
path: coverage_html_report
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Upload Python Package
name: Build and deploy to pypi

on:
release:
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/report-test-results.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Output test results

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
report:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
- name: Run Tests with Coverage
run: |
pip install coverage pytest pytest-cov
coverage run -m pytest --maxfail=1 --disable-warnings -q
coverage report -m
coverage html
coverage xml
- name: Code Coverage Report
uses: irongut/[email protected]
with:
filename: coverage.xml
badge: true
fail_below_min: true
format: markdown
hide_branch_rate: false
hide_complexity: false
indicators: true
output: both
thresholds: '60 80'

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md

- name: Output code coverage results to GitHub step summary
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY

0 comments on commit f5fd83f

Please sign in to comment.