From b89fbd53d9d1e9dcf78de9fa8496083e26c34399 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 29 Aug 2024 14:42:45 +0100 Subject: [PATCH] Correct test results path for GitHub Actions reporters (#665) --- drainpipe-dev/composer.json | 2 +- drainpipe-dev/config/nightwatch.conf.js | 4 ++-- .../scaffold/nightwatch/vrt.gitignore | 2 ++ scaffold/github/workflows/TestFunctional.yml | 1 - scaffold/github/workflows/TestStatic.yml | 1 - scaffold/gitignore/common.gitignore | 3 --- tasks/test.yml | 22 ++++++++++++++++--- 7 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 drainpipe-dev/scaffold/nightwatch/vrt.gitignore diff --git a/drainpipe-dev/composer.json b/drainpipe-dev/composer.json index 8c5adf55..1eb75c73 100644 --- a/drainpipe-dev/composer.json +++ b/drainpipe-dev/composer.json @@ -33,7 +33,6 @@ "composer/composer": "^2.7.8" }, "bin": [ - "bin/drainpipe-twig-linter", "bin/drainpipe-convert-to-junit-xml" ], "extra": { @@ -49,6 +48,7 @@ "[web-root]/sites/sites.php": "scaffold/nightwatch/sites.php", "[project-root]/.ddev/docker-compose.selenium.yaml": "scaffold/nightwatch/docker-compose.selenium.yaml", "[project-root]/test/nightwatch/example.nightwatch.js": "scaffold/nightwatch/example.nightwatch.js", + "[project-root]/test/nightwatch/vrt/.gitignore": "scaffold/nightwatch/vrt.gitignore", "[project-root]/phpcs.xml.dist": "scaffold/phpcs.xml.dist", "[project-root]/phpstan.neon.dist": "scaffold/phpstan.neon.dist", "[project-root]/.twig-cs-fixer.dist.php": "scaffold/.twig-cs-fixer.dist.php" diff --git a/drainpipe-dev/config/nightwatch.conf.js b/drainpipe-dev/config/nightwatch.conf.js index 8708799f..5c0e559d 100644 --- a/drainpipe-dev/config/nightwatch.conf.js +++ b/drainpipe-dev/config/nightwatch.conf.js @@ -52,9 +52,9 @@ module.exports = { filter: '**/*.nightwatch.js', disable_error_log: false, screenshots: { - enabled: false, + enabled: true, on_failure: true, - on_error: false, + on_error: true, path: 'test_result', }, }, diff --git a/drainpipe-dev/scaffold/nightwatch/vrt.gitignore b/drainpipe-dev/scaffold/nightwatch/vrt.gitignore new file mode 100644 index 00000000..18f64dfe --- /dev/null +++ b/drainpipe-dev/scaffold/nightwatch/vrt.gitignore @@ -0,0 +1,2 @@ +/diff +/latest diff --git a/scaffold/github/workflows/TestFunctional.yml b/scaffold/github/workflows/TestFunctional.yml index 44500b8c..bbc2dd71 100644 --- a/scaffold/github/workflows/TestFunctional.yml +++ b/scaffold/github/workflows/TestFunctional.yml @@ -62,4 +62,3 @@ jobs: comment_mode: off files: | test_result/**/*.xml - test-results/**/*.json diff --git a/scaffold/github/workflows/TestStatic.yml b/scaffold/github/workflows/TestStatic.yml index b5563050..b6ddeee8 100644 --- a/scaffold/github/workflows/TestStatic.yml +++ b/scaffold/github/workflows/TestStatic.yml @@ -49,4 +49,3 @@ jobs: comment_mode: off files: | test_result/**/*.xml - test-results/**/*.json diff --git a/scaffold/gitignore/common.gitignore b/scaffold/gitignore/common.gitignore index c52dcbca..c008b558 100644 --- a/scaffold/gitignore/common.gitignore +++ b/scaffold/gitignore/common.gitignore @@ -60,6 +60,3 @@ node_modules test_result .prettiercache .twig-cs-fixer.cache -vrt-report -test/nightwatch/vrt/latest -test/nightwatch/vrt/diff diff --git a/tasks/test.yml b/tasks/test.yml index d5277286..9ddad679 100644 --- a/tasks/test.yml +++ b/tasks/test.yml @@ -64,7 +64,7 @@ tasks: DIRS_ARR=({{.TWIG_DIRS}}) for DIR in "${DIRS_ARR[@]}"; do if [ "{{.format}}" == "junit" ]; then - ./vendor/bin/twig-cs-fixer lint $DIR --format junit + ./vendor/bin/twig-cs-fixer lint $DIR --report junit > test_result/twig-cs-fixer.xml else ./vendor/bin/twig-cs-fixer lint $DIR fi @@ -186,8 +186,9 @@ tasks: desc: Checks for any untracked files in git cmds: - | - if [ "$(git status -s --ignore-submodules=dirty)" != "" ]; then - git status -s --ignore-submodules=dirty + # Ignore the .ddev folder as changes are made to this in order to run tests e.g. adding environment variables. + if [ "$(git status -s --ignore-submodules=dirty -- ':!.ddev')" != "" ]; then + git status -s --ignore-submodules=dirty -- ':!.ddev' echo "Untracked changes detected - please rectify or add the files to your .gitignore" exit 1 fi @@ -333,6 +334,8 @@ tasks: env: NIGHTWATCH_ENV: 'firefox,chrome' cmds: + - defer: { task: _nightwatch:vrt-report } + - rm -rf test_result/nightwatch* - | if [ -f "package-lock.json" ]; then npx nightwatch --env $NIGHTWATCH_ENV {{.CLI_ARGS}} @@ -342,3 +345,16 @@ tasks: echo "Unable to figure out which package manager is in use" exit 1; fi + _nightwatch:vrt-report: + desc: "Moves the VRT report into the test_results folder" + cmds: + - | + if [ -d "vrt-report" ]; then + mkdir -p test_result + mv vrt-report test_result/nightwatch-vrt-report + cp -R test/nightwatch/vrt test_result/nightwatch-vrt-report + mkdir -p test_result/nightwatch-vrt-report/test/nightwatch + mv test_result/nightwatch-vrt-report/vrt test_result/nightwatch-vrt-report/test/nightwatch + sed -i 's/\/test\/nightwatch\/vrt\//test\/nightwatch\/vrt\//g' test_result/nightwatch-vrt-report/index.html + echo "Nightwatch VTR report moved to test_result/nightwatch-vrt-report" + fi