diff --git a/bin/ci/_includes.sh b/bin/ci/_includes.sh index e939bb215..4c914cb0b 100755 --- a/bin/ci/_includes.sh +++ b/bin/ci/_includes.sh @@ -75,6 +75,17 @@ export DRUPAL_TEST_WEBDRIVER_HOSTNAME="localhost" export DRUPAL_TEST_WEBDRIVER_PORT="4444" export DRUPAL_NIGHTWATCH_SEARCH_DIRECTORY=../../ +if [[ "$GITLAB_CI" ]]; then + # In Gitlab we are using a separate container to run ChromeDriver on port 9515. + export DRUPAL_TEST_WEBDRIVER_PORT="9515" + # Nightwatch tests are crashing when they run on SHM due to size constraint, hence disabling. + export DRUPAL_TEST_WEBDRIVER_CHROME_ARGS="--disable-dev-shm-usage --disable-gpu --headless --no-sandbox" + # We are facing intermittent failures for Nightwatch tests of toolbar module, hence ignoring. + export DRUPAL_NIGHTWATCH_IGNORE_DIRECTORIES="node_modules,vendor,.*,sites/*/files,sites/*/private,sites/simpletest,/builds/project/orca-build/docroot/core/modules/toolbar/tests/src/Nightwatch/Tests/*" + # Set DRUPAL_NIGHTWATCH_OUTPUT to a path inside project dir. + export DRUPAL_NIGHTWATCH_OUTPUT="$CI_PROJECT_DIR/reports/nightwatch" +fi + if [[ ! "$ORCA_TEMP_DIR" ]]; then # GitHub Actions. if [[ "$RUNNER_TEMP" ]]; then diff --git a/bin/ci/script.sh b/bin/ci/script.sh index 3225e8d20..8846d0e40 100755 --- a/bin/ci/script.sh +++ b/bin/ci/script.sh @@ -17,9 +17,13 @@ if [[ "$ORCA_ENABLE_NIGHTWATCH" == "TRUE" && "$ORCA_SUT_HAS_NIGHTWATCH_TESTS" && orca fixture:run-server & SERVER_PID=$! - # @todo could we set DRUPAL_TEST_CHROMEDRIVER_AUTOSTART instead of launching Chromedriver manually? - chromedriver --disable-dev-shm-usage --disable-extensions --disable-gpu --headless --no-sandbox --port=4444 & - CHROMEDRIVER_PID=$! + if [[ "$GITLAB_CI" ]]; then + echo "ChromeDriver initialized via separate container..." + else + # @todo could we set DRUPAL_TEST_CHROMEDRIVER_AUTOSTART instead of launching Chromedriver manually? + chromedriver --disable-dev-shm-usage --disable-extensions --disable-gpu --headless --no-sandbox --port=4444 & + CHROMEDRIVER_PID=$! + fi eval "yarn test:nightwatch \\ --headless \\ diff --git a/bin/ci/self-test/script.sh b/bin/ci/self-test/script.sh index 342deb585..a58ebbfa3 100755 --- a/bin/ci/self-test/script.sh +++ b/bin/ci/self-test/script.sh @@ -34,7 +34,7 @@ if [[ "$ORCA_JOB" == "STATIC_CODE_ANALYSIS" ]]; then echo if [[ "$ORCA_COVERAGE_ENABLE" == TRUE ]]; then - eval './vendor/bin/phpunit --coverage-clover="$ORCA_SELF_TEST_COVERAGE_CLOVER"' + eval './vendor/bin/phpunit --coverage-cobertura="$ORCA_SELF_TEST_COVERAGE_CLOVER"' else eval './vendor/bin/phpunit' fi @@ -50,9 +50,14 @@ if [[ "$ORCA_ENABLE_NIGHTWATCH" == "TRUE" && "$ORCA_SUT_HAS_NIGHTWATCH_TESTS" && orca fixture:run-server & SERVER_PID=$! - # @todo could we set DRUPAL_TEST_CHROMEDRIVER_AUTOSTART instead of launching Chromedriver manually? - chromedriver --disable-dev-shm-usage --disable-extensions --disable-gpu --headless --no-sandbox --port=4444 & - CHROMEDRIVER_PID=$! + if [[ "$GITLAB_CI" ]]; then + echo "ChromeDriver initialized via separate container..." + else + # @todo Could we set DRUPAL_TEST_CHROMEDRIVER_AUTOSTART instead of launching ChromeDriver manually? + chromedriver --disable-dev-shm-usage --disable-extensions --disable-gpu --headless --no-sandbox --port=4444 & + CHROMEDRIVER_PID=$! + fi + eval "yarn test:nightwatch \\ --headless \\ @@ -65,6 +70,8 @@ if [[ "$ORCA_ENABLE_NIGHTWATCH" == "TRUE" && "$ORCA_SUT_HAS_NIGHTWATCH_TESTS" && --tag=core" kill -0 $SERVER_PID - kill -0 $CHROMEDRIVER_PID + if [ $CHROMEDRIVER_PID ]; then + kill -0 $CHROMEDRIVER_PID + fi ) fi diff --git a/src/Domain/Server/ChromeDriverServer.php b/src/Domain/Server/ChromeDriverServer.php index 65e38f448..57593e4eb 100644 --- a/src/Domain/Server/ChromeDriverServer.php +++ b/src/Domain/Server/ChromeDriverServer.php @@ -45,7 +45,7 @@ protected function createProcess(): Process { '--disable-gpu', '--headless', '--no-sandbox', - '--port=4444', + '--port=9515', ]; return new Process($command); } diff --git a/src/Domain/Tool/Phpunit/PhpUnitTask.php b/src/Domain/Tool/Phpunit/PhpUnitTask.php index ef9099c5c..c60bd4dc9 100644 --- a/src/Domain/Tool/Phpunit/PhpUnitTask.php +++ b/src/Domain/Tool/Phpunit/PhpUnitTask.php @@ -308,7 +308,7 @@ private function getMinkWebDriverArguments(): string { ], ], ], - 'http://localhost:4444', + 'http://localhost:9515', ], JSON_UNESCAPED_SLASHES); } @@ -324,8 +324,7 @@ protected function runPhpUnit(): void { '--verbose', ]; if ($this->shouldGenerateCodeCoverage()) { - $command[] = "--coverage-clover={$this->cloverCoverage}"; - $command[] = "--log-junit={$this->junitLog}"; + $command[] = "--coverage-cobertura={$this->cloverCoverage}"; $this->processRunner->addEnvVar("XDEBUG_MODE", "coverage"); } $command = array_merge($command, [ @@ -334,6 +333,7 @@ protected function runPhpUnit(): void { "--configuration={$this->fixture->getPath('docroot/core/phpunit.xml')}", '--exclude-group=orca_ignore', '--testsuite=orca', + "--log-junit={$this->junitLog}", ]); if ($this->isPublicTestsOnly()) { $command[] = '--group=orca_public';