Skip to content

Commit

Permalink
Merge branch 'main' of github.com:tanoconsulting/euts into main
Browse files Browse the repository at this point in the history
  • Loading branch information
gggeek committed Oct 25, 2022
2 parents e8df789 + aa6af3b commit 69fcde0
Showing 22 changed files with 202 additions and 109 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/tests export-ignore
/todo.txt export-ignore
75 changes: 34 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -7,55 +7,45 @@ jobs:
runs-on: ${{ matrix.operating-system }}
env:
SYMFONY_ENV: behat
APP_ENV: behat
DB_HOST: localhost
# @todo run at least one test on pgsql. Also: make docker tests run on mysql versions 5.6, 5.7, 8.0
# @todo run at least one test on pgsql
DB_TYPE: mysql
DB_ROOT_PASSWORD: root
DB_EZ_USER: ezp
DB_EZ_PASSWORD: ezp
DB_EZ_DATABASE: behattestdb
# @todo skip setting this, always use the php version from the config file ?
# Note that PHP_VERSION has higher priority than TESTSTACK_PHP_VERSION from the config file
PHP_VERSION: ${{ matrix.php }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
strategy:
fail-fast: false
matrix:
# @see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners for available os versions
# @todo add some tests running on 'windows-latest'
include:
- php: "5.6"
- config_file: '.euts.cp.env'
operating-system: 'ubuntu-20.04'
config_file: 'doc/config_examples/bundle_with_extra_dependencies/.euts.cp.env'

- php: "7.0"
- config_file: '.euts.1.7.env'
operating-system: 'ubuntu-20.04'
config_file: 'doc/config_examples/bundle_with_extra_dependencies/.euts.1.7.env'
- php: "7.1"
- config_file: '.euts.1.13.env'
operating-system: 'ubuntu-20.04'
config_file: 'doc/config_examples/bundle_with_extra_dependencies/.euts.1.13.env'

- php: "7.2"
- config_file: '.euts.2.3.env'
operating-system: 'ubuntu-22.04'
config_file: 'doc/config_examples/bundle_with_extra_dependencies/.euts.2.3.env'
- php: "7.3"
- config_file: '.euts.2.4.env'
operating-system: 'ubuntu-22.04'
config_file: 'doc/config_examples/bundle_with_extra_dependencies/.euts.2.4.env'
- php: "7.4"
- config_file: '.euts.2.5.env'
operating-system: 'ubuntu-22.04'
config_file: 'doc/config_examples/bundle_with_extra_dependencies/.euts.2.5.env'

- php: "7.3"
- config_file: '.euts.3.0.env'
operating-system: 'ubuntu-20.04'
config_file: 'doc/config_examples/bundle_with_extra_dependencies/.euts.3.0.env'
- php: "7.3"
- config_file: '.euts.3.1.env'
operating-system: 'ubuntu-20.04'
config_file: 'doc/config_examples/bundle_with_extra_dependencies/.euts.3.1.env'
- php: "7.4"
- config_file: '.euts.3.2.env'
operating-system: 'ubuntu-22.04'
config_file: 'doc/config_examples/bundle_with_extra_dependencies/.euts.3.2.env'
- php: "8.0"
- config_file: '.euts.3.3.env'
operating-system: 'ubuntu-22.04'
config_file: 'doc/config_examples/bundle_with_extra_dependencies/.euts.3.3.env'

steps:
- name: checkout code
uses: actions/checkout@v2
@@ -64,21 +54,23 @@ jobs:
run: |
# just in case...
chmod 755 ./teststack ./bin/*.sh ./bin/setup/*.sh
# a minimal composer.json is required to allow installation of package dependencies using "dev-master",
# fix behattestdb for ez cp version, etc...
mkdir /tmp/composer_cache
# a minimal composer.json is required to allow installation of package dependencies using "dev-branchXX",
# fix behatbundle for ez cp version, hack roave/securityadvisories for unsafe dependencies, etc...
cp tests/config/composer.json .
# this directory is used in the composer.json file
mkdir /tmp/composer_cache
# patch the configuration file we will use: we won't have the mig bundle available
sed -i 's/Kaliop\\eZMigrationBundle\\EzMigrationBundle //' ${{ matrix.config_file }}
sed -i 's/Kaliop\\eZMigrationBundle\\eZMigrationBundle //' ${{ matrix.config_file }}
sed -i 's/Kaliop\\eZMigrationBundle\\EzMigrationBundle //' doc/config_examples/bundle_with_extra_dependencies/${{ matrix.config_file }}
sed -i 's/Kaliop\\eZMigrationBundle\\eZMigrationBundle //' doc/config_examples/bundle_with_extra_dependencies/${{ matrix.config_file }}
# 1st test: set up the app and check that the sf console works - locally
# @todo stop unused services such as webserver, php-fpm, etc... to leave more memory available for the tests

# 1st test: set up the app and check that the sf console works - locally on the worker vm

# set up the test stack locally, ie. without docker containers
# NB: the php version in use here is not the one from the .env config file, but the one set in the matrix above
- name: GHA test
run: |
set -a && . ${{ matrix.config_file }} && set +a
set -a && . doc/config_examples/bundle_with_extra_dependencies/${{ matrix.config_file }} && set +a
./bin/setup.sh
./bin/sfconsole.sh list
env:
@@ -87,10 +79,9 @@ jobs:
# reset the env which we built
- name: cleanup env
run: |
# @todo stop other services such as webserver, to leave ore ram available for the docker tests
sudo systemctl stop mysql.service
# @todo using the composer.lock file and vendors from the previous run makes install quicker, but then we
# should make sure php versions (and extensions) are in sync.
# @todo using the composer.lock file and vendors from the local run would make install quicker, but then
# we should make sure php versions (and extensions) are in sync.
mv vendor vendor_nodocker
# 2nd test: set up the container stack and check that the sf console works in it
@@ -102,18 +93,18 @@ jobs:
run: |
export DB_HOST=mysql
export GITHUB_ACTION=
./teststack -e ${{ matrix.config_file }} -n -w 300 build
./teststack -e doc/config_examples/bundle_with_extra_dependencies/${{ matrix.config_file }} -n -w 300 build
# troubleshooting failures
#-
# if: ${{ failure() }}
# run: 'DB_HOST=mysql ./teststack -e ${{ matrix.config_file }} logs ez; ./teststack -e ${{ matrix.config_file }} top'
# troubleshooting test stack build failures
#- name: troubleshooting info
# if: ${{ failure() }}
# run: 'DB_HOST=mysql ./teststack -e ${{ matrix.config_file }} logs ez; ./teststack -e ${{ matrix.config_file }} top'

- name: 'docker stack: test'
run: |
export DB_HOST=mysql
export GITHUB_ACTION=
export TESTSTACK_CONFIG_FILE=${{ matrix.config_file }}
export TESTSTACK_CONFIG_FILE=doc/config_examples/bundle_with_extra_dependencies/${{ matrix.config_file }}
./teststack logs
./teststack ps
./teststack services
@@ -131,6 +122,8 @@ jobs:
./teststack cleanup ez-logs
./teststack stop
./teststack cleanup logs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# troubleshooting failures
#- name: troubleshooting info
37 changes: 20 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -10,11 +10,12 @@ a specific version of the CMS and database, or on a combination of versions.

Features:

* allows to run your bundle's tests on any version of eZPublish-Community, eZPlatform 1 and eZPlatform 2
* allows to run your bundle's tests on any version of eZPublish-Community, eZPlatform 1, eZPlatform 2 and eZPlatform 3
* allows to run your bundle's tests on multiple versions of eZPlatform/eZPublish from a single source directory
* allows specifying extra composer packages to be installed and symfony bundles or legacy extensions to be activated
* allows to run your bundle's tests on many versions of PHP (Docker execution only)
* allows to run your bundle's tests on many versions of MySQL (Docker execution only)
* allows to run your bundle's tests on many versions of MySQL/MariaDB (Docker execution only)
* allows to run your bundle's tests on many versions of Debian/Ubuntu as underlying OS (Docker execution only)
* provides a single command-line tool for managing the test stack and running tests, including maintenance operations
such as database reset, logs cleanup, etc... (Docker execution only)

@@ -27,15 +28,15 @@ Step 1 can be omitted when the tests are run on a server which already has php/m
(only Ubuntu/Debian are supported in that case).

Not (yet) supported:
- running tests on PostgreSQL instead of Mysql: this is a work in progress
- running tests on PostgreSQL instead of MySQL: this is a work in progress
- running tests which require eZ to be set up with Redis or Memcached: this is a work in progress; see the FAQ later for details
- running browser-based tests: this has not yet been tested

Requirements
------------

* Git (for a quick way to download this tool)
* Bash shell
* Bash shell, and a smattering of command-line tools such as `which`, `find`, etc...

For running tests in Docker containers:
* Docker version 1.13 or later
@@ -143,21 +144,22 @@ Quick Start
6. commit the `.euts.env` file into version control. Don't forget to add the `/teststack` folder to your .gitignore file
to avoid accidentally committing it to your project's source code

7. Set up your tests to be run on Travis

See an example configuration [.travis.yml](doc/config_examples/.travis.yml) file

Note that, to perform tests on Travis, it is not necessary to run the whole tests stack - for most scenarios eZ
can be set up and the test suite execute without building and starting Docker containers.

8. Set up your tests to be run on GitHub Actions
7. Set up your tests to be run on GitHub Actions

See an example configuration [.travis.yml](doc/config_examples/github_actions.yml) file

Note that, to perform tests on GitHub workers, it is not necessary to run the whole tests stack - for most scenarios
eZ can be set up and the test suite execute without building and starting Docker containers.
If on the other hand you prefer to run the tests using containers inside the workers, you are free to do that.

8. Set up your tests to be run on Travis

See an example configuration [.travis.yml](doc/config_examples/.travis.yml) file

Note that, to perform tests on Travis, it is not necessary to run the whole tests stack - for most scenarios eZ
can be set up and the test suite execute without building and starting Docker containers.


Troubleshooting
---------------

@@ -292,7 +294,11 @@ Q: When I run `teststack start`, there is a long wait while the script says only

A: sure. Start a second shell, go to the project's folder and run `./teststack/teststack logs ez`

Q: Do you know of any bundles do make use of this one for testing, so that I can explore how they do it?
Q: Do you know of any bundles which do make use of this one for testing, so that I can explore how they do it?

A: sure. At least the following ones: https://github.com/kaliop-uk/ezmigrationbundle,
https://github.com/kaliop-uk/ezworkfloenginebundle, https://github.com/kaliop-uk/ezloreimpsumbundle,
https://github.com/kaliop/ezobjectwrapper or https://github.com/tanoconsulting/ezmigrationbundle2

Q: When I run the tests on GitHub using Actions, I get an error `Could not authenticate against github.com `

@@ -303,16 +309,13 @@ A: in that case, change the action's yml config to pass automatically GitHub's c
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

A: sure. At least the following ones: https://github.com/kaliop/ezobjectwrapper, https://github.com/kaliop-uk/ezmigrationbundle,
https://github.com/kaliop-uk/ezworkfloenginebundle, https://github.com/kaliop-uk/ezloreimpsumbundle,

Q: Are there other projects that you know of that have similar goals as this package?

A: certainly there are. Ones that I know of are f.e. https://github.com/Plopix/symfony-bundle-app-wrapper and
https://github.com/g1a/composer-test-scenarios

Q: Are you testing this Test Stack itself?

A: inception!!! ;-) In fact, yes, we strive to test it, using Github Actions
A: inception!!! ;-) In fact, yes, we do to test it, using Github Actions

[![Build Status](https://github.com/tanoconsulting/euts/actions/workflows/ci.yml/badge.svg)](https://github.com/tanoconsulting/euts/actions/workflows/ci.yml)
3 changes: 3 additions & 0 deletions WHATSNEW.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,9 @@ Version 0.6.0

* the `teststack` command learned action `cleanup containers`; `cleanup docker-images` was renamed to `cleanup dead-images`

* fix: do not try to install php from a custom repository when the desired version is available in the apt repos already
set up in the operating system

Version 0.5.2
=============

1 change: 1 addition & 0 deletions bin/setup.sh
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ if [ -n "${TESTSTACK_PHP_VERSION}" ]; then
fi

# For php 5.6, Composer needs humongous amounts of ram - which we don't have on Travis. Enable swap as workaround
# @todo we could probably disable this when EZ_COMPOSER_LOCK is used instead of EZ_PACKAGES
if [ "${PHP_VERSION}" = "5.6" -a -n "${TRAVIS}" ]; then
echo "Setting up a swap file..."

Original file line number Diff line number Diff line change
@@ -11,5 +11,5 @@ TESTSTACK_PHP_VERSION=7.1
EZ_PACKAGES='ezsystems/ezplatform:~1.13.5 ezsystems/ezplatform-xmltext-fieldtype:^1.1 ezsystems/ez-matrix-bundle:^0.2.1 netgen/tagsbundle:^2.2 ezsystems/behatbundle:^6.3'
EZ_BUNDLES='Kaliop\eZMigrationBundle\EzMigrationBundle EzSystems\EzPlatformXmlTextFieldTypeBundle\EzSystemsEzPlatformXmlTextFieldTypeBundle EzSystems\MatrixBundle\EzSystemsMatrixBundle Netgen\TagsBundle\NetgenTagsBundle'

# We use specifically version 5.7 here to exercise a code-path within the test-stack
# We use specifically version 5.7 here to exercise a code-path within the teststack via its CI setup
MYSQL_VERSION=5.7-debian
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@
COMPOSE_PROJECT_NAME=kezmbt_17
# Debian 9 Stretch comes with php 7.0 by default
TESTSTACK_DEBIAN_VERSION=stretch
# We specify the php version too. This is redundant in this case and is only used for the teststack CI tests
TESTSTACK_PHP_VERSION=7.0

# Besides the eZ Kernel, our tests require NetgenTagsBundle, EzSystemsEzPlatformXmlTextFieldTypeBundle and EzSystemsMatrixBundle.
EZ_PACKAGES='ezsystems/ezplatform:~1.7.9 ezsystems/ezplatform-xmltext-fieldtype:^1.1 ezsystems/ez-matrix-bundle:^0.2.1 netgen/tagsbundle:^2.2 ezsystems/behatbundle:^6.3'
Original file line number Diff line number Diff line change
@@ -2,17 +2,18 @@

# Use a specific project name - always a good idea when you plan to test the same bundle in different configurations
COMPOSE_PROJECT_NAME=kezmbt_23
# We use Debian 10 Buster which comes with php 7.3 by default, downgraded to 7.2
TESTSTACK_DEBIAN_VERSION=buster
TETSTSTACK_PHP_VERSION=7.2
# We use Ubuntu 18 Bionic which comes with php 7.2 by default
TESTSTACK_OS_VENDOR=ubuntu
TESTSTACK_DEBIAN_VERSION=bionic
TESTSTACK_PHP_VERSION=7.2

# Besides the eZ Kernel, our tests require NetgenTagsBundle, EzSystemsEzPlatformXmlTextFieldTypeBundle and EzSystemsMatrixBundle.
# This in turn requires manual activation of EzSystemsEzPlatformGraphQLBundle and EzCoreExtraBundle.
# Also, we need to pull in a version-locked ezsystems/repository-forms and sensio/generator-bundle (which is only needed because we run the tests using the 'behat' sf env)
EZ_PACKAGES='ezsystems/ezplatform:~2.3.2 ezsystems/ezplatform-xmltext-fieldtype:^1.7 ezsystems/ezplatform-matrix-fieldtype:^1.0 netgen/tagsbundle:^3.2 ezsystems/behatbundle:^6.5 ezsystems/repository-forms:<=2.4 sensio/generator-bundle'
EZ_BUNDLES='Kaliop\eZMigrationBundle\EzMigrationBundle EzSystems\EzPlatformXmlTextFieldTypeBundle\EzSystemsEzPlatformXmlTextFieldTypeBundle EzSystems\EzPlatformMatrixFieldtypeBundle\EzPlatformMatrixFieldtypeBundle Netgen\TagsBundle\NetgenTagsBundle Lolautruche\EzCoreExtraBundle\EzCoreExtraBundle EzSystems\EzPlatformGraphQL\EzSystemsEzPlatformGraphQLBundle'

# We use specifically version 8.0 here to exercise a code-path within the test-stack
# We use specifically version 8.0 here to exercise a code-path within the teststack via its CI setup
MYSQL_VERSION=8.0

#DB_TYPE=postgresql
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@
COMPOSE_PROJECT_NAME=kezmbt_24
# We use Debian 10 Buster, which comes with php 7.3 by default
TESTSTACK_DEBIAN_VERSION=buster
# We specify the php version too. This is redundant in this case and is only used for teststack CI tests
TESTSTACK_PHP_VERSION=7.3

# Besides the eZ Kernel, our tests require NetgenTagsBundle, EzSystemsEzPlatformXmlTextFieldTypeBundle and EzSystemsMatrixBundle.
# This in turn requires manual activation of EzCoreExtraBundle.
@@ -12,5 +14,5 @@ TESTSTACK_DEBIAN_VERSION=buster
EZ_PACKAGES='ezsystems/ezplatform:~2.4.2 ezsystems/ezplatform-xmltext-fieldtype:^1.8 ezsystems/ezplatform-matrix-fieldtype:^1.0 netgen/tagsbundle:^3.3 ezsystems/behatbundle:^6.5 sensio/generator-bundle'
EZ_BUNDLES='Kaliop\eZMigrationBundle\EzMigrationBundle EzSystems\EzPlatformXmlTextFieldTypeBundle\EzSystemsEzPlatformXmlTextFieldTypeBundle EzSystems\EzPlatformMatrixFieldtypeBundle\EzPlatformMatrixFieldtypeBundle Netgen\TagsBundle\NetgenTagsBundle Lolautruche\EzCoreExtraBundle\EzCoreExtraBundle EzSystems\EzPlatformGraphQL\EzSystemsEzPlatformGraphQLBundle'

# We use specifically version 8.0 here to exercise a code-path within the test-stack
# We use specifically version 8.0 here to exercise a code-path within the teststack via its CI setup
MYSQL_VERSION=8.0-debian
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@
COMPOSE_PROJECT_NAME=kezmbt_25
# We use Debian 11 Bullseye, which comes with php 7.4 by default
TESTSTACK_DEBIAN_VERSION=bullseye
# We specify the php version too. This is redundant in this case and is only used for the teststack CI tests
TESTSTACK_PHP_VERSION=7.4

# Besides the eZ Kernel, our tests require NetgenTagsBundle, EzSystemsEzPlatformXmlTextFieldTypeBundle and EzSystemsMatrixBundle.
# This in turn requires manual activation of EzCoreExtraBundle.
@@ -12,6 +14,6 @@ TESTSTACK_DEBIAN_VERSION=bullseye
EZ_PACKAGES='ezsystems/ezplatform:^2.5.5 ezsystems/ezplatform-xmltext-fieldtype:^1.9 netgen/tagsbundle:^3.4 ezsystems/behatbundle:^7.0 sensio/generator-bundle overblog/graphiql-bundle'
EZ_BUNDLES='Kaliop\eZMigrationBundle\EzMigrationBundle EzSystems\EzPlatformXmlTextFieldTypeBundle\EzSystemsEzPlatformXmlTextFieldTypeBundle Netgen\TagsBundle\NetgenTagsBundle Lolautruche\EzCoreExtraBundle\EzCoreExtraBundle'

# We use specifically mariadb version 10.6 here to exercise a code-path within the test-stack
# We use specifically mariadb version 10.6 here to exercise a code-path within the teststack via its CI setup
DB_VENDOR=mariadb
MYSQL_VERSION=10.6
Loading

0 comments on commit 69fcde0

Please sign in to comment.