Composite GitHub Action that bootstraps a disposable Magento 2 project on the runner and installs your module into it via a composer path repository.
Magento module repositories contain only module code — no project around it. This action builds that project in CI so Magento-dependent tooling can run, and makes it trivial to test against a matrix of PHP and Magento versions.
Add your repo.magento.com access keys as repository (or organization) secrets:
MAGENTO_AUTH_USER— public keyMAGENTO_AUTH_PASS— private key
jobs:
ci:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- { magento: "2.4.7-p3", php: "8.3" }
- { magento: "2.4.6-p8", php: "8.2" }
steps:
- uses: actions/checkout@v4
- uses: magebitcom/setup-magento-module@v1
id: magento
with:
magento-version: ${{ matrix.magento }}
php-version: ${{ matrix.php }}
composer-auth-user: ${{ secrets.MAGENTO_AUTH_USER }}
composer-auth-pass: ${{ secrets.MAGENTO_AUTH_PASS }}
- name: Unit tests
working-directory: ${{ steps.magento.outputs.project-path }}
run: vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist "${{ steps.magento.outputs.module-path }}/Test/Unit"
- name: PHPStan
working-directory: ${{ steps.magento.outputs.project-path }}
run: vendor/bin/phpstan analyse "${{ steps.magento.outputs.module-path }}"
- name: PHPCS
working-directory: ${{ steps.magento.outputs.project-path }}
run: vendor/bin/phpcs --standard=Magento2 "${{ steps.magento.outputs.module-path }}"| Input | Required | Default | Description |
|---|---|---|---|
php-version |
yes | — | PHP version for the runner (e.g. 8.3) |
magento-version |
yes | — | Version of magento/project-community-edition (e.g. 2.4.7-p3) |
composer-auth-user |
yes | — | repo.magento.com public key |
composer-auth-pass |
yes | — | repo.magento.com private key |
module-path |
no | ${{ github.workspace }} |
Path to the module checkout |
project-path |
no | ${{ runner.temp }}/magento |
Where the Magento project is created (must be outside module-path) |
composer-version |
no | 2 |
Composer major version |
php-extensions |
no | Magento's required extensions | PHP extensions passed to setup-php (comma-separated, replaces the default list) |
php-tools |
no | — | Extra tools passed to setup-php (comma-separated, appended after composer) |
php-ini-values |
no | — | ini-values passed to setup-php (e.g. memory_limit=-1) |
php-coverage |
no | none |
Coverage driver passed to setup-php (none, xdebug or pcov) |
extra-packages |
no | — | Additional composer packages installed as dev requirements of the project, whitespace-separated (e.g. phpstan/phpstan:^1.10 mockery/mockery) |
cache |
no | true |
Built-in composer package caching |
| Output | Description |
|---|---|
project-path |
Absolute path of the created Magento project — use as working-directory for tool steps |
module-path |
Absolute path of your module inside the project's vendor/ — point phpunit/phpstan/phpcs at it |
The checked-out module is registered as a composer path repository in the
freshly created project and required at @dev. A single composer update
then resolves Magento core, your module, and your module's own dependencies
together — so an incompatible magento/framework constraint or a broken
composer.json fails CI with a solver error before any test runs.
No database is installed and bin/magento setup:install never runs — unit
tests and static analysis don't need them.
MIT