Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

name: Coverage

on:
push:
branches:
- main

jobs:
coverage:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt

- name: Install system dependencies (Xvfb & GL/SDL deps)
run: |
sudo apt-get update
sudo apt-get install -y xvfb x11-utils
sudo apt-get install -y libsdl2-2.0-0 libsdl2-dev libgles2-mesa-dev libgl1-mesa-dev libgl1-mesa-dri mesa-utils \
gstreamer1.0-plugins-base

- name: Run pytest under Xvfb (v3)
run: |
# start Xvfb automatically around the command
xvfb-run -a -s "-screen 0 1280x720x24" python -m pytest -vv -s \
--schema-version=v3 \
--cov=GuiApp --cov-branch --cov-report=html --cov-report=xml \
--cov-report=term-missing --junitxml=junit-v3.xml

- name: Upload coverage HTML report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: htmlcov/

- name: Extract coverage percentage
if: always()
id: coverage
run: |
import xml.etree.ElementTree as ET
tree = ET.parse("coverage.xml")
root = tree.getroot()
line_rate = float(root.attrib["line-rate"])
coverage_pct = round(line_rate * 100, 1)
print(f"Coverage: {coverage_pct}%")
# Write to GITHUB_OUTPUT for use in next step
import os
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write(f"coverage_pct={coverage_pct}\n")
shell: python

- name: Update coverage badge
if: always()
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: 96b0d2232509808bb39c8fd3a4435cc3
filename: coverage.json
label: coverage
message: ${{ steps.coverage.outputs.coverage_pct || 'N/A' }}%
color: brightgreen
namedLogo: pytest
38 changes: 1 addition & 37 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,47 +79,11 @@ jobs:
# start Xvfb automatically around the command
xvfb-run -a -s "-screen 0 1280x720x24" python -m pytest -vv -s \
--schema-version=${{ matrix.schema_version }} \
--cov=GuiApp --cov-branch --cov-report=html --cov-report=xml \
--cov-report=term-missing --junitxml=junit-${{ matrix.schema_version }}.xml
--junitxml=junit-${{ matrix.schema_version }}.xml

- name: Upload pytest test results
uses: actions/upload-artifact@v4
if: always()
with:
name: pytest-results-${{ matrix.schema_version }}
path: junit-${{ matrix.schema_version }}.xml

- name: Upload coverage HTML report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report-${{ matrix.schema_version }}
path: htmlcov/

- name: Extract coverage percentage
if: always()
id: coverage
run: |
import xml.etree.ElementTree as ET
tree = ET.parse("coverage.xml")
root = tree.getroot()
line_rate = float(root.attrib["line-rate"])
coverage_pct = round(line_rate * 100, 1)
print(f"Coverage: {coverage_pct}%")
# Write to GITHUB_OUTPUT for use in next step
import os
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write(f"coverage_pct={coverage_pct}\n")
shell: python

- name: Update coverage badge
if: always()
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: 96b0d2232509808bb39c8fd3a4435cc3
filename: coverage.json
label: coverage
message: ${{ steps.coverage.outputs.coverage_pct || 'N/A' }}%
color: brightgreen
namedLogo: pytest
Loading