Hello,
I’m implementing unit testing and CI in a project and I’m getting different behaviors in my local env and in the gitlab runner (I am using gitlab.com with the shared runners).
My local env is running in docker containers and I’m using the same images in gitlab CI.
When I run PHPUnit locally, it works and I get the normal output.
On the CI side, It doesn’t log anything. I have no clue why this is the case.
I might miss something about how gitlab CI works as it’s the first time I implement CI.
The only way I got it working in the runner is by running the PHPUnit command two time in a row. It logs the second time.
the docker images I use are webdevops/php-apache-dev:7.4
and mariadb:10.6
here is the releavent part of my gitlab-ci.yml file:
test:project:
stage: test
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/usr/project
DOCUMENT_ROOT: $CI_BUILDS_DIR/usr/project/www
script:
- apt-get update && apt-get install -y mariadb-client
- git clone https://gitlab.com/n-pestana/gabox.git /gabox
- ln -s /gabox "$CI_BUILDS_DIR/gabox"
- echo auto_prepend_file="" >> /opt/docker/etc/php/php.ini
- mysql --user="$MARIADB_USER" --password="$MARIADB_PASSWORD" --host=mariadb "$MARIADB_DATABASE" < "$CI_BUILDS_DIR/gabox/sql/start.sql"
- mysql --user="$MARIADB_USER" --password="$MARIADB_PASSWORD" --host=mariadb "$MARIADB_DATABASE" < "$CI_BUILDS_DIR/gabox/sql/fixtures.sql"
- cd "$CI_BUILDS_DIR/gabox/phpunit/vendor/bin/"
- ./phpunit --configuration "$CI_BUILDS_DIR/usr/coach-alex/tests/phpunit.xml" --bootstrap "$CI_BUILDS_DIR/gabox/tests/autoload.php" "$CI_BUILDS_DIR/usr/coach-alex/tests/" --filter 'ExampleTest'
- ./phpunit --configuration "$CI_BUILDS_DIR/usr/coach-alex/tests/phpunit.xml" --bootstrap "$CI_BUILDS_DIR/gabox/tests/autoload.php" "$CI_BUILDS_DIR/usr/coach-alex/tests/"
rules:
- if: $CI_COMMIT_BRANCH == "develop"
It works like that, but logs only the second time I execute PHPUnit.
Any idea on what causes that behavior ?
Thanks !