Skip to content

Commit

Permalink
WIP TASK: Try to integrate functional tests in GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
gradinarufelix committed Dec 10, 2023
1 parent be274c1 commit 961ab51
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 39 deletions.
119 changes: 86 additions & 33 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,92 @@ name: build

on:
push:
branches:
- 'main'
branches:
- 'main'
pull_request: ~

jobs:
test:
name: "Test (PHP ${{ matrix.php-versions }}, Neos ${{ matrix.neos-versions }})"

strategy:
fail-fast: false
matrix:
php-versions: ['7.4']
neos-versions: ['7.3']
include:
- php-versions: '8.1'
neos-versions: '8.3'
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
path: ${{ env.FLOW_FOLDER }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, json, zlib, iconv, intl, pdo_sqlite
ini-values: date.timezone="Africa/Tunis", opcache.fast_shutdown=0, apc.enable_cli=on

- name: Set Neos Version
run: composer require neos/neos ^${{ matrix.neos-versions }} --no-progress --no-interaction

- name: Run Tests
run: composer test
test:
name: "Test (PHP ${{ matrix.php-versions }}, Neos ${{ matrix.neos-versions }})"

strategy:
fail-fast: false
matrix:
php-versions: [ '7.4' ]
neos-versions: [ '7.3' ]
include:
- php-versions: '8.1'
neos-versions: '8.3'
runs-on: ubuntu-latest

env:
FLOW_CONTEXT: Testing
NEOS_FOLDER: neos/
DIST_FOLDER: DistributionPackages/Sitegeist.LostInTranslation

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, json, zlib, iconv, intl, pdo_sqlite, mysql, pgsql, redis, memcached, memcache, apcu
ini-values: date.timezone="Africa/Tunis", opcache.fast_shutdown=0, apc.enable_cli=on

- name: Install Neos Project and other dependencies
run: |
rm -rf ${{ env.NEOS_FOLDER }}
mkdir ${{ env.NEOS_FOLDER }}
composer create --no-scripts --no-install neos/neos-base-distribution "${{ env.NEOS_FOLDER }}" "^${{ matrix.neos-versions }}"
cd "${{ env.NEOS_FOLDER }}"
composer require fakerphp/faker "^1.23.0" --no-install
composer require phpstan/phpstan "^1.10.0" --no-install
composer require squizlabs/php_codesniffer "^3.7" --no-install
composer require mockery/mockery "@stable" --no-install
composer config --no-plugins allow-plugins.neos/composer-plugin true
- name: Checkout
uses: actions/checkout@v2
with:
path: ${{ env.NEOS_FOLDER }}/${{ env.DIST_FOLDER }}

- name: Finish composer setup
run: |
cd "${{ env.NEOS_FOLDER }}"
composer config repositories.lostintranslation '{ "type": "path", "url": "./${{ env.DIST_FOLDER }}", "options": { "symlink": false } }'
composer require sitegeist/lostintranslation "@dev" --no-install
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: |
~/.cache/composer
~/${{ env.NEOS_FOLDER }}/Packages
key: php-${{ matrix.php-versions }}-${{ matrix.dependencies }}${{ hashFiles('**/composer.json') }}
restore-keys: php-${{ matrix.php-versions }}-${{ matrix.dependencies }}

- name: Install dependencies
run: |
cd ${{ env.NEOS_FOLDER }}
composer ${{ matrix.dependencies == 'locked' && 'install' || 'update' }} --no-progress --no-interaction ${{ matrix.dependencies == 'lowest' && '--prefer-lowest' || '' }} ${{ matrix.composer-arguments }}
- name: Set Flow Context
run: echo "FLOW_CONTEXT=${{ env.FLOW_CONTEXT }}" >> $GITHUB_ENV

- name: Run style tests
run: |
phpcs --colors -n --standard=PSR12 ${{ env.NEOS_FOLDER }}/${{ env.DIST_FOLDER }}/Classes
- name: Run stan tests
run: |
phpstan analyse ${{ env.NEOS_FOLDER }}/${{ env.DIST_FOLDER }}/Classes
- name: Run unit tests
run: |
cd "${{ env.NEOS_FOLDER }}"
bin/phpunit --colors --stop-on-failure -c DistributionPackages/Sitegeist.LostInTranslation/Tests/UnitTests.xml --testsuite "LostInTranslation" --verbose
- name: Run functional tests
run: |
cd "${{ env.NEOS_FOLDER }}"
bin/phpunit --colors --stop-on-failure -c DistributionPackages/Sitegeist.LostInTranslation/Tests/FunctionalTests.xml --testsuite "LostInTranslation" --verbose
6 changes: 3 additions & 3 deletions Tests/FunctionalTests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
bootstrap="FunctionalTestBootstrap.php"
bootstrap="../../../Build/BuildEssentials/PhpUnit/FunctionalTestBootstrap.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
timeoutForSmallTests="0">
<testsuites>
<testsuite name="Sitegeist.LostInTranslation Functional Tests">
<testsuite name="LostInTranslation">
<directory>Functional</directory>
</testsuite>
</testsuites>
<coverage includeUncoveredFiles="true">
<include>
<directory>Data/Temporary/Testing/Cache/Code/Flow_Object_Classes/</directory>
<directory>../../../Data/Temporary/Testing/Cache/Code/Flow_Object_Classes/</directory>
</include>
</coverage>
<logging>
Expand Down
6 changes: 3 additions & 3 deletions Tests/UnitTests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
bootstrap="UnitTestBootstrap.php"
bootstrap="../../../Build/BuildEssentials/PhpUnit/UnitTestBootstrap.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
timeoutForSmallTests="0">
<testsuites>
<testsuite name="All tests">
<testsuite name="LostInTranslation">
<directory>Unit</directory>
</testsuite>
</testsuites>
<coverage includeUncoveredFiles="false">
<include>
<directory>../Classes</directory>
<directory>../../../Packages/*/*/Classes</directory>
</include>
</coverage>
<logging>
Expand Down

0 comments on commit 961ab51

Please sign in to comment.