You've already forked phpmyadmin
mirror of
https://github.com/phpmyadmin/phpmyadmin.git
synced 2026-10-23 18:29:15 +03:00
Fix logs system and temp dir for tests
Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
17
.github/workflows/test-selenium.yml
vendored
17
.github/workflows/test-selenium.yml
vendored
@@ -11,7 +11,7 @@ on:
|
||||
jobs:
|
||||
test-selenium:
|
||||
name: Selenium tests on php ${{ matrix.php-version }} and ${{ matrix.os }}
|
||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[ci selenium skip]')"
|
||||
runs-on: ${{ matrix.os }}
|
||||
services:
|
||||
database-server:
|
||||
@@ -95,7 +95,10 @@ jobs:
|
||||
CI_MODE: selenium
|
||||
FPM_PATH: php-fpm8.0
|
||||
SKIP_STANDALONE: 1
|
||||
run: ./test/start-local-server
|
||||
run: |
|
||||
./test/start-local-server
|
||||
echo ::set-output name=SELENIUM_TEMPDIR::"$(cat /tmp/last_temp_dir_phpMyAdminTests)"
|
||||
id: start-local-server
|
||||
- name: Run selenium tests
|
||||
env:
|
||||
CI_MODE: selenium
|
||||
@@ -110,11 +113,15 @@ jobs:
|
||||
# Allowed errors: https://github.com/phpmyadmin/phpmyadmin/issues/16479
|
||||
continue-on-error: true
|
||||
run: ./vendor/bin/phpunit --group selenium --verbose --debug --no-coverage
|
||||
- name: Output logs
|
||||
- name: Output logs and stop server
|
||||
env:
|
||||
CI_MODE: selenium
|
||||
SELENIUM_TEMPDIR: ${{ steps.start-local-server.outputs.SELENIUM_TEMPDIR }}
|
||||
if: ${{ success() || failure() }}
|
||||
run: |
|
||||
if [ -f php.log ] ; then cat php.log ; fi
|
||||
if [ -f nginx-error.log ] ; then cat nginx-error.log ; fi
|
||||
if [ -f "${SELENIUM_TEMPDIR}/php.log" ] ; then cat "${SELENIUM_TEMPDIR}/php.log" ; fi
|
||||
if [ -f "${SELENIUM_TEMPDIR}/nginx-error.log" ] ; then cat "${SELENIUM_TEMPDIR}/nginx-error.log" ; fi
|
||||
./test/stop-local-server
|
||||
- name: 'Upload screenshots'
|
||||
uses: actions/upload-artifact@v2
|
||||
if: ${{ success() || failure() }}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<exclude-pattern>test/doctum-config.php</exclude-pattern>
|
||||
<exclude-pattern>*/node_modules/*</exclude-pattern>
|
||||
<exclude-pattern>*/tmp/*</exclude-pattern>
|
||||
<exclude-pattern>*/build/*</exclude-pattern>
|
||||
<exclude-pattern>*/twig-templates/*</exclude-pattern>
|
||||
<exclude-pattern>*/vendor/*</exclude-pattern>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ daemon on;
|
||||
|
||||
pid %DIR%/nginx.pid;
|
||||
|
||||
error_log %ROOT%/nginx-error.log;
|
||||
error_log %DIR%/nginx-error.log;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
@@ -49,8 +49,8 @@ http {
|
||||
access_log off;
|
||||
|
||||
server {
|
||||
access_log %ROOT%/nginx-access.log;
|
||||
error_log %ROOT%/nginx-error.log error;
|
||||
access_log %DIR%/nginx-access.log;
|
||||
error_log %DIR%/nginx-error.log error;
|
||||
listen 8000 default_server;
|
||||
server_name _;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[global]
|
||||
error_log = %ROOT%/php.log
|
||||
error_log = %DIR%/php.log
|
||||
log_level = warning
|
||||
pid = %DIR%/php-fpm.pid
|
||||
|
||||
[www]
|
||||
listen = %DIR%/php-fpm.sock
|
||||
|
||||
@@ -57,6 +57,8 @@ use function usleep;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use function time;
|
||||
use function file_put_contents;
|
||||
use const JSON_PRETTY_PRINT;
|
||||
use const JSON_UNESCAPED_SLASHES;
|
||||
|
||||
/**
|
||||
* Base class for Selenium tests.
|
||||
@@ -273,6 +275,21 @@ abstract class TestBase extends TestCase
|
||||
$this->webDriver->get($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current running test name
|
||||
*
|
||||
* Usefull for browserstack
|
||||
*
|
||||
* @see https://github.com/phpmyadmin/phpmyadmin/pull/14595#issuecomment-418541475
|
||||
* Reports the name of the test to browserstack
|
||||
*/
|
||||
public function getTestName(): string
|
||||
{
|
||||
$className = substr(static::class, strlen('PhpMyAdmin\Tests\Selenium\\'));
|
||||
|
||||
return $className . ': ' . $this->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add specific capabilities
|
||||
*
|
||||
@@ -283,14 +300,6 @@ abstract class TestBase extends TestCase
|
||||
$buildLocal = true;
|
||||
$buildId = 'Manual';
|
||||
$projectName = 'phpMyAdmin';
|
||||
/**
|
||||
* Usefull for browserstack
|
||||
*
|
||||
* @see https://github.com/phpmyadmin/phpmyadmin/pull/14595#issuecomment-418541475
|
||||
* Reports the name of the test to browserstack
|
||||
*/
|
||||
$className = substr(static::class, strlen('PhpMyAdmin\Tests\Selenium\\'));
|
||||
$testName = $className . ': ' . $this->getName();
|
||||
|
||||
if (getenv('BUILD_TAG')) {
|
||||
$buildId = getenv('BUILD_TAG');
|
||||
@@ -313,7 +322,7 @@ abstract class TestBase extends TestCase
|
||||
'osVersion' => '10',
|
||||
'resolution' => '1920x1080',
|
||||
'projectName' => $projectName,
|
||||
'sessionName' => $testName,
|
||||
'sessionName' => $this->getTestName(),
|
||||
'buildName' => $buildId,
|
||||
'localIdentifier' => $buildId,
|
||||
'local' => $buildLocal,
|
||||
@@ -663,13 +672,23 @@ abstract class TestBase extends TestCase
|
||||
if ($this->webDriver === null) {
|
||||
return;
|
||||
}
|
||||
$key = time();
|
||||
|
||||
// This call will also create the file path
|
||||
$this->webDriver->takeScreenshot(
|
||||
$screenshotDir . DIRECTORY_SEPARATOR
|
||||
. 'screenshot_' . time() . '_' . $comment . '.png'
|
||||
. 'screenshot_' . $key . '_' . $comment . '.png'
|
||||
);
|
||||
$htmlOutput = $screenshotDir . DIRECTORY_SEPARATOR . 'source_' . time() . '.html';
|
||||
$htmlOutput = $screenshotDir . DIRECTORY_SEPARATOR . 'source_' . $key . '.html';
|
||||
file_put_contents($htmlOutput, $this->webDriver->getPageSource());
|
||||
$testInfo = $screenshotDir . DIRECTORY_SEPARATOR . 'source_' . $key . '.json';
|
||||
file_put_contents($testInfo, json_encode(
|
||||
[
|
||||
'filesKey' => $key,
|
||||
'testName' => $this->getTestName(),
|
||||
],
|
||||
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,7 +42,7 @@ if [ ! -z "$TESTSUITE_BROWSERSTACK_KEY" ] ; then
|
||||
unzip BrowserStackLocal-linux-x64.zip
|
||||
fi
|
||||
# Start BrowserStack Local forwarder
|
||||
~/browserstack/BrowserStackLocal --force-local --localIdentifier "travis-$TRAVIS_JOB_NUMBER" --onlyAutomate --key "$TESTSUITE_BROWSERSTACK_KEY" --daemon start
|
||||
~/browserstack/BrowserStackLocal --force-local --localIdentifier "gh-$GITHUB_ACTION" --onlyAutomate --key "$TESTSUITE_BROWSERSTACK_KEY" --daemon start
|
||||
elif [ -z "$SKIP_STANDALONE" ] ; then
|
||||
echo "Using: selenium-standalone"
|
||||
if [ ! -f selenium-standalone ]; then
|
||||
@@ -54,3 +54,5 @@ elif [ -z "$SKIP_STANDALONE" ] ; then
|
||||
else
|
||||
echo "Using: nothing."
|
||||
fi
|
||||
|
||||
echo "${DIR}" > /tmp/last_temp_dir_phpMyAdminTests
|
||||
|
||||
@@ -14,6 +14,8 @@ if [ "$CI_MODE" != "selenium" ] ; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SELENIUM_TEMPDIR="$(cat /tmp/last_temp_dir_phpMyAdminTests)"
|
||||
|
||||
if [ ! -z "$TESTSUITE_BROWSERSTACK_KEY" ] ; then
|
||||
# Stop BrowserStack Local forwarder
|
||||
~/browserstack/BrowserStackLocal --daemon stop
|
||||
@@ -24,3 +26,19 @@ if [ -f ~/selenium-standalone.pid~ ] ; then
|
||||
kill $(cat ~/selenium-standalone.pid~)
|
||||
rm ~/selenium-standalone.pid~
|
||||
fi
|
||||
|
||||
if [ ! -z "${SELENIUM_TEMPDIR}" ] && [ -f "${SELENIUM_TEMPDIR}/nginx.pid" ]; then
|
||||
# Stop nginx server
|
||||
kill $(cat "${SELENIUM_TEMPDIR}/nginx.pid")
|
||||
fi
|
||||
|
||||
if [ ! -z "${SELENIUM_TEMPDIR}" ] && [ -f "${SELENIUM_TEMPDIR}/php-fpm.pid" ]; then
|
||||
# Stop php-fpm server
|
||||
kill $(cat "${SELENIUM_TEMPDIR}/php-fpm.pid")
|
||||
fi
|
||||
|
||||
if [ ! -z "${SELENIUM_TEMPDIR}" ] && [ -d "${SELENIUM_TEMPDIR}" ]; then
|
||||
# Delete the temporary folder
|
||||
rm -rf "${SELENIUM_TEMPDIR}"
|
||||
echo "Deleted temporary dir: ${SELENIUM_TEMPDIR}"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user