Repository files navigation

GitHub Actions for Magento 2 Extensions

This repository's aim is to provide a set of open sourced GitHub actions to write better tested Magento 2 extensions.

Available Actions

Magento Coding Standard

Provides an action that can be used in your GitHub workflow to execute the latest Magento Coding Standard.

Screenshot

Screenshot Coding Style Action

How to use it

In your GitHub repository add the below as .github/workflows/coding-standard.yml

name: ExtDN M2 Coding Standard
on:
push:
branches:
- master
pull_request:
jobs:
static:
name: M2 Coding Standard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-coding-standard@master

Magento Integration tests

Run your Magento 2 integration tests via this Github Action. All you need is to add your tests. This action will set up the needed Magento services and set up. Please note this action will perform a Composer installation so will provide additional confirmation that this works as well.

Screenshot

Screenshot Mess Detector Action

How to use it

In your GitHub repository add the below as .github/workflows/integration.yml

name: ExtDN M2 Integration Tests
on:
push:
branches:
- master
pull_request:
jobs:
integration-tests:
name: Magento 2 Integration Tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.4
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
es:
image: docker.io/wardenenv/elasticsearch:8.18
ports:
- 9200:9200
env:
'discovery.type': single-node
'xpack.security.enabled': false
ES_JAVA_OPTS: "-Xms64m -Xmx512m"
options: --health-cmd="curl localhost:9200/_cluster/health?wait_for_status=yellow&timeout=60s" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v6
- name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'

The following images are provided for use

PhpImage
8.5extdn/github-actions-m2/magento-integration-tests/8.5@master
8.4extdn/github-actions-m2/magento-integration-tests/8.4@master
8.3extdn/github-actions-m2/magento-integration-tests/8.3@master
8.2extdn/github-actions-m2/magento-integration-tests/8.2@master
8.1extdn/github-actions-m2/magento-integration-tests/8.1@master

The following inputs are required:

withdescription
module_nameYour Magento module name. Example: Foo_Bar
composer_nameYour composer name. Example: foo/magento2-bar
magento_versionMagento 2 Open Source version number. Example: 2.4.0

The default phpunit.xml configuration will check the following folders for *Test files:

  • Test/Integration
  • tests/Integration
  • tests/integration

If this phpunit file does not work for you can provide a relative path to your own PHPUnit file via phpunit_file

 - name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'
phpunit_file: './path/to/phpunit.xml'

Sometimes it may be needed to run additional commands before tests can run. For example to add or remove additional dependencies. Use the input magento_pre_install_script to provide a relative path to this script. Example

 - name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'
magento_pre_install_script: './.github/integration-test-setup.sh'

Magento Mess Detector

Provides an action that can be used in your GitHub workflow to execute the PHP Mess Detector rules included in Magento 2 (link).

Screenshot

Screenshot Mess Detector Action

How to use it

In your GitHub repository add the below as .github/workflows/mess-detector.yml

name: ExtDN M2 Mess Detector
on:
push:
branches:
- master
pull_request:
jobs:
phpmd:
name: M2 Mess Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-mess-detector@master

Magento Copy Paste Detector

Provides an action that can be used in your GitHub workflow to execute the PHP Copy Paste Detector rules included in Magento 2 (link).

How to use it

In your GitHub repository add the below as .github/workflows/copy-paste-detector.yml

name: ExtDN M2 Copy Paste Detector
on:
push:
branches:
- master
pull_request:
jobs:
phpmd:
name: M2 Copy Paste Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-copy-paste-detector@master

Magento PHPStan

Provides an action that can be used in your GitHub workflow to execute the PHPStan rules included in Magento 2 (link).

Screenshot

Screenshot PHPStan Action

How to use it

In your GitHub repository add the below as .github/workflows/phpstan.yml

name: ExtDN M2 PHPStan
on:
push:
branches:
- master
pull_request:
jobs:
phpstan:
name: M2 PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-phpstan/8.5@master
with:
composer_name: foo/magento2-foobar

Magento Performance Smoke Test

Provides an action that can be used in your GitHub workflow to execute blackfire.io profiling before and after installing extension code.

How to use it

In your GitHub repository add the below as .github/workflows/performance.yml

name: ExtDN M2 Performance Testing
on:
push:
branches:
- master
pull_request:
jobs:
performance:
name: M2 Performance Testing
runs-on: ubuntu-latest
env:
DOCKER_COMPOSE_FILE: "./docker-compose.yml"
EXTENSION_NAME: "Foo_Bar"
EXTENSION_PACKAGE_NAME: "foo/magento2-foobar"
steps:
- uses: actions/checkout@v6
name: Checkout files
with:
path: extension
- name: Get composer cache directory
id: composer-cache
run: "echo \"::set-output name=dir::$(composer config cache-dir)\""
working-directory: ./extension
- name: Cache dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Prepare ExtDN performance testing
uses: extdn/github-actions-m2/magento-performance-setup@master
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Install Magento
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -T php-fpm
bash -c 'cd /var/www/html/m2 && sudo chown www-data: -R /var/www/html/m2 && ls -al && id
&& php -f bin/magento setup:install --base-url=http://magento2.test/ --backend-frontname=admin --db-host=mysql --db-name=magento_performance_tests --db-user=root --db-password=123123q --admin-user=admin@example.com --admin-password=password1 --admin-email=admin@example.com --admin-firstname=firstname --admin-lastname=lastname'
- name: Generate Performance Fixtures
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -T php-fpm
bash -c 'cd /var/www/html/m2
&& php -f bin/magento setup:performance:generate-fixtures setup/performance-toolkit/profiles/ce/small.xml
&& php -f bin/magento cache:enable
&& php -f bin/magento cache:disable block_html full_page'
- name: Run Blackfire
id: blackfire-baseline
run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} run blackfire-agent blackfire --json curl http://magento2.test/category-1/category-1-1.html > ${{ github.workspace }}/baseline.json
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Install Extension
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -e EXTENSION_BRANCH=${GITHUB_REF#refs/heads/} -T php-fpm
bash -c 'cd /var/www/html/m2
&& php -f vendor/composer/composer/bin/composer config repo.extension path /var/www/html/extension
&& php -f vendor/composer/composer/bin/composer require ${{ env.EXTENSION_PACKAGE_NAME }}:dev-$EXTENSION_BRANCH#${{ github.sha }}
&& php -f bin/magento module:enable ${{ env.EXTENSION_NAME }}
&& php -f bin/magento setup:upgrade
&& php -f bin/magento cache:enable
&& php -f bin/magento cache:disable block_html full_page'
- name: Run Blackfire Again
id: blackfire-after
run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} run blackfire-agent blackfire --json curl http://magento2.test/category-1/category-1-1.html > ${{ github.workspace }}/after.json
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Compare Performance Results
uses: extdn/github-actions-m2/magento-performance-compare@master

Change these environment variables:

EXTENSION_NAME: "Foo_Bar"
EXTENSION_PACKAGE_NAME: "foo/magento2-foobar"

Additionally please create the following Github Secrets for this repository with the values available in your blackfire.io account:

BLACKFIRE_CLIENT_ID
BLACKFIRE_CLIENT_TOKEN
BLACKFIRE_SERVER_ID
BLACKFIRE_SERVER_TOKEN

Magento Marketplace repository

With various of the GitHub Actions, you will need to setup Magento, with all of its packages. Normally, you would use the official Magento Marketplace for this, which also requires you to setup authentication.

Amongst the environment variables, there is a variable REPOSITORY_URL which defaults - when kept empty - to https://repo-magento-mirror.fooman.co.nz/ - a mirror of the Magento Marketplace, that removes the need of authentication.

If you want to use the original Magento Marketplace anyway, reset the REPOSITORY_URL variable and add the marketplace credentials like this:

jobs:
unit-tests:
env:
REPOSITORY_URL: https://repo.magento.com/MAGENTO_MARKETPLACE_USERNAME: ${{ secrets.MAGENTO_MARKETPLACE_USERNAME }}MAGENTO_MARKETPLACE_PASSWORD: ${{ secrets.MAGENTO_MARKETPLACE_PASSWORD }}

Next, make sure to add the secrets MAGENTO_MARKETPLACE_USERNAME and MAGENTO_MARKETPLACE_PASSWORD to your GitHub repository under Settings > Secrets. Tip: You could also use the secrets to define the module and composer name: This way your workflow file remains generic.

