Skip to content

ci: refactor tests to use standard actions - #120

Merged
JellyBellyDev merged 1 commit into
badges:masterfrom
garak:ci-refactoring
Jul 15, 2026
Merged

ci: refactor tests to use standard actions#120
JellyBellyDev merged 1 commit into
badges:masterfrom
garak:ci-refactoring

Conversation

@garak

@garak garak commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

This should fix #110 (including the latest 8.5)

@garak

garak commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator Author

A few notes on the reason why some tests are changed (after a first failure):

  • GDTextSizeCalculator depends on imagettfbbox, and that can vary slightly by font/rendering stack across environments.
  • Some tests asserted exact pixel values (e.g. in tests/Calculator/GDTextSizeCalculatorTest.php).
  • Some renderer tests compared full SVG strings against fixtures while using live GD measurements (e.g. tests/Render/SvgForTheBadgeRendererTest.php, tests/Render/SvgSocialRenderTest.php), so tiny width drift caused whole-string mismatches.

So tests were changed to reflect intent:

  • In tests/Calculator/GDTextSizeCalculatorTest.php, we used assertEqualsWithDelta(...) for metric-sensitive cases.
  • In tests/Render/SvgForTheBadgeRendererTest.php and tests/Render/SvgSocialRenderTest.php, we mocked TextSizeCalculatorInterface to keep widths deterministic for fixture comparisons.

Why this is correct:

  • We didn’t change badge rendering behaviour intentionally.
  • Failures were from environment-dependent measurement noise, not logic regressions.
  • These tests are now stable and still verify what they should: renderer layout logic and output structure, without coupling to host-specific font rasterisation quirks.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the project’s CI to use standard GitHub Actions for PHP setup and Composer installs, enabling the test matrix to run on newer PHP versions (including 8.4 and 8.5) while keeping SVG-rendering tests deterministic across environments.

Changes:

  • Refactors GitHub Actions workflows to use shivammathur/setup-php and ramsey/composer-install, and expands the PHPUnit matrix to PHP 8.4 and 8.5.
  • Updates renderer tests to mock TextSizeCalculatorInterface (instead of relying on GD/font metrics) for stable fixture comparisons.
  • Loosens a couple of GD text width assertions using assertEqualsWithDelta to reduce environment-dependent flakiness.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/Render/SvgSocialRenderTest.php Replaces GD calculator usage with a mocked TextSizeCalculatorInterface returning stable widths.
tests/Render/SvgForTheBadgeRendererTest.php Replaces GD calculator usage with a mocked TextSizeCalculatorInterface returning stable widths.
tests/Calculator/GDTextSizeCalculatorTest.php Uses delta-based float assertions for more stable GD width checks.
.github/workflows/release.yml Updates checkout action version.
.github/workflows/php.yml Moves to setup-php + composer-install and expands the PHP test matrix to 8.4/8.5.
.github/workflows/commit-lint.yml Updates runner version and checkout action version.
.gitattributes Updates export-ignore rules (e.g., root *.md, compose.yml, doc, test/dev tooling files).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@garak
garak requested a review from JellyBellyDev July 11, 2026 08:46

@JellyBellyDev JellyBellyDev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!!!

LGTM 👍

@JellyBellyDev
JellyBellyDev merged commit d1f2537 into badges:master Jul 15, 2026
7 checks passed
@garak
garak deleted the ci-refactoring branch July 15, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test on PHP 8.4+

3 participants