From e68e59b1b300f286237ab64f8725dfa2340a963b Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Fri, 11 Oct 2024 14:30:56 +0800 Subject: [PATCH] Attempt to support restructured directories TODO: Bats tests --- runner/main/jobtypes/behat/behat.sh | 17 ++++++++++++++--- runner/main/jobtypes/phpunit/phpunit.sh | 9 ++++++++- .../moodle-core-copy/moodle-core-copy.sh | 6 +++++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/runner/main/jobtypes/behat/behat.sh b/runner/main/jobtypes/behat/behat.sh index c875c2a..c3c931c 100644 --- a/runner/main/jobtypes/behat/behat.sh +++ b/runner/main/jobtypes/behat/behat.sh @@ -45,6 +45,8 @@ function behat_to_env_file() { SELENIUMURL_10 WEBSERVER + APACHE_DOCUMENT_ROOT + PUBLICROOT IONICURL @@ -67,6 +69,8 @@ function behat_to_env_file() { function behat_to_summary() { echo "== Moodle branch (version.php): ${MOODLE_BRANCH}" echo "== PHP version: ${PHP_VERSION}" + echo "== APACHE_DOCUMENT_ROOT: ${APACHE_DOCUMENT_ROOT}" + echo "== PUBLICROOT: ${PUBLICROOT}" echo "== DBTYPE: ${DBTYPE}" echo "== DBTAG: ${DBTAG}" echo "== DBREPLICAS: ${DBREPLICAS}" @@ -144,6 +148,8 @@ function behat_check() { # Behat job type init. function behat_config() { # Apply some defaults. + APACHE_DOCUMENT_ROOT="${APACHE_DOCUMENT_ROOT:-/var/www/html}" + PUBLICROOT="${PUBLICROOT:-}" RUNCOUNT="${RUNCOUNT:-1}" BEHAT_SUITE="${BEHAT_SUITE:-}" BEHAT_TAGS="${BEHAT_TAGS:-}" @@ -177,6 +183,11 @@ function behat_config() { BEHAT_RERUNS=0 BEHAT_TIMING_FILENAME= fi + + if [[ -d "${CODEDIR}/public" ]]; then + APACHE_DOCUMENT_ROOT="${APACHE_DOCUMENT_ROOT:-/var/www/html/public}" + PUBLICROOT="${PUBLICROOT:-/public}" + fi } # Behat job type setup. @@ -229,7 +240,7 @@ function behat_initcmd() { # Build the complete init command. cmd=( - php admin/tool/behat/cli/init.php + php ${PUBLICROOT}admin/tool/behat/cli/init.php "${initsuite}" -j="${BEHAT_PARALLEL}" --axe @@ -451,7 +462,7 @@ function behat_main_command() { # Let's build the complete behat command for the 1st (parallel) run. _cmd=( - php admin/tool/behat/cli/run.php + php ${PUBLICROOT}admin/tool/behat/cli/run.php ) # Add the options and profile. @@ -527,7 +538,7 @@ function behat_rerun_command() { # and, also, it automatically handles the file system links for the web server. # (output is a little bit uglier, but consistent with the main run). _reruncmd=( - php admin/tool/behat/cli/run.php --rerun + php ${PUBLICROOT}admin/tool/behat/cli/run.php --rerun ) # Add the config, options and profile. diff --git a/runner/main/jobtypes/phpunit/phpunit.sh b/runner/main/jobtypes/phpunit/phpunit.sh index 186392e..8f28f46 100644 --- a/runner/main/jobtypes/phpunit/phpunit.sh +++ b/runner/main/jobtypes/phpunit/phpunit.sh @@ -20,6 +20,8 @@ # PHPUnit needed variables to go to the env file. function phpunit_to_env_file() { local env=( + PUBLICROOT + DBTYPE DBTAG DBHOST @@ -53,6 +55,7 @@ function phpunit_to_env_file() { function phpunit_to_summary() { echo "== Moodle branch (version.php): ${MOODLE_BRANCH}" echo "== PHP version: ${PHP_VERSION}" + echo "== PUBLICROOT: ${PUBLICROOT}" echo "== DBTYPE: ${DBTYPE}" echo "== DBTAG: ${DBTAG}" echo "== DBCOLLATION: ${DBCOLLATION}" @@ -128,6 +131,10 @@ function phpunit_config() { # Also, we don't want to allow repetitions in the bisect session. RUNCOUNT=1 fi + + if [[ -d "${CODEDIR}/public" ]]; then + PUBLICROOT="${PUBLICROOT:-/public}" + fi } # PHPUnit job type setup. @@ -157,7 +164,7 @@ function phpunit_initcmd() { local -n cmd=$1 cmd=( php - admin/tool/phpunit/cli/init.php + ${PUBLICROOT}admin/tool/phpunit/cli/init.php ) } diff --git a/runner/main/modules/moodle-core-copy/moodle-core-copy.sh b/runner/main/modules/moodle-core-copy/moodle-core-copy.sh index 439ccd4..26153c1 100644 --- a/runner/main/modules/moodle-core-copy/moodle-core-copy.sh +++ b/runner/main/modules/moodle-core-copy/moodle-core-copy.sh @@ -37,7 +37,11 @@ function moodle-core-copy_check() { # Moodle core copy module config. function moodle-core-copy_config() { # Get the Moodle branch from code, so we can make decisions based on it. - MOODLE_BRANCH=$(grep "\$branch" "${CODEDIR}"/version.php | sed "s/';.*//" | sed "s/^\$.*'//") + if [[ -d "${CODEDIR}/public" ]]; then + MOODLE_BRANCH=$(grep "\$branch" "${CODEDIR}"/public/version.php | sed "s/';.*//" | sed "s/^\$.*'//") + else + MOODLE_BRANCH=$(grep "\$branch" "${CODEDIR}"/version.php | sed "s/';.*//" | sed "s/^\$.*'//") + fi } # Moodle core copy module setup.