Alternatively, the credentials could also be hard-coded :(

jobs:
unit-tests:
env:
MAGENTO_MARKETPLACE_USERNAME: fooMAGENTO_MARKETPLACE_PASSWORD: bar

About

No description, website, or topics provided.

Resources

Stars

142 stars

Watchers

14 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

GitHub Actions for Magento 2 Extensions

This repository's aim is to provide a set of open sourced GitHub actions to write better tested Magento 2 extensions.

Available Actions

Magento Coding Standard

Provides an action that can be used in your GitHub workflow to execute the latest Magento Coding Standard.

Screenshot

Screenshot Coding Style Action

How to use it

In your GitHub repository add the below as .github/workflows/coding-standard.yml

name: ExtDN M2 Coding Standard
on:
push:
branches:
- master
pull_request:
jobs:
static:
name: M2 Coding Standard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-coding-standard@master

Magento Integration tests

Run your Magento 2 integration tests via this Github Action. All you need is to add your tests. This action will set up the needed Magento services and set up. Please note this action will perform a Composer installation so will provide additional confirmation that this works as well.

Screenshot

Screenshot Mess Detector Action

How to use it

In your GitHub repository add the below as .github/workflows/integration.yml

name: ExtDN M2 Integration Tests
on:
push:
branches:
- master
pull_request:
jobs:
integration-tests:
name: Magento 2 Integration Tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.4
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
es:
image: docker.io/wardenenv/elasticsearch:8.18
ports:
- 9200:9200
env:
'discovery.type': single-node
'xpack.security.enabled': false
ES_JAVA_OPTS: "-Xms64m -Xmx512m"
options: --health-cmd="curl localhost:9200/_cluster/health?wait_for_status=yellow&timeout=60s" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v6
- name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'

The following images are provided for use

PhpImage
8.5extdn/github-actions-m2/magento-integration-tests/8.5@master
8.4extdn/github-actions-m2/magento-integration-tests/8.4@master
8.3extdn/github-actions-m2/magento-integration-tests/8.3@master
8.2extdn/github-actions-m2/magento-integration-tests/8.2@master
8.1extdn/github-actions-m2/magento-integration-tests/8.1@master

The following inputs are required:

withdescription
module_nameYour Magento module name. Example: Foo_Bar
composer_nameYour composer name. Example: foo/magento2-bar
magento_versionMagento 2 Open Source version number. Example: 2.4.0

The default phpunit.xml configuration will check the following folders for *Test files:

  • Test/Integration
  • tests/Integration
  • tests/integration

If this phpunit file does not work for you can provide a relative path to your own PHPUnit file via phpunit_file

 - name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'
phpunit_file: './path/to/phpunit.xml'

Sometimes it may be needed to run additional commands before tests can run. For example to add or remove additional dependencies. Use the input magento_pre_install_script to provide a relative path to this script. Example

 - name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'
magento_pre_install_script: './.github/integration-test-setup.sh'

Magento Mess Detector

Provides an action that can be used in your GitHub workflow to execute the PHP Mess Detector rules included in Magento 2 (link).

Screenshot

Screenshot Mess Detector Action

How to use it

In your GitHub repository add the below as .github/workflows/mess-detector.yml

name: ExtDN M2 Mess Detector
on:
push:
branches:
- master
pull_request:
jobs:
phpmd:
name: M2 Mess Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-mess-detector@master

Magento Copy Paste Detector

Provides an action that can be used in your GitHub workflow to execute the PHP Copy Paste Detector rules included in Magento 2 (link).

How to use it

In your GitHub repository add the below as .github/workflows/copy-paste-detector.yml

name: ExtDN M2 Copy Paste Detector
on:
push:
branches:
- master
pull_request:
jobs:
phpmd:
name: M2 Copy Paste Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-copy-paste-detector@master

Magento PHPStan

Provides an action that can be used in your GitHub workflow to execute the PHPStan rules included in Magento 2 (link).

Screenshot

Screenshot PHPStan Action

How to use it

In your GitHub repository add the below as .github/workflows/phpstan.yml

name: ExtDN M2 PHPStan
on:
push:
branches:
- master
pull_request:
jobs:
phpstan:
name: M2 PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-phpstan/8.5@master
with:
composer_name: foo/magento2-foobar

Magento Performance Smoke Test

Provides an action that can be used in your GitHub workflow to execute blackfire.io profiling before and after installing extension code.

How to use it

In your GitHub repository add the below as .github/workflows/performance.yml

name: ExtDN M2 Performance Testing
on:
push:
branches:
- master
pull_request:
jobs:
performance:
name: M2 Performance Testing
runs-on: ubuntu-latest
env:
DOCKER_COMPOSE_FILE: "./docker-compose.yml"
EXTENSION_NAME: "Foo_Bar"
EXTENSION_PACKAGE_NAME: "foo/magento2-foobar"
steps:
- uses: actions/checkout@v6
name: Checkout files
with:
path: extension
- name: Get composer cache directory
id: composer-cache
run: "echo \"::set-output name=dir::$(composer config cache-dir)\""
working-directory: ./extension
- name: Cache dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Prepare ExtDN performance testing
uses: extdn/github-actions-m2/magento-performance-setup@master
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Install Magento
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -T php-fpm
bash -c 'cd /var/www/html/m2 && sudo chown www-data: -R /var/www/html/m2 && ls -al && id
&& php -f bin/magento setup:install --base-url=http://magento2.test/ --backend-frontname=admin --db-host=mysql --db-name=magento_performance_tests --db-user=root --db-password=123123q --admin-user=admin@example.com --admin-password=password1 --admin-email=admin@example.com --admin-firstname=firstname --admin-lastname=lastname'
- name: Generate Performance Fixtures
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -T php-fpm
bash -c 'cd /var/www/html/m2
&& php -f bin/magento setup:performance:generate-fixtures setup/performance-toolkit/profiles/ce/small.xml
&& php -f bin/magento cache:enable
&& php -f bin/magento cache:disable block_html full_page'
- name: Run Blackfire
id: blackfire-baseline
run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} run blackfire-agent blackfire --json curl http://magento2.test/category-1/category-1-1.html > ${{ github.workspace }}/baseline.json
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Install Extension
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -e EXTENSION_BRANCH=${GITHUB_REF#refs/heads/} -T php-fpm
bash -c 'cd /var/www/html/m2
&& php -f vendor/composer/composer/bin/composer config repo.extension path /var/www/html/extension
&& php -f vendor/composer/composer/bin/composer require ${{ env.EXTENSION_PACKAGE_NAME }}:dev-$EXTENSION_BRANCH#${{ github.sha }}
&& php -f bin/magento module:enable ${{ env.EXTENSION_NAME }}
&& php -f bin/magento setup:upgrade
&& php -f bin/magento cache:enable
&& php -f bin/magento cache:disable block_html full_page'
- name: Run Blackfire Again
id: blackfire-after
run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} run blackfire-agent blackfire --json curl http://magento2.test/category-1/category-1-1.html > ${{ github.workspace }}/after.json
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Compare Performance Results
uses: extdn/github-actions-m2/magento-performance-compare@master

Change these environment variables:

EXTENSION_NAME: "Foo_Bar"
EXTENSION_PACKAGE_NAME: "foo/magento2-foobar"

Additionally please create the following Github Secrets for this repository with the values available in your blackfire.io account:

BLACKFIRE_CLIENT_ID
BLACKFIRE_CLIENT_TOKEN
BLACKFIRE_SERVER_ID
BLACKFIRE_SERVER_TOKEN

Magento Marketplace repository

With various of the GitHub Actions, you will need to setup Magento, with all of its packages. Normally, you would use the official Magento Marketplace for this, which also requires you to setup authentication.

Amongst the environment variables, there is a variable REPOSITORY_URL which defaults - when kept empty - to https://repo-magento-mirror.fooman.co.nz/ - a mirror of the Magento Marketplace, that removes the need of authentication.

If you want to use the original Magento Marketplace anyway, reset the REPOSITORY_URL variable and add the marketplace credentials like this:

jobs:
unit-tests:
env:
REPOSITORY_URL: https://repo.magento.com/MAGENTO_MARKETPLACE_USERNAME: ${{ secrets.MAGENTO_MARKETPLACE_USERNAME }}MAGENTO_MARKETPLACE_PASSWORD: ${{ secrets.MAGENTO_MARKETPLACE_PASSWORD }}

Next, make sure to add the secrets MAGENTO_MARKETPLACE_USERNAME and MAGENTO_MARKETPLACE_PASSWORD to your GitHub repository under Settings > Secrets. Tip: You could also use the secrets to define the module and composer name: This way your workflow file remains generic.

