Skip to content

magebitcom/setup-magento-module-action

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

setup-magento-module

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.

Prerequisites

Add your repo.magento.com access keys as repository (or organization) secrets:

  • MAGENTO_AUTH_USER — public key
  • MAGENTO_AUTH_PASS — private key

Usage

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 }}"

Inputs

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

Outputs

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

How it installs your module

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.

License

MIT

About

Github Action for bootstrapping Magento installations for module repositories

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages