From f5ee280426a1328d1e6e03cc1dd68d6f6edc1a6b Mon Sep 17 00:00:00 2001 From: Thomas Hauschild <7961978+Morgy93@users.noreply.github.com> Date: Sun, 5 Jul 2026 09:38:27 +0200 Subject: [PATCH 1/3] feat: add badges for PHPUnit and code quality checks --- .github/workflows/phpcs.yml | 5 +- .github/workflows/phpunit.yml | 98 ++++++++++++++++++++++++++++++++++- README.md | 16 +++++- 3 files changed, 116 insertions(+), 3 deletions(-) diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index b81655e5..4a92660d 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -1,6 +1,9 @@ name: PHPCS -on: [pull_request] +on: + pull_request: + push: + branches: [main] permissions: contents: read diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 82b9d32d..17a92e5d 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -1,6 +1,9 @@ name: PHPUnit -on: [pull_request] +on: + pull_request: + push: + branches: [main] permissions: contents: read @@ -128,3 +131,96 @@ jobs: name: mutation-report path: reports/infection if-no-files-found: ignore + + # Publishes shields.io endpoint JSON (coverage %, mutation score) to the + # "badges" branch; the README badges read from there via raw.githubusercontent. + badges: + name: Publish badge data + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + needs: [phpunit, mutation] + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Download coverage report + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: coverage-report + path: reports + + - name: Download mutation report + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: mutation-report + path: reports/infection + + - name: Generate badge JSON + run: | + mkdir -p badge-data + python3 - <<'EOF' + import json + import re + import xml.etree.ElementTree as ET + + def color(value, bands): + for limit, name in bands: + if value < limit: + return name + return "brightgreen" + + metrics = ET.parse("reports/clover.xml").getroot().find("./project/metrics") + statements = int(metrics.get("statements")) + covered = int(metrics.get("coveredstatements")) + coverage = covered / statements * 100 if statements else 0.0 + + summary = open("reports/infection/summary.log").read() + + def count(label): + return int(re.search(rf"^{label}: (\d+)$", summary, re.M).group(1)) + + total = count("Total") + detected = ( + count("Killed by Test Framework") + + count("Killed by Static Analysis") + + count("Errored") + + count("Timed Out") + ) + covered_mutants = total - count("Not Covered") + msi = detected / covered_mutants * 100 if covered_mutants else 0.0 + + badges = { + "coverage.json": ("coverage", coverage, [(20, "red"), (50, "orange"), (75, "yellow")]), + "msi.json": ("mutation score", msi, [(50, "red"), (70, "orange"), (85, "yellow")]), + } + for filename, (label, value, bands) in badges.items(): + with open(f"badge-data/{filename}", "w") as handle: + json.dump( + { + "schemaVersion": 1, + "label": label, + "message": f"{value:.1f}%", + "color": color(value, bands), + }, + handle, + ) + EOF + + - name: Push badge data to badges branch + env: + GH_TOKEN: ${{ github.token }} + run: | + remote="https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" + if ! git clone --depth 1 --branch badges "${remote}" badges-branch; then + mkdir badges-branch + git -C badges-branch init -b badges + git -C badges-branch remote add origin "${remote}" + fi + cp badge-data/*.json badges-branch/ + cd badges-branch + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add . + git diff --cached --quiet || git commit -m "chore: update badge data" + git push origin badges diff --git a/README.md b/README.md index 7e4fd01d..4661455c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,20 @@ ![Mageforge Hero](./.github/assets/MageForge-Header.png) -[![Release](https://img.shields.io/github/v/release/OpenForgeProject/mageforge)](https://github.com/OpenForgeProject/mageforge/releases) [![License](https://img.shields.io/badge/license-GPL--3.0-blue)](LICENSE) +[![Release](https://img.shields.io/github/v/release/OpenForgeProject/mageforge)](https://github.com/OpenForgeProject/mageforge/releases) +[![License](https://img.shields.io/badge/license-GPL--3.0-blue)](LICENSE) +[![Downloads](https://img.shields.io/packagist/dt/openforgeproject/mageforge)](https://packagist.org/packages/openforgeproject/mageforge) +[![PHP](https://img.shields.io/packagist/dependency-v/openforgeproject/mageforge/php?logo=php&logoColor=white)](composer.json) + +[![PHPUnit](https://github.com/OpenForgeProject/mageforge/actions/workflows/phpunit.yml/badge.svg?branch=main)](https://github.com/OpenForgeProject/mageforge/actions/workflows/phpunit.yml) +[![Coverage](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FOpenForgeProject%2Fmageforge%2Fbadges%2Fcoverage.json)](https://github.com/OpenForgeProject/mageforge/actions/workflows/phpunit.yml) +[![Mutation Score](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FOpenForgeProject%2Fmageforge%2Fbadges%2Fmsi.json)](https://github.com/OpenForgeProject/mageforge/actions/workflows/phpunit.yml) +[![Functional Tests](https://github.com/OpenForgeProject/mageforge/actions/workflows/functional-tests.yml/badge.svg?branch=main)](https://github.com/OpenForgeProject/mageforge/actions/workflows/functional-tests.yml) +[![Magento Compatibility](https://github.com/OpenForgeProject/mageforge/actions/workflows/magento-compatibility.yml/badge.svg?branch=main)](https://github.com/OpenForgeProject/mageforge/actions/workflows/magento-compatibility.yml) + +[![PHPCS](https://github.com/OpenForgeProject/mageforge/actions/workflows/phpcs.yml/badge.svg?branch=main)](https://github.com/OpenForgeProject/mageforge/actions/workflows/phpcs.yml) +[![Static Analysis](https://github.com/OpenForgeProject/mageforge/actions/workflows/static-analysis.yml/badge.svg?branch=main)](https://github.com/OpenForgeProject/mageforge/actions/workflows/static-analysis.yml) +[![Lint](https://github.com/OpenForgeProject/mageforge/actions/workflows/lint.yml/badge.svg?branch=main)](https://github.com/OpenForgeProject/mageforge/actions/workflows/lint.yml) MageForge is a powerful CLI toolkit for Magento 2 front-end development. It simplifies theme building workflows, supports multiple theme types (Magento Standard, Hyvä, TailwindCSS, custom), and includes developer tools like the Frontend Inspector. @@ -91,6 +104,7 @@ The MageForge Inspector lets you inspect Magento blocks, templates, and performa ```bash bin/magento mageforge:theme:inspector enable ``` + The Inspector can also be enabled in Admin: `Stores > Configuration > MageForge > Frontend Inspector`) **Use in Browser:** From d814d0383b5a20fe2ed8204fa102435785696a58 Mon Sep 17 00:00:00 2001 From: Thomas Hauschild <7961978+Morgy93@users.noreply.github.com> Date: Sun, 5 Jul 2026 09:43:46 +0200 Subject: [PATCH 2/3] fix: update action versions in PHPCS workflow --- .github/workflows/phpcs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index 4a92660d..d4fcbb27 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - name: Set up PHP uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2 @@ -26,7 +26,7 @@ jobs: tools: composer:v2 - name: Cache Composer packages - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: ~/.composer/cache/files key: ${{ runner.os }}-composer-phpcs-${{ hashFiles('composer.json') }} From b2f0c531fab6312c88d247b5ea82267aceed31fc Mon Sep 17 00:00:00 2001 From: Thomas Hauschild <7961978+Morgy93@users.noreply.github.com> Date: Sun, 5 Jul 2026 09:46:18 +0200 Subject: [PATCH 3/3] fix: correct typo in Inspector configuration instructions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4661455c..6df19424 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ The MageForge Inspector lets you inspect Magento blocks, templates, and performa bin/magento mageforge:theme:inspector enable ``` -The Inspector can also be enabled in Admin: `Stores > Configuration > MageForge > Frontend Inspector`) +The Inspector can also be enabled in Admin: `Stores > Configuration > MageForge > Frontend Inspector` **Use in Browser:**