Alternatively, the credentials could also be hard-coded :(

jobs:
unit-tests:
env:
MAGENTO_MARKETPLACE_USERNAME: fooMAGENTO_MARKETPLACE_PASSWORD: bar

About

No description, website, or topics provided.

Resources

Stars

142 stars

Watchers

14 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

GitHub Actions for Magento 2 Extensions

This repository's aim is to provide a set of open sourced GitHub actions to write better tested Magento 2 extensions.

Available Actions

Magento Coding Standard

Provides an action that can be used in your GitHub workflow to execute the latest Magento Coding Standard.

Screenshot

Screenshot Coding Style Action

How to use it

In your GitHub repository add the below as .github/workflows/coding-standard.yml

name: ExtDN M2 Coding Standard
on:
push:
branches:
- master
pull_request:
jobs:
static:
name: M2 Coding Standard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-coding-standard@master

Magento Integration tests

Run your Magento 2 integration tests via this Github Action. All you need is to add your tests. This action will set up the needed Magento services and set up. Please note this action will perform a Composer installation so will provide additional confirmation that this works as well.

Screenshot

Screenshot Mess Detector Action

How to use it

In your GitHub repository add the below as .github/workflows/integration.yml

name: ExtDN M2 Integration Tests
on:
push:
branches:
- master
pull_request:
jobs:
integration-tests:
name: Magento 2 Integration Tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.4
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
es:
image: docker.io/wardenenv/elasticsearch:8.18
ports:
- 9200:9200
env:
'discovery.type': single-node
'xpack.security.enabled': false
ES_JAVA_OPTS: "-Xms64m -Xmx512m"
options: --health-cmd="curl localhost:9200/_cluster/health?wait_for_status=yellow&timeout=60s" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v6
- name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'

The following images are provided for use

PhpImage
8.5extdn/github-actions-m2/magento-integration-tests/8.5@master
8.4extdn/github-actions-m2/magento-integration-tests/8.4@master
8.3extdn/github-actions-m2/magento-integration-tests/8.3@master
8.2extdn/github-actions-m2/magento-integration-tests/8.2@master
8.1extdn/github-actions-m2/magento-integration-tests/8.1@master

The following inputs are required:

withdescription
module_nameYour Magento module name. Example: Foo_Bar
composer_nameYour composer name. Example: foo/magento2-bar
magento_versionMagento 2 Open Source version number. Example: 2.4.0

The default phpunit.xml configuration will check the following folders for *Test files:

  • Test/Integration
  • tests/Integration
  • tests/integration

If this phpunit file does not work for you can provide a relative path to your own PHPUnit file via phpunit_file

 - name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'
phpunit_file: './path/to/phpunit.xml'

Sometimes it may be needed to run additional commands before tests can run. For example to add or remove additional dependencies. Use the input magento_pre_install_script to provide a relative path to this script. Example

 - name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'
magento_pre_install_script: './.github/integration-test-setup.sh'

Magento Mess Detector

Provides an action that can be used in your GitHub workflow to execute the PHP Mess Detector rules included in Magento 2 (link).

Screenshot

Screenshot Mess Detector Action

How to use it

In your GitHub repository add the below as .github/workflows/mess-detector.yml

name: ExtDN M2 Mess Detector
on:
push:
branches:
- master
pull_request:
jobs:
phpmd:
name: M2 Mess Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-mess-detector@master

Magento Copy Paste Detector

Provides an action that can be used in your GitHub workflow to execute the PHP Copy Paste Detector rules included in Magento 2 (link).

How to use it

In your GitHub repository add the below as .github/workflows/copy-paste-detector.yml

name: ExtDN M2 Copy Paste Detector
on:
push:
branches:
- master
pull_request:
jobs:
phpmd:
name: M2 Copy Paste Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-copy-paste-detector@master

Magento PHPStan

Provides an action that can be used in your GitHub workflow to execute the PHPStan rules included in Magento 2 (link).

Screenshot

Screenshot PHPStan Action

How to use it

In your GitHub repository add the below as .github/workflows/phpstan.yml

name: ExtDN M2 PHPStan
on:
push:
branches:
- master
pull_request:
jobs:
phpstan:
name: M2 PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-phpstan/8.5@master
with:
composer_name: foo/magento2-foobar

Magento Performance Smoke Test

Provides an action that can be used in your GitHub workflow to execute blackfire.io profiling before and after installing extension code.

How to use it

In your GitHub repository add the below as .github/workflows/performance.yml

name: ExtDN M2 Performance Testing
on:
push:
branches:
- master
pull_request:
jobs:
performance:
name: M2 Performance Testing
runs-on: ubuntu-latest
env:
DOCKER_COMPOSE_FILE: "./docker-compose.yml"
EXTENSION_NAME: "Foo_Bar"
EXTENSION_PACKAGE_NAME: "foo/magento2-foobar"
steps:
- uses: actions/checkout@v6
name: Checkout files
with:
path: extension
- name: Get composer cache directory
id: composer-cache
run: "echo \"::set-output name=dir::$(composer config cache-dir)\""
working-directory: ./extension
- name: Cache dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Prepare ExtDN performance testing
uses: extdn/github-actions-m2/magento-performance-setup@master
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Install Magento
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -T php-fpm
bash -c 'cd /var/www/html/m2 && sudo chown www-data: -R /var/www/html/m2 && ls -al && id
&& php -f bin/magento setup:install --base-url=http://magento2.test/ --backend-frontname=admin --db-host=mysql --db-name=magento_performance_tests --db-user=root --db-password=123123q --admin-user=admin@example.com --admin-password=password1 --admin-email=admin@example.com --admin-firstname=firstname --admin-lastname=lastname'
- name: Generate Performance Fixtures
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -T php-fpm
bash -c 'cd /var/www/html/m2
&& php -f bin/magento setup:performance:generate-fixtures setup/performance-toolkit/profiles/ce/small.xml
&& php -f bin/magento cache:enable
&& php -f bin/magento cache:disable block_html full_page'
- name: Run Blackfire
id: blackfire-baseline
run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} run blackfire-agent blackfire --json curl http://magento2.test/category-1/category-1-1.html > ${{ github.workspace }}/baseline.json
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Install Extension
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -e EXTENSION_BRANCH=${GITHUB_REF#refs/heads/} -T php-fpm
bash -c 'cd /var/www/html/m2
&& php -f vendor/composer/composer/bin/composer config repo.extension path /var/www/html/extension
&& php -f vendor/composer/composer/bin/composer require ${{ env.EXTENSION_PACKAGE_NAME }}:dev-$EXTENSION_BRANCH#${{ github.sha }}
&& php -f bin/magento module:enable ${{ env.EXTENSION_NAME }}
&& php -f bin/magento setup:upgrade
&& php -f bin/magento cache:enable
&& php -f bin/magento cache:disable block_html full_page'
- name: Run Blackfire Again
id: blackfire-after
run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} run blackfire-agent blackfire --json curl http://magento2.test/category-1/category-1-1.html > ${{ github.workspace }}/after.json
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Compare Performance Results
uses: extdn/github-actions-m2/magento-performance-compare@master

Change these environment variables:

EXTENSION_NAME: "Foo_Bar"
EXTENSION_PACKAGE_NAME: "foo/magento2-foobar"

Additionally please create the following Github Secrets for this repository with the values available in your blackfire.io account:

BLACKFIRE_CLIENT_ID
BLACKFIRE_CLIENT_TOKEN
BLACKFIRE_SERVER_ID
BLACKFIRE_SERVER_TOKEN

Magento Marketplace repository

With various of the GitHub Actions, you will need to setup Magento, with all of its packages. Normally, you would use the official Magento Marketplace for this, which also requires you to setup authentication.

Amongst the environment variables, there is a variable REPOSITORY_URL which defaults - when kept empty - to https://repo-magento-mirror.fooman.co.nz/ - a mirror of the Magento Marketplace, that removes the need of authentication.

If you want to use the original Magento Marketplace anyway, reset the REPOSITORY_URL variable and add the marketplace credentials like this:

jobs:
unit-tests:
env:
REPOSITORY_URL: https://repo.magento.com/MAGENTO_MARKETPLACE_USERNAME: ${{ secrets.MAGENTO_MARKETPLACE_USERNAME }}MAGENTO_MARKETPLACE_PASSWORD: ${{ secrets.MAGENTO_MARKETPLACE_PASSWORD }}

Next, make sure to add the secrets MAGENTO_MARKETPLACE_USERNAME and MAGENTO_MARKETPLACE_PASSWORD to your GitHub repository under Settings > Secrets. Tip: You could also use the secrets to define the module and composer name: This way your workflow file remains generic.

