Repository navigation
Add Magento compatibility checks with GitHub Actions - #7
Open
lbajsarowicz wants to merge 1 commit into
Open
lbajsarowicz wants to merge 1 commit into
lbajsarowicz wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds one GitHub Actions workflow that checks every pull request, every push to
masterand 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 oneResultcheck 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:compileand static content deployment on a real Magento installWhy
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"]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"]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. TheResultjob 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 withbitexpert/phpstan-magento, which knows Magento's generated factories and proxies.composer.json:require-devwithmagento/magento-coding-standard,phpstan/phpstan,bitexpert/phpstan-magentoandphpstan/extension-installer, andallow-pluginsfor 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
pull_request, neverpull_request_target, so a pull request from a public fork runs with a read-only token and without secrets.contents: read(checkout) andpull-requests: read(list changed files). The matrix and result jobs get no permissions. The token cannot push, comment, create releases or publish anything.actions/checkoutdoes 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: falseon 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:
masterin this repository; GitHub only offers checks it has seen.master: enable "Require status checks to pass" and addResultonly. The per-version job names change with each Magento release;Resultfails whenever one of them fails.actions/checkout,actions/cache,actions/upload-artifact,actions/download-artifact) and addlbajsarowicz/github-action-magento-extension@*andlbajsarowicz/github-action-magento-matrix@*.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.