Files
github-actions-magento2/.github/workflows/integration.yaml
T
2022-08-05 08:19:37 -04:00

151 lines
5.1 KiB
YAML

on:
workflow_call:
inputs:
source_folder:
type: string
required: false
default: $GITHUB_WORKSPACE
description: "The source folder of the package"
package_name:
type: string
required: true
description: "The name of the package"
magento_directory:
type: string
required: false
default: "../magento2"
description: "The folder where Magento will be installed"
magento_repository:
type: string
required: false
default: "https://mirror.mage-os.org/"
description: "Where to install Magento from"
matrix:
type: string
required: true
description: "The matrix of Magento versions to test against"
fail-fast:
type: boolean
required: false
default: true
test_command:
type: string
required: false
default: ../../../vendor/bin/phpunit
description: "The integration test command to run"
secrets:
composer_auth:
required: false
jobs:
integration_test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: ${{ inputs.fail-fast }}
matrix: ${{ fromJSON(inputs.matrix) }}
services:
elasticsearch:
image: ${{ matrix.elasticsearch }}
env:
discovery.type: single-node
options: >-
--health-cmd "curl http://localhost:9200/_cluster/health"
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
- 9200:9200
mysql:
image: ${{ matrix.mysql }}
env:
MYSQL_DATABASE: magento_integration_tests
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: rootpassword
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
rabbitmq:
image: ${{ matrix.rabbitmq }}
env:
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest
ports:
- 5672:5672
steps:
- uses: actions/checkout@v3
- name: Set PHP Version
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- run: composer self-update --${{ matrix.composer }}
name: Pin to Composer Version ${{ matrix.composer }}
shell: bash
- run: composer create-project --repository-url="${{ inputs.magento_repository }}" "${{ matrix.magento }}" ${{ inputs.magento_directory }} --no-install
shell: bash
env:
COMPOSER_AUTH: ${{ secrets.composer_auth }}
name: Create Magento ${{ matrix.magento }} Project
- name: Get Composer Cache Directory
shell: bash
working-directory: ${{ inputs.magento_directory }}
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: "Cache Composer Packages"
uses: actions/cache@v3
with:
key: 'composer | v3 | "$(Agent.OS)" | composer.lock | ${{ matrix.composer }} | ${{ matrix.php }} | ${{ matrix.magento }}'
path: ${{ steps.composer-cache.outputs.dir }}
- run: composer config repositories.local path ${{ inputs.source_folder }}
name: Add Github Repo for Testing
working-directory: ${{ inputs.magento_directory }}
shell: bash
- run: composer require monolog/monolog:"<2.7.0" --no-update
name: Fixup Monolog (https://github.com/magento/magento2/pull/35596)
working-directory: ${{ inputs.magento_directory }}
- run: |
composer config --no-interaction allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer config --no-interaction allow-plugins.laminas/laminas-dependency-plugin true
composer config --no-interaction allow-plugins.magento/* true
name: Fixup Composer Plugins
working-directory: ${{ inputs.magento_directory }}
if: ${{ !startsWith(matrix.composer, '1') }}
- run: composer require ${{ inputs.package_name }} "@dev" --no-update && composer install
name: Require and attempt install
working-directory: ${{ inputs.magento_directory }}
shell: bash
env:
COMPOSER_CACHE_DIR: ${{ steps.composer-cache.outputs.dir }}
COMPOSER_AUTH: ${{ secrets.composer_auth }}
- name: Replace Configuration Settings for env
working-directory: ${{ inputs.magento_directory }}/dev/tests/integration
run: |
sed -i "s/'db-host' => 'localhost'/'db-host' => '127.0.0.1'/" etc/install-config-mysql.php.dist
sed -i "s/'db-user' => 'root'/'db-user' => 'user'/" etc/install-config-mysql.php.dist
sed -i "s/'db-password' => '123123q'/'db-password' => 'password'/" etc/install-config-mysql.php.dist
sed -i "s/'elasticsearch-host' => 'localhost'/'elasticsearch-host' => '127.0.0.1'/" etc/install-config-mysql.php.dist
sed -i "s/'amqp-host' => 'localhost'/'amqp-host' => '127.0.0.1'/" etc/install-config-mysql.php.dist
- run: ${{ inputs.test_command }}
working-directory: ${{ inputs.magento_directory }}/dev/tests/integration
name: Run Integration Tests