Alternatively, the credentials could also be hard-coded :(

jobs:
unit-tests:
env:
MAGENTO_MARKETPLACE_USERNAME: fooMAGENTO_MARKETPLACE_PASSWORD: bar

About

No description, website, or topics provided.

Resources

Stars

142 stars

Watchers

14 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

GitHub Actions for Magento 2 Extensions

This repository's aim is to provide a set of open sourced GitHub actions to write better tested Magento 2 extensions.

Available Actions

Magento Coding Standard

Provides an action that can be used in your GitHub workflow to execute the latest Magento Coding Standard.

Screenshot

Screenshot Coding Style Action

How to use it

In your GitHub repository add the below as .github/workflows/coding-standard.yml

name: ExtDN M2 Coding Standard
on:
push:
branches:
- master
pull_request:
jobs:
static:
name: M2 Coding Standard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-coding-standard@master

Magento Integration tests

Run your Magento 2 integration tests via this Github Action. All you need is to add your tests. This action will set up the needed Magento services and set up. Please note this action will perform a Composer installation so will provide additional confirmation that this works as well.

Screenshot

Screenshot Mess Detector Action

How to use it

In your GitHub repository add the below as .github/workflows/integration.yml

name: ExtDN M2 Integration Tests
on:
push:
branches:
- master
pull_request:
jobs:
integration-tests:
name: Magento 2 Integration Tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.4
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
es:
image: docker.io/wardenenv/elasticsearch:8.18
ports:
- 9200:9200
env:
'discovery.type': single-node
'xpack.security.enabled': false
ES_JAVA_OPTS: "-Xms64m -Xmx512m"
options: --health-cmd="curl localhost:9200/_cluster/health?wait_for_status=yellow&timeout=60s" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v6
- name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'

The following images are provided for use

PhpImage
8.5extdn/github-actions-m2/magento-integration-tests/8.5@master
8.4extdn/github-actions-m2/magento-integration-tests/8.4@master
8.3extdn/github-actions-m2/magento-integration-tests/8.3@master
8.2extdn/github-actions-m2/magento-integration-tests/8.2@master
8.1extdn/github-actions-m2/magento-integration-tests/8.1@master

The following inputs are required:

withdescription
module_nameYour Magento module name. Example: Foo_Bar
composer_nameYour composer name. Example: foo/magento2-bar
magento_versionMagento 2 Open Source version number. Example: 2.4.0

The default phpunit.xml configuration will check the following folders for *Test files:

  • Test/Integration
  • tests/Integration
  • tests/integration

If this phpunit file does not work for you can provide a relative path to your own PHPUnit file via phpunit_file

 - name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'
phpunit_file: './path/to/phpunit.xml'

Sometimes it may be needed to run additional commands before tests can run. For example to add or remove additional dependencies. Use the input magento_pre_install_script to provide a relative path to this script. Example

 - name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'
magento_pre_install_script: './.github/integration-test-setup.sh'

Magento Mess Detector

Provides an action that can be used in your GitHub workflow to execute the PHP Mess Detector rules included in Magento 2 (link).

Screenshot

Screenshot Mess Detector Action

How to use it

In your GitHub repository add the below as .github/workflows/mess-detector.yml

name: ExtDN M2 Mess Detector
on:
push:
branches:
- master
pull_request:
jobs:
phpmd:
name: M2 Mess Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-mess-detector@master

Magento Copy Paste Detector

Provides an action that can be used in your GitHub workflow to execute the PHP Copy Paste Detector rules included in Magento 2 (link).

How to use it

In your GitHub repository add the below as .github/workflows/copy-paste-detector.yml

name: ExtDN M2 Copy Paste Detector
on:
push:
branches:
- master
pull_request:
jobs:
phpmd:
name: M2 Copy Paste Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-copy-paste-detector@master

Magento PHPStan

Provides an action that can be used in your GitHub workflow to execute the PHPStan rules included in Magento 2 (link).

Screenshot

Screenshot PHPStan Action

How to use it

In your GitHub repository add the below as .github/workflows/phpstan.yml

name: ExtDN M2 PHPStan
on:
push:
branches:
- master
pull_request:
jobs:
phpstan:
name: M2 PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-phpstan/8.5@master
with:
composer_name: foo/magento2-foobar

Magento Performance Smoke Test

Provides an action that can be used in your GitHub workflow to execute blackfire.io profiling before and after installing extension code.

How to use it

In your GitHub repository add the below as .github/workflows/performance.yml

name: ExtDN M2 Performance Testing
on:
push:
branches:
- master
pull_request:
jobs:
performance:
name: M2 Performance Testing
runs-on: ubuntu-latest
env:
DOCKER_COMPOSE_FILE: "./docker-compose.yml"
EXTENSION_NAME: "Foo_Bar"
EXTENSION_PACKAGE_NAME: "foo/magento2-foobar"
steps:
- uses: actions/checkout@v6
name: Checkout files
with:
path: extension
- name: Get composer cache directory
id: composer-cache
run: "echo \"::set-output name=dir::$(composer config cache-dir)\""
working-directory: ./extension
- name: Cache dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Prepare ExtDN performance testing
uses: extdn/github-actions-m2/magento-performance-setup@master
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Install Magento
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -T php-fpm
bash -c 'cd /var/www/html/m2 && sudo chown www-data: -R /var/www/html/m2 && ls -al && id
&& php -f bin/magento setup:install --base-url=http://magento2.test/ --backend-frontname=admin --db-host=mysql --db-name=magento_performance_tests --db-user=root --db-password=123123q --admin-user=admin@example.com --admin-password=password1 --admin-email=admin@example.com --admin-firstname=firstname --admin-lastname=lastname'
- name: Generate Performance Fixtures
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -T php-fpm
bash -c 'cd /var/www/html/m2
&& php -f bin/magento setup:performance:generate-fixtures setup/performance-toolkit/profiles/ce/small.xml
&& php -f bin/magento cache:enable
&& php -f bin/magento cache:disable block_html full_page'
- name: Run Blackfire
id: blackfire-baseline
run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} run blackfire-agent blackfire --json curl http://magento2.test/category-1/category-1-1.html > ${{ github.workspace }}/baseline.json
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Install Extension
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -e EXTENSION_BRANCH=${GITHUB_REF#refs/heads/} -T php-fpm
bash -c 'cd /var/www/html/m2
&& php -f vendor/composer/composer/bin/composer config repo.extension path /var/www/html/extension
&& php -f vendor/composer/composer/bin/composer require ${{ env.EXTENSION_PACKAGE_NAME }}:dev-$EXTENSION_BRANCH#${{ github.sha }}
&& php -f bin/magento module:enable ${{ env.EXTENSION_NAME }}
&& php -f bin/magento setup:upgrade
&& php -f bin/magento cache:enable
&& php -f bin/magento cache:disable block_html full_page'
- name: Run Blackfire Again
id: blackfire-after
run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} run blackfire-agent blackfire --json curl http://magento2.test/category-1/category-1-1.html > ${{ github.workspace }}/after.json
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Compare Performance Results
uses: extdn/github-actions-m2/magento-performance-compare@master

Change these environment variables:

EXTENSION_NAME: "Foo_Bar"
EXTENSION_PACKAGE_NAME: "foo/magento2-foobar"

Additionally please create the following Github Secrets for this repository with the values available in your blackfire.io account:

BLACKFIRE_CLIENT_ID
BLACKFIRE_CLIENT_TOKEN
BLACKFIRE_SERVER_ID
BLACKFIRE_SERVER_TOKEN

Magento Marketplace repository

With various of the GitHub Actions, you will need to setup Magento, with all of its packages. Normally, you would use the official Magento Marketplace for this, which also requires you to setup authentication.

Amongst the environment variables, there is a variable REPOSITORY_URL which defaults - when kept empty - to https://repo-magento-mirror.fooman.co.nz/ - a mirror of the Magento Marketplace, that removes the need of authentication.

If you want to use the original Magento Marketplace anyway, reset the REPOSITORY_URL variable and add the marketplace credentials like this:

jobs:
unit-tests:
env:
REPOSITORY_URL: https://repo.magento.com/MAGENTO_MARKETPLACE_USERNAME: ${{ secrets.MAGENTO_MARKETPLACE_USERNAME }}MAGENTO_MARKETPLACE_PASSWORD: ${{ secrets.MAGENTO_MARKETPLACE_PASSWORD }}

Next, make sure to add the secrets MAGENTO_MARKETPLACE_USERNAME and MAGENTO_MARKETPLACE_PASSWORD to your GitHub repository under Settings > Secrets. Tip: You could also use the secrets to define the module and composer name: This way your workflow file remains generic.

