From 1791319d8b684040768e53df90a74dc388304918 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 | 9 ++++++--- runner/main/jobtypes/phpunit/phpunit.sh | 4 +++- runner/main/modules/moodle-core-copy/moodle-core-copy.sh | 6 +++++- runner/main/modules/summary/summary.sh | 4 +++- runner/main/run.sh | 6 ++++++ 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/runner/main/jobtypes/behat/behat.sh b/runner/main/jobtypes/behat/behat.sh index c875c2a..6763969 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 @@ -144,6 +146,7 @@ function behat_check() { # Behat job type init. function behat_config() { # Apply some defaults. + PUBLICROOT="${PUBLICROOT:-}" RUNCOUNT="${RUNCOUNT:-1}" BEHAT_SUITE="${BEHAT_SUITE:-}" BEHAT_TAGS="${BEHAT_TAGS:-}" @@ -229,7 +232,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 +454,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 +530,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..61bc5e2 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 @@ -157,7 +159,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. diff --git a/runner/main/modules/summary/summary.sh b/runner/main/modules/summary/summary.sh index f6ecc89..a606d1c 100644 --- a/runner/main/modules/summary/summary.sh +++ b/runner/main/modules/summary/summary.sh @@ -52,7 +52,9 @@ function summary_setup() { echo "== Build Id: ${BUILD_ID}" echo "== Workspace: ${WORKSPACE}" echo "== Code directory: ${CODEDIR}" + echo "== Public directory: ${PUBLICROOT}" echo "== Shared directory: ${SHAREDDIR}" + echo "== APACHE_DOCUMENT_ROOT: ${APACHE_DOCUMENT_ROOT}" echo "== UUID / Container suffix: ${UUID}" echo "== Environment: ${ENVIROPATH}" echo "== GIT commit: ${GIT_COMMIT}" @@ -60,4 +62,4 @@ function summary_setup() { # Add all the summary information that the job type wants to add. get_job_to_summary "${JOBTYPE}" echo "============================================================================" -} \ No newline at end of file +} diff --git a/runner/main/run.sh b/runner/main/run.sh index 41f8d2e..44f9bb6 100755 --- a/runner/main/run.sh +++ b/runner/main/run.sh @@ -48,6 +48,12 @@ fi # Base directory where the code is located. CODEDIR="${CODEDIR:-${WORKSPACE}/moodle}" +APACHE_DOCUMENT_ROOT="${APACHE_DOCUMENT_ROOT:-/var/www/html}" +PUBLICROOT="${PUBLICROOT:-}" +if [[ -d "${CODEDIR}/public" ]]; then + PUBLICROOT="public/" + APACHE_DOCUMENT_ROOT="${APACHE_DOCUMENT_ROOT:-/var/www/html/public}" +fi # Fail if CODEDIR does not exist. if [[ ! -d ${CODEDIR} ]]; then