Skip to content

Add Magento compatibility checks with GitHub Actions - #7

Open
lbajsarowicz wants to merge 1 commit into
MultiSafepay:masterfrom
lbajsarowicz:ci/magento-extension-check
Open

lbajsarowicz wants to merge 1 commit into
MultiSafepay:masterfrom
lbajsarowicz:ci/magento-extension-check

Conversation

@lbajsarowicz

@lbajsarowicz lbajsarowicz commented Nov 18, 2026 •

Copy link
Copy Markdown

This pull request adds one GitHub Actions workflow that checks every pull request, every push to master and the merge queue if you use one: Composer validation, PHP lint, the Magento coding standard, setup:di:compile, static content deployment, the existing unit tests and PHPStan. It runs on the latest patch of each supported Magento Open Source release line, on the lowest and highest PHP version that release supports, and reports one Result check that you can require before merging.

Your existing CI

The repository already runs magento-integration-tests.yml, phpcs.yml, phpstan.yml, release-actions.yml. Magento Check runs next to these workflows and changes none of them. It adds:

  • setup:di:compile and static content deployment on a real Magento install
  • Magento 2.4.7, 2.4.8 and 2.4.9, refreshed automatically when a release comes out
  • PHP lint on each supported PHP version

Why

  • Compilation errors, code a newer PHP rejects and failing unit tests show up in the pull request instead of in a shop after a release.
  • The list of releases refreshes on every run, so a new Magento or PHP release is tested as soon as it is supported, without a change to the workflow.
  • PHPCS and PHPStan findings are shown inline in "Files changed". PHPCS checks the PHP and PHTML files a pull request changes (the whole file, including code that was already there), not the whole module. PHPStan analyses the whole module at level 1.
  • No account, no Magento credentials and no repository secrets. Compute on GitHub-hosted runners is free for public repositories; runs use Actions concurrency and keep their reports as artifacts for 7 days.

How it works

flowchart LR
    T["Pull request / push"] --> M["Version matrix"]
    M --> J1["Magento 2.4.7 @ PHP 8.2"]
    M --> J2["..."]
    M --> J3["Magento 2.4.9 @ PHP 8.5"]
    J1 & J2 & J3 --> R["Result"]
Loading

Each Magento and PHP combination is one job:

flowchart LR
    S["composer validate<br/>PHP lint"] --> I["Install Magento<br/>+ this module"]
    I --> P["PHPCS"]
    I --> C["di:compile<br/>static content"]
    C --> U["Unit tests"]
    C --> PS["PHPStan"]
Loading

Each job runs in the Warden image wardenenv/php-fpm:<php>-magento2, which carries PHP with every extension Magento needs, Composer and Node.js. Magento is installed from the public Mage-OS mirror with the module from the pull request's checkout, and the job checks that the installed module is that checkout. Unit tests and PHPStan run only after compilation and static content deployment succeed. The Result job collects every combination into one table in the run summary and fails when any check failed.

Files added or changed:

  • .github/workflows/magento-check.yml: the workflow.
  • phpcs.xml.dist: the Magento 2 coding standard.
  • phpstan.neon: level 1 with bitexpert/phpstan-magento, which knows Magento's generated factories and proxies.
  • composer.json: require-dev with magento/magento-coding-standard, phpstan/phpstan, bitexpert/phpstan-magento and phpstan/extension-installer, and allow-plugins for the two Composer plugins that register the coding standard and the PHPStan extension. Both are root-only settings: a shop that requires this package installs none of it.

Security and trust

  • I get no access to this repository: no collaborator invitation, no GitHub App, no secrets.
  • The workflow runs on pull_request, never pull_request_target, so a pull request from a public fork runs with a read-only token and without secrets.
  • The check jobs get a temporary token with contents: read (checkout) and pull-requests: read (list changed files). The matrix and result jobs get no permissions. The token cannot push, comment, create releases or publish anything.
  • actions/checkout does not store the token in the checkout (persist-credentials: false).

The checks are two actions I maintain, github-action-magento-extension and github-action-magento-matrix (MIT). They execute code in your CI: Composer installs Magento and the tools (including the two plugins above), then compilation, unit tests and PHPStan run PHP. Both are referenced by their major tag @v1, so fixes reach you without another pull request, and also run without your review. If you want to review every update, pin both actions to a commit SHA (@<sha> # v1.0.0) and update them yourself or with Dependabot.

Network traffic from the runner: the matrix action asks magento.watch for the list of supported releases and sends this repository's public name in its User-Agent (set send-repository: false on that step to leave it out; if the request fails, a bundled list is used). The runner pulls the Warden PHP image from Docker Hub; Composer downloads Magento from the Mage-OS mirror and the tools from Packagist. Logs and reports stay in GitHub Actions. This is a compatibility check, not a dependency audit: Composer's advisory blocking is switched off inside the temporary Magento project so older release lines still install.

After merging (optional)

Merging the workflow does not make the check required. To block merges on it, in Settings:

  1. Let the workflow run once on master in this repository; GitHub only offers checks it has seen.
  2. Rules › Rulesets (or Branches for classic branch protection) for master: enable "Require status checks to pass" and add Result only. The per-version job names change with each Magento release; Result fails whenever one of them fails.
  3. Actions › General, if the repository allows only selected actions: allow actions created by GitHub (actions/checkout, actions/cache, actions/upload-artifact, actions/download-artifact) and add lbajsarowicz/github-action-magento-extension@* and lbajsarowicz/github-action-magento-matrix@*.
  4. Actions › General › Approval for running fork pull request workflows from contributors: keep GitHub's default or anything stricter.

Test plan

The workflow ran on this branch in my fork on 5 combinations (2.4.7-p10 @ PHP 8.2, 2.4.7-p10 @ PHP 8.3, 2.4.8-p5 @ PHP 8.3, 2.4.8-p5 @ PHP 8.4, 2.4.9 @ PHP 8.5); every check passed or had nothing to run; each combination took at most 4 minutes: run.

Runs composer validate, PHP lint, PHPCS, setup:di:compile, static content deploy, unit tests and PHPStan on the latest patch of every supported Magento Open Source release line, in Warden's PHP images.
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.

1 participant