Alternatively, the credentials could also be hard-coded :(

jobs:
unit-tests:
env:
MAGENTO_MARKETPLACE_USERNAME: fooMAGENTO_MARKETPLACE_PASSWORD: bar

About

No description, website, or topics provided.

Resources

Stars

142 stars

Watchers

14 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

GitHub Actions for Magento 2 Extensions

This repository's aim is to provide a set of open sourced GitHub actions to write better tested Magento 2 extensions.

Available Actions

Magento Coding Standard

Provides an action that can be used in your GitHub workflow to execute the latest Magento Coding Standard.

Screenshot

Screenshot Coding Style Action

How to use it

In your GitHub repository add the below as .github/workflows/coding-standard.yml

name: ExtDN M2 Coding Standard
on:
push:
branches:
- master
pull_request:
jobs:
static:
name: M2 Coding Standard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-coding-standard@master

Magento Integration tests

Run your Magento 2 integration tests via this Github Action. All you need is to add your tests. This action will set up the needed Magento services and set up. Please note this action will perform a Composer installation so will provide additional confirmation that this works as well.

Screenshot

Screenshot Mess Detector Action

How to use it

In your GitHub repository add the below as .github/workflows/integration.yml

name: ExtDN M2 Integration Tests
on:
push:
branches:
- master
pull_request:
jobs:
integration-tests:
name: Magento 2 Integration Tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.4
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
es:
image: docker.io/wardenenv/elasticsearch:8.18
ports:
- 9200:9200
env:
'discovery.type': single-node
'xpack.security.enabled': false
ES_JAVA_OPTS: "-Xms64m -Xmx512m"
options: --health-cmd="curl localhost:9200/_cluster/health?wait_for_status=yellow&timeout=60s" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v6
- name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'

The following images are provided for use

PhpImage
8.5extdn/github-actions-m2/magento-integration-tests/8.5@master
8.4extdn/github-actions-m2/magento-integration-tests/8.4@master
8.3extdn/github-actions-m2/magento-integration-tests/8.3@master
8.2extdn/github-actions-m2/magento-integration-tests/8.2@master
8.1extdn/github-actions-m2/magento-integration-tests/8.1@master

The following inputs are required:

withdescription
module_nameYour Magento module name. Example: Foo_Bar
composer_nameYour composer name. Example: foo/magento2-bar
magento_versionMagento 2 Open Source version number. Example: 2.4.0

The default phpunit.xml configuration will check the following folders for *Test files:

  • Test/Integration
  • tests/Integration
  • tests/integration

If this phpunit file does not work for you can provide a relative path to your own PHPUnit file via phpunit_file

 - name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'
phpunit_file: './path/to/phpunit.xml'

Sometimes it may be needed to run additional commands before tests can run. For example to add or remove additional dependencies. Use the input magento_pre_install_script to provide a relative path to this script. Example

 - name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'
magento_pre_install_script: './.github/integration-test-setup.sh'

Magento Mess Detector

Provides an action that can be used in your GitHub workflow to execute the PHP Mess Detector rules included in Magento 2 (link).

Screenshot

Screenshot Mess Detector Action

How to use it

In your GitHub repository add the below as .github/workflows/mess-detector.yml

name: ExtDN M2 Mess Detector
on:
push:
branches:
- master
pull_request:
jobs:
phpmd:
name: M2 Mess Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-mess-detector@master

Magento Copy Paste Detector

Provides an action that can be used in your GitHub workflow to execute the PHP Copy Paste Detector rules included in Magento 2 (link).

How to use it

In your GitHub repository add the below as .github/workflows/copy-paste-detector.yml

name: ExtDN M2 Copy Paste Detector
on:
push:
branches:
- master
pull_request:
jobs:
phpmd:
name: M2 Copy Paste Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-copy-paste-detector@master

Magento PHPStan

Provides an action that can be used in your GitHub workflow to execute the PHPStan rules included in Magento 2 (link).

Screenshot

Screenshot PHPStan Action

How to use it

In your GitHub repository add the below as .github/workflows/phpstan.yml

name: ExtDN M2 PHPStan
on:
push:
branches:
- master
pull_request:
jobs:
phpstan:
name: M2 PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-phpstan/8.5@master
with:
composer_name: foo/magento2-foobar

Magento Performance Smoke Test

Provides an action that can be used in your GitHub workflow to execute blackfire.io profiling before and after installing extension code.

How to use it

In your GitHub repository add the below as .github/workflows/performance.yml

name: ExtDN M2 Performance Testing
on:
push:
branches:
- master
pull_request:
jobs:
performance:
name: M2 Performance Testing
runs-on: ubuntu-latest
env:
DOCKER_COMPOSE_FILE: "./docker-compose.yml"
EXTENSION_NAME: "Foo_Bar"
EXTENSION_PACKAGE_NAME: "foo/magento2-foobar"
steps:
- uses: actions/checkout@v6
name: Checkout files
with:
path: extension
- name: Get composer cache directory
id: composer-cache
run: "echo \"::set-output name=dir::$(composer config cache-dir)\""
working-directory: ./extension
- name: Cache dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Prepare ExtDN performance testing
uses: extdn/github-actions-m2/magento-performance-setup@master
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Install Magento
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -T php-fpm
bash -c 'cd /var/www/html/m2 && sudo chown www-data: -R /var/www/html/m2 && ls -al && id
&& php -f bin/magento setup:install --base-url=http://magento2.test/ --backend-frontname=admin --db-host=mysql --db-name=magento_performance_tests --db-user=root --db-password=123123q --admin-user=admin@example.com --admin-password=password1 --admin-email=admin@example.com --admin-firstname=firstname --admin-lastname=lastname'
- name: Generate Performance Fixtures
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -T php-fpm
bash -c 'cd /var/www/html/m2
&& php -f bin/magento setup:performance:generate-fixtures setup/performance-toolkit/profiles/ce/small.xml
&& php -f bin/magento cache:enable
&& php -f bin/magento cache:disable block_html full_page'
- name: Run Blackfire
id: blackfire-baseline
run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} run blackfire-agent blackfire --json curl http://magento2.test/category-1/category-1-1.html > ${{ github.workspace }}/baseline.json
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Install Extension
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -e EXTENSION_BRANCH=${GITHUB_REF#refs/heads/} -T php-fpm
bash -c 'cd /var/www/html/m2
&& php -f vendor/composer/composer/bin/composer config repo.extension path /var/www/html/extension
&& php -f vendor/composer/composer/bin/composer require ${{ env.EXTENSION_PACKAGE_NAME }}:dev-$EXTENSION_BRANCH#${{ github.sha }}
&& php -f bin/magento module:enable ${{ env.EXTENSION_NAME }}
&& php -f bin/magento setup:upgrade
&& php -f bin/magento cache:enable
&& php -f bin/magento cache:disable block_html full_page'
- name: Run Blackfire Again
id: blackfire-after
run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} run blackfire-agent blackfire --json curl http://magento2.test/category-1/category-1-1.html > ${{ github.workspace }}/after.json
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Compare Performance Results
uses: extdn/github-actions-m2/magento-performance-compare@master

Change these environment variables:

EXTENSION_NAME: "Foo_Bar"
EXTENSION_PACKAGE_NAME: "foo/magento2-foobar"

Additionally please create the following Github Secrets for this repository with the values available in your blackfire.io account:

BLACKFIRE_CLIENT_ID
BLACKFIRE_CLIENT_TOKEN
BLACKFIRE_SERVER_ID
BLACKFIRE_SERVER_TOKEN

Magento Marketplace repository

With various of the GitHub Actions, you will need to setup Magento, with all of its packages. Normally, you would use the official Magento Marketplace for this, which also requires you to setup authentication.

Amongst the environment variables, there is a variable REPOSITORY_URL which defaults - when kept empty - to https://repo-magento-mirror.fooman.co.nz/ - a mirror of the Magento Marketplace, that removes the need of authentication.

If you want to use the original Magento Marketplace anyway, reset the REPOSITORY_URL variable and add the marketplace credentials like this:

jobs:
unit-tests:
env:
REPOSITORY_URL: https://repo.magento.com/MAGENTO_MARKETPLACE_USERNAME: ${{ secrets.MAGENTO_MARKETPLACE_USERNAME }}MAGENTO_MARKETPLACE_PASSWORD: ${{ secrets.MAGENTO_MARKETPLACE_PASSWORD }}

Next, make sure to add the secrets MAGENTO_MARKETPLACE_USERNAME and MAGENTO_MARKETPLACE_PASSWORD to your GitHub repository under Settings > Secrets. Tip: You could also use the secrets to define the module and composer name: This way your workflow file remains generic.

