mirror of
https://github.com/graycoreio/github-actions-magento2.git
synced 2026-06-08 19:46:41 +00:00
feat: add integration test workflow (#3)
This commit is contained in:
@@ -0,0 +1,27 @@
|
|||||||
|
name: Integration Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- "_test/demo-package/**"
|
||||||
|
- ".github/workflows/_internal-integration.yaml"
|
||||||
|
- ".github/workflows/integration.yaml"
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- "_test/demo-package/**"
|
||||||
|
- ".github/workflows/_internal-integration.yaml"
|
||||||
|
- ".github/workflows/integration.yaml"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
integration-workflow:
|
||||||
|
uses: ./.github/workflows/integration.yaml
|
||||||
|
with:
|
||||||
|
package_name: graycore/magento2-demo-package
|
||||||
|
source_folder: $GITHUB_WORKSPACE/_test/demo-package
|
||||||
|
test_command: ../../../vendor/bin/phpunit ../../../vendor/graycore/magento2-demo-package/Test/Integration
|
||||||
|
secrets:
|
||||||
|
composer_auth: ${{ secrets.COMPOSER_AUTH }}
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
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"
|
||||||
|
|
||||||
|
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
|
||||||
|
required: false
|
||||||
|
default: "../magento2"
|
||||||
|
description: "The folder where Magento will be installed"
|
||||||
|
|
||||||
|
magento_repository:
|
||||||
|
type: string
|
||||||
|
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
|
||||||
|
|
||||||
|
test_command:
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
default: ../../../vendor/bin/phpunit
|
||||||
|
description: "The integration test command to run"
|
||||||
|
|
||||||
|
secrets:
|
||||||
|
composer_auth:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
integration_test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
elasticsearch:
|
||||||
|
image: ${{ inputs.elasticsearch_image }}
|
||||||
|
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: ${{ inputs.mysql_image }}
|
||||||
|
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: ${{ inputs.rabbitmq_image }}
|
||||||
|
env:
|
||||||
|
RABBITMQ_DEFAULT_USER: guest
|
||||||
|
RABBITMQ_DEFAULT_PASS: guest
|
||||||
|
ports:
|
||||||
|
- 5672:5672
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set PHP Version
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: ${{ inputs.php_version }}
|
||||||
|
|
||||||
|
- run: composer self-update --${{ inputs.composer_version }}
|
||||||
|
name: Pin to Composer Version ${{ inputs.composer_version }}
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- run: composer create-project --repository-url="${{ inputs.magento_repository }}" "${{ inputs.magento_version }}" ${{ inputs.magento_directory }} --no-install
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
COMPOSER_AUTH: ${{ secrets.composer_auth }}
|
||||||
|
name: Create Magento ${{ inputs.magento_version }} 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 | ${{ inputs.composer_version }} | ${{ inputs.php_version }} | ${{ inputs.magento_version }}'
|
||||||
|
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 ${{ 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
|
||||||
@@ -1 +1,2 @@
|
|||||||
vendor/
|
vendor/
|
||||||
|
.phpunit.result.cache
|
||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Graycore\DemoPackage\Test\Integration;
|
namespace Graycore\DemoPackage\Test\Integration;
|
||||||
|
|
||||||
class TestItWorks extends \PHPUnit\Framework\TestCase
|
class ItWorksTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
public function testItWorks()
|
public function testItWorks()
|
||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Graycore\DemoPackage\Test\Unit;
|
namespace Graycore\DemoPackage\Test\Unit;
|
||||||
|
|
||||||
class TestItWorks extends \PHPUnit\Framework\TestCase
|
class ItWorksTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
public function testItWorks()
|
public function testItWorks()
|
||||||
Reference in New Issue
Block a user