mirror of
https://github.com/graycoreio/github-actions-magento2.git
synced 2026-06-08 19:46:41 +00:00
feat: add matrix to integration-test workflow (#7)
This commit is contained in:
@@ -17,11 +17,22 @@ on:
|
||||
- ".github/workflows/integration.yaml"
|
||||
|
||||
jobs:
|
||||
compute_matrix:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.supported-version.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ./supported-version
|
||||
id: supported-version
|
||||
- run: echo ${{ steps.supported-version.outputs.matrix }}
|
||||
integration-workflow:
|
||||
needs: compute_matrix
|
||||
uses: ./.github/workflows/integration.yaml
|
||||
with:
|
||||
package_name: graycore/magento2-demo-package
|
||||
source_folder: $GITHUB_WORKSPACE/_test/demo-package
|
||||
matrix: ${{ needs.compute_matrix.outputs.matrix }}
|
||||
test_command: ../../../vendor/bin/phpunit ../../../vendor/graycore/magento2-demo-package/Test/Integration
|
||||
secrets:
|
||||
composer_auth: ${{ secrets.COMPOSER_AUTH }}
|
||||
|
||||
@@ -6,6 +6,26 @@ A Github Workflow that runs the Integration Tests of a Magento Package
|
||||
|
||||
See the [integration.yaml](./integration.yaml)
|
||||
|
||||
| Input | Description | Required | Default |
|
||||
| ------------------ | ------------------------------------------------------------- | -------- | ----------------------------- |
|
||||
| matrix | JSON string of [version matrix for Magento](#./matrix-format) | true | NULL |
|
||||
| package_name | The name of the package | true | NULL |
|
||||
| source_folder | The source folder of the package | false | $GITHUB_WORKSPACE |
|
||||
| magento_directory | The folder where Magento will be installed | false | ../magento2 |
|
||||
| magento_repository | Where to install Magento from | false | https://repo.magento.com/ |
|
||||
| test_command | The integration test command to run | false | "../../../vendor/bin/phpunit" |
|
||||
|
||||
## Secrets
|
||||
| Input | Description | Required | Default |
|
||||
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------- |
|
||||
| composer_auth | JSON string of [composer credentials]([#./matrix-format](https://devdocs.magento.com/guides/v2.4/install-gde/prereq/connect-auth.html)) | true | NULL |
|
||||
|
||||
### Matrix Format
|
||||
|
||||
The Magento matrix format outlined by the [supported versions action.](https://github.com/graycoreio/github-actions-magento2/tree/main/supported-version/supported.json
|
||||
)
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```yml
|
||||
@@ -20,12 +40,23 @@ on:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
compute_matrix:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.supported-version.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: graycoreio/github-actions-magento2/supported-version@main
|
||||
id: supported-version
|
||||
- run: echo ${{ steps.supported-version.outputs.matrix }}
|
||||
integration-workflow:
|
||||
needs: compute_matrix
|
||||
uses: graycoreio/github-actions-magento2/.github/workflows/integration.yaml@main
|
||||
with:
|
||||
package_name: YOUR_PACKAGE_NAME
|
||||
source_folder: $GITHUB_WORKSPACE
|
||||
test_command: ../../../vendor/bin/phpunit ../../../vendor/YOUR_VENDOR/YOUR_PACKAGE_NAME/Test/Integration
|
||||
package_name: graycore/magento2-demo-package
|
||||
source_folder: $GITHUB_WORKSPACE/_test/demo-package
|
||||
matrix: ${{ needs.compute_matrix.outputs.matrix }}
|
||||
test_command: ../../../vendor/bin/phpunit ../../../vendor/graycore/magento2-demo-package/Test/Integration
|
||||
secrets:
|
||||
composer_auth: ${{ secrets.COMPOSER_AUTH }}
|
||||
```
|
||||
|
||||
@@ -12,24 +12,6 @@ on:
|
||||
type: string
|
||||
required: true
|
||||
description: "The name of the package"
|
||||
|
||||
composer_version:
|
||||
type: string
|
||||
default: "2"
|
||||
description: The composer version to use.
|
||||
required: false
|
||||
|
||||
php_version:
|
||||
type: string
|
||||
default: "7.4"
|
||||
description: The php version to use.
|
||||
required: false
|
||||
|
||||
magento_version:
|
||||
type: string
|
||||
default: magento/project-community-edition:>2.4.3 <2.4.4
|
||||
description: The magento version to use.
|
||||
required: false
|
||||
|
||||
magento_directory:
|
||||
type: string
|
||||
@@ -42,25 +24,12 @@ on:
|
||||
required: false
|
||||
default: "https://repo.magento.com/"
|
||||
description: "Where to install Magento from"
|
||||
|
||||
mysql_image:
|
||||
type: string
|
||||
default: mysql:8.0
|
||||
description: The mysql image to use.
|
||||
required: false
|
||||
|
||||
rabbitmq_image:
|
||||
type: string
|
||||
default: rabbitmq:3.10-alpine
|
||||
description: The RabbitMQ image to use.
|
||||
required: false
|
||||
|
||||
elasticsearch_image:
|
||||
type: string
|
||||
default: docker.elastic.co/elasticsearch/elasticsearch:7.16.3
|
||||
description: The elasticsearch image to use.
|
||||
required: false
|
||||
|
||||
matrix:
|
||||
type: string
|
||||
required: true
|
||||
description: "The matrix of Magento versions to test against"
|
||||
|
||||
test_command:
|
||||
type: string
|
||||
required: false
|
||||
@@ -73,10 +42,12 @@ on:
|
||||
|
||||
jobs:
|
||||
integration_test:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix: ${{ fromJSON(inputs.matrix) }}
|
||||
services:
|
||||
elasticsearch:
|
||||
image: ${{ inputs.elasticsearch_image }}
|
||||
image: ${{ matrix.elasticsearch }}
|
||||
env:
|
||||
discovery.type: single-node
|
||||
options: >-
|
||||
@@ -88,7 +59,7 @@ jobs:
|
||||
- 9200:9200
|
||||
|
||||
mysql:
|
||||
image: ${{ inputs.mysql_image }}
|
||||
image: ${{ matrix.mysql }}
|
||||
env:
|
||||
MYSQL_DATABASE: magento_integration_tests
|
||||
MYSQL_USER: user
|
||||
@@ -99,7 +70,7 @@ jobs:
|
||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||
|
||||
rabbitmq:
|
||||
image: ${{ inputs.rabbitmq_image }}
|
||||
image: ${{ matrix.rabbitmq }}
|
||||
env:
|
||||
RABBITMQ_DEFAULT_USER: guest
|
||||
RABBITMQ_DEFAULT_PASS: guest
|
||||
@@ -110,17 +81,17 @@ jobs:
|
||||
- name: Set PHP Version
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ inputs.php_version }}
|
||||
php-version: ${{ matrix.php }}
|
||||
|
||||
- run: composer self-update --${{ inputs.composer_version }}
|
||||
name: Pin to Composer Version ${{ inputs.composer_version }}
|
||||
- run: composer self-update --${{ matrix.composer }}
|
||||
name: Pin to Composer Version ${{ matrix.composer }}
|
||||
shell: bash
|
||||
|
||||
- run: composer create-project --repository-url="${{ inputs.magento_repository }}" "${{ inputs.magento_version }}" ${{ inputs.magento_directory }} --no-install
|
||||
- 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 ${{ inputs.magento_version }} Project
|
||||
name: Create Magento ${{ matrix.magento }} Project
|
||||
|
||||
- name: Get Composer Cache Directory
|
||||
shell: bash
|
||||
@@ -132,14 +103,18 @@ jobs:
|
||||
- name: "Cache Composer Packages"
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
key: 'composer | v3 | "$(Agent.OS)" | composer.lock | ${{ inputs.composer_version }} | ${{ inputs.php_version }} | ${{ inputs.magento_version }}'
|
||||
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 require ${{ inputs.package_name }} "@dev" --no-update && composer install
|
||||
name: Require and attempt install
|
||||
working-directory: ${{ inputs.magento_directory }}
|
||||
|
||||
Reference in New Issue
Block a user