Alternatively, the credentials could also be hard-coded :(

jobs:
unit-tests:
env:
MAGENTO_MARKETPLACE_USERNAME: fooMAGENTO_MARKETPLACE_PASSWORD: bar

About

No description, website, or topics provided.

Resources

Stars

142 stars

Watchers

14 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

GitHub Actions for Magento 2 Extensions

This repository's aim is to provide a set of open sourced GitHub actions to write better tested Magento 2 extensions.

Available Actions

Magento Coding Standard

Provides an action that can be used in your GitHub workflow to execute the latest Magento Coding Standard.

Screenshot

Screenshot Coding Style Action

How to use it

In your GitHub repository add the below as .github/workflows/coding-standard.yml

name: ExtDN M2 Coding Standard
on:
push:
branches:
- master
pull_request:
jobs:
static:
name: M2 Coding Standard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-coding-standard@master

Magento Integration tests

Run your Magento 2 integration tests via this Github Action. All you need is to add your tests. This action will set up the needed Magento services and set up. Please note this action will perform a Composer installation so will provide additional confirmation that this works as well.

Screenshot

Screenshot Mess Detector Action

How to use it

In your GitHub repository add the below as .github/workflows/integration.yml

name: ExtDN M2 Integration Tests
on:
push:
branches:
- master
pull_request:
jobs:
integration-tests:
name: Magento 2 Integration Tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.4
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
es:
image: docker.io/wardenenv/elasticsearch:8.18
ports:
- 9200:9200
env:
'discovery.type': single-node
'xpack.security.enabled': false
ES_JAVA_OPTS: "-Xms64m -Xmx512m"
options: --health-cmd="curl localhost:9200/_cluster/health?wait_for_status=yellow&timeout=60s" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v6
- name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'

The following images are provided for use

PhpImage
8.5extdn/github-actions-m2/magento-integration-tests/8.5@master
8.4extdn/github-actions-m2/magento-integration-tests/8.4@master
8.3extdn/github-actions-m2/magento-integration-tests/8.3@master
8.2extdn/github-actions-m2/magento-integration-tests/8.2@master
8.1extdn/github-actions-m2/magento-integration-tests/8.1@master

The following inputs are required:

withdescription
module_nameYour Magento module name. Example: Foo_Bar
composer_nameYour composer name. Example: foo/magento2-bar
magento_versionMagento 2 Open Source version number. Example: 2.4.0

The default phpunit.xml configuration will check the following folders for *Test files:

  • Test/Integration
  • tests/Integration
  • tests/integration

If this phpunit file does not work for you can provide a relative path to your own PHPUnit file via phpunit_file

 - name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'
phpunit_file: './path/to/phpunit.xml'

Sometimes it may be needed to run additional commands before tests can run. For example to add or remove additional dependencies. Use the input magento_pre_install_script to provide a relative path to this script. Example

 - name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'
magento_pre_install_script: './.github/integration-test-setup.sh'

Magento Mess Detector

Provides an action that can be used in your GitHub workflow to execute the PHP Mess Detector rules included in Magento 2 (link).

Screenshot

Screenshot Mess Detector Action

How to use it

In your GitHub repository add the below as .github/workflows/mess-detector.yml

name: ExtDN M2 Mess Detector
on:
push:
branches:
- master
pull_request:
jobs:
phpmd:
name: M2 Mess Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-mess-detector@master

Magento Copy Paste Detector

Provides an action that can be used in your GitHub workflow to execute the PHP Copy Paste Detector rules included in Magento 2 (link).

How to use it

In your GitHub repository add the below as .github/workflows/copy-paste-detector.yml

name: ExtDN M2 Copy Paste Detector
on:
push:
branches:
- master
pull_request:
jobs:
phpmd:
name: M2 Copy Paste Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-copy-paste-detector@master

Magento PHPStan

Provides an action that can be used in your GitHub workflow to execute the PHPStan rules included in Magento 2 (link).

Screenshot

Screenshot PHPStan Action

How to use it

In your GitHub repository add the below as .github/workflows/phpstan.yml

name: ExtDN M2 PHPStan
on:
push:
branches:
- master
pull_request:
jobs:
phpstan:
name: M2 PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-phpstan/8.5@master
with:
composer_name: foo/magento2-foobar

Magento Performance Smoke Test

Provides an action that can be used in your GitHub workflow to execute blackfire.io profiling before and after installing extension code.

How to use it

In your GitHub repository add the below as .github/workflows/performance.yml

name: ExtDN M2 Performance Testing
on:
push:
branches:
- master
pull_request:
jobs:
performance:
name: M2 Performance Testing
runs-on: ubuntu-latest
env:
DOCKER_COMPOSE_FILE: "./docker-compose.yml"
EXTENSION_NAME: "Foo_Bar"
EXTENSION_PACKAGE_NAME: "foo/magento2-foobar"
steps:
- uses: actions/checkout@v6
name: Checkout files
with:
path: extension
- name: Get composer cache directory
id: composer-cache
run: "echo \"::set-output name=dir::$(composer config cache-dir)\""
working-directory: ./extension
- name: Cache dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Prepare ExtDN performance testing
uses: extdn/github-actions-m2/magento-performance-setup@master
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Install Magento
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -T php-fpm
bash -c 'cd /var/www/html/m2 && sudo chown www-data: -R /var/www/html/m2 && ls -al && id
&& php -f bin/magento setup:install --base-url=http://magento2.test/ --backend-frontname=admin --db-host=mysql --db-name=magento_performance_tests --db-user=root --db-password=123123q --admin-user=admin@example.com --admin-password=password1 --admin-email=admin@example.com --admin-firstname=firstname --admin-lastname=lastname'
- name: Generate Performance Fixtures
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -T php-fpm
bash -c 'cd /var/www/html/m2
&& php -f bin/magento setup:performance:generate-fixtures setup/performance-toolkit/profiles/ce/small.xml
&& php -f bin/magento cache:enable
&& php -f bin/magento cache:disable block_html full_page'
- name: Run Blackfire
id: blackfire-baseline
run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} run blackfire-agent blackfire --json curl http://magento2.test/category-1/category-1-1.html > ${{ github.workspace }}/baseline.json
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Install Extension
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -e EXTENSION_BRANCH=${GITHUB_REF#refs/heads/} -T php-fpm
bash -c 'cd /var/www/html/m2
&& php -f vendor/composer/composer/bin/composer config repo.extension path /var/www/html/extension
&& php -f vendor/composer/composer/bin/composer require ${{ env.EXTENSION_PACKAGE_NAME }}:dev-$EXTENSION_BRANCH#${{ github.sha }}
&& php -f bin/magento module:enable ${{ env.EXTENSION_NAME }}
&& php -f bin/magento setup:upgrade
&& php -f bin/magento cache:enable
&& php -f bin/magento cache:disable block_html full_page'
- name: Run Blackfire Again
id: blackfire-after
run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} run blackfire-agent blackfire --json curl http://magento2.test/category-1/category-1-1.html > ${{ github.workspace }}/after.json
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Compare Performance Results
uses: extdn/github-actions-m2/magento-performance-compare@master

Change these environment variables:

EXTENSION_NAME: "Foo_Bar"
EXTENSION_PACKAGE_NAME: "foo/magento2-foobar"

Additionally please create the following Github Secrets for this repository with the values available in your blackfire.io account:

BLACKFIRE_CLIENT_ID
BLACKFIRE_CLIENT_TOKEN
BLACKFIRE_SERVER_ID
BLACKFIRE_SERVER_TOKEN

Magento Marketplace repository

With various of the GitHub Actions, you will need to setup Magento, with all of its packages. Normally, you would use the official Magento Marketplace for this, which also requires you to setup authentication.

Amongst the environment variables, there is a variable REPOSITORY_URL which defaults - when kept empty - to https://repo-magento-mirror.fooman.co.nz/ - a mirror of the Magento Marketplace, that removes the need of authentication.

If you want to use the original Magento Marketplace anyway, reset the REPOSITORY_URL variable and add the marketplace credentials like this:

jobs:
unit-tests:
env:
REPOSITORY_URL: https://repo.magento.com/MAGENTO_MARKETPLACE_USERNAME: ${{ secrets.MAGENTO_MARKETPLACE_USERNAME }}MAGENTO_MARKETPLACE_PASSWORD: ${{ secrets.MAGENTO_MARKETPLACE_PASSWORD }}

Next, make sure to add the secrets MAGENTO_MARKETPLACE_USERNAME and MAGENTO_MARKETPLACE_PASSWORD to your GitHub repository under Settings > Secrets. Tip: You could also use the secrets to define the module and composer name: This way your workflow file remains generic.

