From 645a2cf7bf75bef22732b319b640a74dc7df6832 Mon Sep 17 00:00:00 2001 From: Douglas Halse <4headmaster@gmail.com> Date: Sun, 14 Jun 2026 18:46:37 +0200 Subject: [PATCH] fix(dev env): :green_heart: Move coverage calculation to separate action --- .github/workflows/coverage.yml | 75 ++++++++++++++++++++++++++++++++++ .github/workflows/pytest.yml | 38 +---------------- 2 files changed, 76 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..5d9e10c --- /dev/null +++ b/.github/workflows/coverage.yml @@ -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 diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 22ebea4..2050a25 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -79,8 +79,7 @@ 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 @@ -88,38 +87,3 @@ jobs: 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 \ No newline at end of file