Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes related to accommodate nightwatch tests in Gitlab CI #483

Merged
merged 30 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions bin/ci/_includes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions bin/ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \\
Expand Down
17 changes: 12 additions & 5 deletions bin/ci/self-test/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 \\
Expand All @@ -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
2 changes: 1 addition & 1 deletion src/Domain/Server/ChromeDriverServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function createProcess(): Process {
'--disable-gpu',
'--headless',
'--no-sandbox',
'--port=4444',
'--port=9515',
];
return new Process($command);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Domain/Tool/Phpunit/PhpUnitTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ private function getMinkWebDriverArguments(): string {
],
],
],
'http://localhost:4444',
'http://localhost:9515',
], JSON_UNESCAPED_SLASHES);
}

Expand All @@ -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, [
Expand All @@ -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';
Expand Down
Loading