Alternatively, the credentials could also be hard-coded :(

jobs:
unit-tests:
env:
MAGENTO_MARKETPLACE_USERNAME: fooMAGENTO_MARKETPLACE_PASSWORD: bar

About

No description, website, or topics provided.

Resources

Stars

142 stars

Watchers

14 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

GitHub Actions for Magento 2 Extensions

This repository's aim is to provide a set of open sourced GitHub actions to write better tested Magento 2 extensions.

Available Actions

Magento Coding Standard

Provides an action that can be used in your GitHub workflow to execute the latest Magento Coding Standard.

Screenshot

Screenshot Coding Style Action

How to use it

In your GitHub repository add the below as .github/workflows/coding-standard.yml

name: ExtDN M2 Coding Standard
on:
push:
branches:
- master
pull_request:
jobs:
static:
name: M2 Coding Standard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-coding-standard@master

Magento Integration tests

Run your Magento 2 integration tests via this Github Action. All you need is to add your tests. This action will set up the needed Magento services and set up. Please note this action will perform a Composer installation so will provide additional confirmation that this works as well.

Screenshot

Screenshot Mess Detector Action

How to use it

In your GitHub repository add the below as .github/workflows/integration.yml

name: ExtDN M2 Integration Tests
on:
push:
branches:
- master
pull_request:
jobs:
integration-tests:
name: Magento 2 Integration Tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.4
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
es:
image: docker.io/wardenenv/elasticsearch:8.18
ports:
- 9200:9200
env:
'discovery.type': single-node
'xpack.security.enabled': false
ES_JAVA_OPTS: "-Xms64m -Xmx512m"
options: --health-cmd="curl localhost:9200/_cluster/health?wait_for_status=yellow&timeout=60s" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v6
- name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'

The following images are provided for use

PhpImage
8.5extdn/github-actions-m2/magento-integration-tests/8.5@master
8.4extdn/github-actions-m2/magento-integration-tests/8.4@master
8.3extdn/github-actions-m2/magento-integration-tests/8.3@master
8.2extdn/github-actions-m2/magento-integration-tests/8.2@master
8.1extdn/github-actions-m2/magento-integration-tests/8.1@master

The following inputs are required:

withdescription
module_nameYour Magento module name. Example: Foo_Bar
composer_nameYour composer name. Example: foo/magento2-bar
magento_versionMagento 2 Open Source version number. Example: 2.4.0

The default phpunit.xml configuration will check the following folders for *Test files:

  • Test/Integration
  • tests/Integration
  • tests/integration

If this phpunit file does not work for you can provide a relative path to your own PHPUnit file via phpunit_file

 - name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'
phpunit_file: './path/to/phpunit.xml'

Sometimes it may be needed to run additional commands before tests can run. For example to add or remove additional dependencies. Use the input magento_pre_install_script to provide a relative path to this script. Example

 - name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'
magento_pre_install_script: './.github/integration-test-setup.sh'

Magento Mess Detector

Provides an action that can be used in your GitHub workflow to execute the PHP Mess Detector rules included in Magento 2 (link).

Screenshot

Screenshot Mess Detector Action

How to use it

In your GitHub repository add the below as .github/workflows/mess-detector.yml

name: ExtDN M2 Mess Detector
on:
push:
branches:
- master
pull_request:
jobs:
phpmd:
name: M2 Mess Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-mess-detector@master

Magento Copy Paste Detector

Provides an action that can be used in your GitHub workflow to execute the PHP Copy Paste Detector rules included in Magento 2 (link).

How to use it

In your GitHub repository add the below as .github/workflows/copy-paste-detector.yml

name: ExtDN M2 Copy Paste Detector
on:
push:
branches:
- master
pull_request:
jobs:
phpmd:
name: M2 Copy Paste Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-copy-paste-detector@master

Magento PHPStan

Provides an action that can be used in your GitHub workflow to execute the PHPStan rules included in Magento 2 (link).

Screenshot

Screenshot PHPStan Action

How to use it

In your GitHub repository add the below as .github/workflows/phpstan.yml

name: ExtDN M2 PHPStan
on:
push:
branches:
- master
pull_request:
jobs:
phpstan:
name: M2 PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-phpstan/8.5@master
with:
composer_name: foo/magento2-foobar

Magento Performance Smoke Test

Provides an action that can be used in your GitHub workflow to execute blackfire.io profiling before and after installing extension code.

How to use it

In your GitHub repository add the below as .github/workflows/performance.yml

name: ExtDN M2 Performance Testing
on:
push:
branches:
- master
pull_request:
jobs:
performance:
name: M2 Performance Testing
runs-on: ubuntu-latest
env:
DOCKER_COMPOSE_FILE: "./docker-compose.yml"
EXTENSION_NAME: "Foo_Bar"
EXTENSION_PACKAGE_NAME: "foo/magento2-foobar"
steps:
- uses: actions/checkout@v6
name: Checkout files
with:
path: extension
- name: Get composer cache directory
id: composer-cache
run: "echo \"::set-output name=dir::$(composer config cache-dir)\""
working-directory: ./extension
- name: Cache dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Prepare ExtDN performance testing
uses: extdn/github-actions-m2/magento-performance-setup@master
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Install Magento
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -T php-fpm
bash -c 'cd /var/www/html/m2 && sudo chown www-data: -R /var/www/html/m2 && ls -al && id
&& php -f bin/magento setup:install --base-url=http://magento2.test/ --backend-frontname=admin --db-host=mysql --db-name=magento_performance_tests --db-user=root --db-password=123123q --admin-user=admin@example.com --admin-password=password1 --admin-email=admin@example.com --admin-firstname=firstname --admin-lastname=lastname'
- name: Generate Performance Fixtures
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -T php-fpm
bash -c 'cd /var/www/html/m2
&& php -f bin/magento setup:performance:generate-fixtures setup/performance-toolkit/profiles/ce/small.xml
&& php -f bin/magento cache:enable
&& php -f bin/magento cache:disable block_html full_page'
- name: Run Blackfire
id: blackfire-baseline
run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} run blackfire-agent blackfire --json curl http://magento2.test/category-1/category-1-1.html > ${{ github.workspace }}/baseline.json
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Install Extension
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -e EXTENSION_BRANCH=${GITHUB_REF#refs/heads/} -T php-fpm
bash -c 'cd /var/www/html/m2
&& php -f vendor/composer/composer/bin/composer config repo.extension path /var/www/html/extension
&& php -f vendor/composer/composer/bin/composer require ${{ env.EXTENSION_PACKAGE_NAME }}:dev-$EXTENSION_BRANCH#${{ github.sha }}
&& php -f bin/magento module:enable ${{ env.EXTENSION_NAME }}
&& php -f bin/magento setup:upgrade
&& php -f bin/magento cache:enable
&& php -f bin/magento cache:disable block_html full_page'
- name: Run Blackfire Again
id: blackfire-after
run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} run blackfire-agent blackfire --json curl http://magento2.test/category-1/category-1-1.html > ${{ github.workspace }}/after.json
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Compare Performance Results
uses: extdn/github-actions-m2/magento-performance-compare@master

Change these environment variables:

EXTENSION_NAME: "Foo_Bar"
EXTENSION_PACKAGE_NAME: "foo/magento2-foobar"

Additionally please create the following Github Secrets for this repository with the values available in your blackfire.io account:

BLACKFIRE_CLIENT_ID
BLACKFIRE_CLIENT_TOKEN
BLACKFIRE_SERVER_ID
BLACKFIRE_SERVER_TOKEN

Magento Marketplace repository

With various of the GitHub Actions, you will need to setup Magento, with all of its packages. Normally, you would use the official Magento Marketplace for this, which also requires you to setup authentication.

Amongst the environment variables, there is a variable REPOSITORY_URL which defaults - when kept empty - to https://repo-magento-mirror.fooman.co.nz/ - a mirror of the Magento Marketplace, that removes the need of authentication.

If you want to use the original Magento Marketplace anyway, reset the REPOSITORY_URL variable and add the marketplace credentials like this:

jobs:
unit-tests:
env:
REPOSITORY_URL: https://repo.magento.com/MAGENTO_MARKETPLACE_USERNAME: ${{ secrets.MAGENTO_MARKETPLACE_USERNAME }}MAGENTO_MARKETPLACE_PASSWORD: ${{ secrets.MAGENTO_MARKETPLACE_PASSWORD }}

Next, make sure to add the secrets MAGENTO_MARKETPLACE_USERNAME and MAGENTO_MARKETPLACE_PASSWORD to your GitHub repository under Settings > Secrets. Tip: You could also use the secrets to define the module and composer name: This way your workflow file remains generic.

Alternatively, the credentials could also be hard-coded :(

jobs:
unit-tests:
env:
MAGENTO_MARKETPLACE_USERNAME: fooMAGENTO_MARKETPLACE_PASSWORD: bar

About

No description, website, or topics provided.

Resources

Stars

142 stars

Watchers

14 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

GitHub Actions for Magento 2 Extensions

This repository's aim is to provide a set of open sourced GitHub actions to write better tested Magento 2 extensions.

Available Actions

Magento Coding Standard

Provides an action that can be used in your GitHub workflow to execute the latest Magento Coding Standard.

Screenshot

Screenshot Coding Style Action

How to use it

In your GitHub repository add the below as .github/workflows/coding-standard.yml

name: ExtDN M2 Coding Standard
on:
push:
branches:
- master
pull_request:
jobs:
static:
name: M2 Coding Standard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-coding-standard@master

Magento Integration tests

Run your Magento 2 integration tests via this Github Action. All you need is to add your tests. This action will set up the needed Magento services and set up. Please note this action will perform a Composer installation so will provide additional confirmation that this works as well.

Screenshot

Screenshot Mess Detector Action

How to use it

In your GitHub repository add the below as .github/workflows/integration.yml

name: ExtDN M2 Integration Tests
on:
push:
branches:
- master
pull_request:
jobs:
integration-tests:
name: Magento 2 Integration Tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.4
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
es:
image: docker.io/wardenenv/elasticsearch:8.18
ports:
- 9200:9200
env:
'discovery.type': single-node
'xpack.security.enabled': false
ES_JAVA_OPTS: "-Xms64m -Xmx512m"
options: --health-cmd="curl localhost:9200/_cluster/health?wait_for_status=yellow&timeout=60s" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v6
- name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'

The following images are provided for use

PhpImage
8.5extdn/github-actions-m2/magento-integration-tests/8.5@master
8.4extdn/github-actions-m2/magento-integration-tests/8.4@master
8.3extdn/github-actions-m2/magento-integration-tests/8.3@master
8.2extdn/github-actions-m2/magento-integration-tests/8.2@master
8.1extdn/github-actions-m2/magento-integration-tests/8.1@master

The following inputs are required:

withdescription
module_nameYour Magento module name. Example: Foo_Bar
composer_nameYour composer name. Example: foo/magento2-bar
magento_versionMagento 2 Open Source version number. Example: 2.4.0

The default phpunit.xml configuration will check the following folders for *Test files:

  • Test/Integration
  • tests/Integration
  • tests/integration

If this phpunit file does not work for you can provide a relative path to your own PHPUnit file via phpunit_file

 - name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'
phpunit_file: './path/to/phpunit.xml'

Sometimes it may be needed to run additional commands before tests can run. For example to add or remove additional dependencies. Use the input magento_pre_install_script to provide a relative path to this script. Example

 - name: M2 Integration Tests with Magento 2 (PHP 8.5)
uses: extdn/github-actions-m2/magento-integration-tests/8.5@master
with:
module_name: Foo_Bar
composer_name: foo/magento2-foobar
magento_version: '2.4.9'
magento_pre_install_script: './.github/integration-test-setup.sh'

Magento Mess Detector

Provides an action that can be used in your GitHub workflow to execute the PHP Mess Detector rules included in Magento 2 (link).

Screenshot

Screenshot Mess Detector Action

How to use it

In your GitHub repository add the below as .github/workflows/mess-detector.yml

name: ExtDN M2 Mess Detector
on:
push:
branches:
- master
pull_request:
jobs:
phpmd:
name: M2 Mess Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-mess-detector@master

Magento Copy Paste Detector

Provides an action that can be used in your GitHub workflow to execute the PHP Copy Paste Detector rules included in Magento 2 (link).

How to use it

In your GitHub repository add the below as .github/workflows/copy-paste-detector.yml

name: ExtDN M2 Copy Paste Detector
on:
push:
branches:
- master
pull_request:
jobs:
phpmd:
name: M2 Copy Paste Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-copy-paste-detector@master

Magento PHPStan

Provides an action that can be used in your GitHub workflow to execute the PHPStan rules included in Magento 2 (link).

Screenshot

Screenshot PHPStan Action

How to use it

In your GitHub repository add the below as .github/workflows/phpstan.yml

name: ExtDN M2 PHPStan
on:
push:
branches:
- master
pull_request:
jobs:
phpstan:
name: M2 PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: extdn/github-actions-m2/magento-phpstan/8.5@master
with:
composer_name: foo/magento2-foobar

Magento Performance Smoke Test

Provides an action that can be used in your GitHub workflow to execute blackfire.io profiling before and after installing extension code.

How to use it

In your GitHub repository add the below as .github/workflows/performance.yml

name: ExtDN M2 Performance Testing
on:
push:
branches:
- master
pull_request:
jobs:
performance:
name: M2 Performance Testing
runs-on: ubuntu-latest
env:
DOCKER_COMPOSE_FILE: "./docker-compose.yml"
EXTENSION_NAME: "Foo_Bar"
EXTENSION_PACKAGE_NAME: "foo/magento2-foobar"
steps:
- uses: actions/checkout@v6
name: Checkout files
with:
path: extension
- name: Get composer cache directory
id: composer-cache
run: "echo \"::set-output name=dir::$(composer config cache-dir)\""
working-directory: ./extension
- name: Cache dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Prepare ExtDN performance testing
uses: extdn/github-actions-m2/magento-performance-setup@master
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Install Magento
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -T php-fpm
bash -c 'cd /var/www/html/m2 && sudo chown www-data: -R /var/www/html/m2 && ls -al && id
&& php -f bin/magento setup:install --base-url=http://magento2.test/ --backend-frontname=admin --db-host=mysql --db-name=magento_performance_tests --db-user=root --db-password=123123q --admin-user=admin@example.com --admin-password=password1 --admin-email=admin@example.com --admin-firstname=firstname --admin-lastname=lastname'
- name: Generate Performance Fixtures
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -T php-fpm
bash -c 'cd /var/www/html/m2
&& php -f bin/magento setup:performance:generate-fixtures setup/performance-toolkit/profiles/ce/small.xml
&& php -f bin/magento cache:enable
&& php -f bin/magento cache:disable block_html full_page'
- name: Run Blackfire
id: blackfire-baseline
run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} run blackfire-agent blackfire --json curl http://magento2.test/category-1/category-1-1.html > ${{ github.workspace }}/baseline.json
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Install Extension
run: >-
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} exec -e EXTENSION_BRANCH=${GITHUB_REF#refs/heads/} -T php-fpm
bash -c 'cd /var/www/html/m2
&& php -f vendor/composer/composer/bin/composer config repo.extension path /var/www/html/extension
&& php -f vendor/composer/composer/bin/composer require ${{ env.EXTENSION_PACKAGE_NAME }}:dev-$EXTENSION_BRANCH#${{ github.sha }}
&& php -f bin/magento module:enable ${{ env.EXTENSION_NAME }}
&& php -f bin/magento setup:upgrade
&& php -f bin/magento cache:enable
&& php -f bin/magento cache:disable block_html full_page'
- name: Run Blackfire Again
id: blackfire-after
run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} run blackfire-agent blackfire --json curl http://magento2.test/category-1/category-1-1.html > ${{ github.workspace }}/after.json
env:
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
- name: Compare Performance Results
uses: extdn/github-actions-m2/magento-performance-compare@master

Change these environment variables:

EXTENSION_NAME: "Foo_Bar"
EXTENSION_PACKAGE_NAME: "foo/magento2-foobar"

Additionally please create the following Github Secrets for this repository with the values available in your blackfire.io account:

BLACKFIRE_CLIENT_ID
BLACKFIRE_CLIENT_TOKEN
BLACKFIRE_SERVER_ID
BLACKFIRE_SERVER_TOKEN

Magento Marketplace repository

With various of the GitHub Actions, you will need to setup Magento, with all of its packages. Normally, you would use the official Magento Marketplace for this, which also requires you to setup authentication.

Amongst the environment variables, there is a variable REPOSITORY_URL which defaults - when kept empty - to https://repo-magento-mirror.fooman.co.nz/ - a mirror of the Magento Marketplace, that removes the need of authentication.

If you want to use the original Magento Marketplace anyway, reset the REPOSITORY_URL variable and add the marketplace credentials like this:

jobs:
unit-tests:
env:
REPOSITORY_URL: https://repo.magento.com/MAGENTO_MARKETPLACE_USERNAME: ${{ secrets.MAGENTO_MARKETPLACE_USERNAME }}MAGENTO_MARKETPLACE_PASSWORD: ${{ secrets.MAGENTO_MARKETPLACE_PASSWORD }}

Next, make sure to add the secrets MAGENTO_MARKETPLACE_USERNAME and MAGENTO_MARKETPLACE_PASSWORD to your GitHub repository under Settings > Secrets. Tip: You could also use the secrets to define the module and composer name: This way your workflow file remains generic.

Alternatively, the credentials could also be hard-coded :(

jobs:
unit-tests:
env:
MAGENTO_MARKETPLACE_USERNAME: fooMAGENTO_MARKETPLACE_PASSWORD: bar

About

No description, website, or topics provided.

Resources

Stars

142 stars

Watchers

14 watching

Forks

Releases

Packages

Used by

Contributors

Languages