From 368b42c0cf3c1eb260c6558a6a6ca2cd9c1dda58 Mon Sep 17 00:00:00 2001 From: muhme Date: Sat, 14 Dec 2024 11:21:49 +0100 Subject: [PATCH] Fixes/Improvements after testing Windows - Cleaning 652 MB pre-installed Cypress 14.14.2 - Using non-local config file in cypress script - Running Cypress with npx and the config-file - one shellcheck error disabled --- VERSION | 2 +- scripts/create.sh | 4 +++- scripts/cypress.sh | 53 ++++++++++++++++++++++------------------------ scripts/test.sh | 1 + 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/VERSION b/VERSION index 63a1a1c..8dbb0f2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.1.9 +2.1.10 diff --git a/scripts/create.sh b/scripts/create.sh index 4ca4afa..986a78c 100755 --- a/scripts/create.sh +++ b/scripts/create.sh @@ -190,7 +190,9 @@ if [ "$recreate" = false ]; then docker exec jbt-cypress sh -c "apt-get update && apt-get install -y git vim iputils-ping iproute2 telnet net-tools" log "jbt-cypress – JBT 'installation' environment – installing cypress@latest" - docker exec "jbt-cypress" bash -c "cd /jbt/installation && \ + # First free 652 MB for pre-installed Cypress 13.14.2 + docker exec "jbt-cypress" bash -c "rm -rf /root/.cache/Cypress && \ + cd /jbt/installation && \ npm install cypress-file-upload cypress@latest && \ CYPRESS_CACHE_FOLDER=/jbt/cypress-cache npx cypress@latest install" diff --git a/scripts/cypress.sh b/scripts/cypress.sh index b310a54..5adf2cf 100755 --- a/scripts/cypress.sh +++ b/scripts/cypress.sh @@ -28,7 +28,7 @@ function help { # shellcheck disable=SC2207 # There are no spaces in instance numbers allInstalledInstances=($(getAllInstalledInstances)) -local=false +local="" # defaults to false joomla_cypress=false while [ $# -ge 1 ]; do if [[ "$1" =~ ^(help|-h|--h|-help|--help|-\?)$ ]]; then @@ -38,7 +38,7 @@ while [ $# -ge 1 ]; do instance="$1" shift # Argument is eaten as the instance number. elif [ "$1" = "local" ]; then - local=true + local=".local" # set true and use it as part for config file path shift # Argument is eaten to run Cypress directly on the Docker host. elif [ "$1" = "joomla-cypress" ]; then joomla_cypress=true @@ -83,8 +83,24 @@ else sudo chmod 644 "joomla-${instance}/configuration.php" fi +# Determine Cypress config file +# e.g. joomla-52/cypress.config.local.mjs or installation/joomla-52/cypress.config.local.js +if ${joomla_cypress}; then + prefix="../joomla-${instance}/" +else + prefix="" +fi +if [ -f "${cypress_dir}/${prefix}cypress.config${local}.mjs" ]; then + config_file="${prefix}cypress.config${local}.mjs" +elif [ -f "${cypress_dir}/${prefix}cypress.config${local}.js" ]; then + config_file="${prefix}cypress.config${local}.js" +else + error "There is no file '${prefix}cypress.config${local}.[m]js'." + exit 1 +fi + # Use of SMTP port 7325 for the smtp-tester, as port 7125 is occupied by the mapping for the Cypress container. -if ${local}; then +if [ -n "${local}" ]; then # Don't use 'cypress-cache' for local running Cypress GUI, as e.g. macOS reinstalls with Cypress.app and # Linux is later missing Cypress. Users' Cypress default cache is used. export CYPRESS_CACHE_FOLDER="${HOME}/.cache/Cypress" @@ -97,20 +113,6 @@ if ${local}; then npx cypress install 2>/dev/null || sudo bash -c "CYPRESS_CACHE_FOLDER=$CYPRESS_CACHE_FOLDER npx cypress install && chown -R $USER $CYPRESS_CACHE_FOLDER" - if ${joomla_cypress}; then - prefix="../joomla-${instance}/" - else - prefix="" - fi - if [ -f "${prefix}cypress.config.local.mjs" ]; then - config_file="${prefix}cypress.config.local.mjs" - elif [ -f "${prefix}cypress.config.local.js" ]; then - config_file="${prefix}cypress.config.local.js" - else - error "There is no file '${prefix}cypress.config.local.*js'." - exit 1 - fi - # For installExtensionFromFolder() in joomla-cypress/cypress/extensions.cy.js needed # to find 'mod_hello_world' folder. And we can not use 'fixturesFolder' as this is # needed for installExtensionFromFileUpload() with default 'cypress/fixtures'. @@ -118,22 +120,17 @@ if ${local}; then # For joomla-cypress you can set CYPRESS_SKIP_INSTALL_LANGUAGES=1 # to skip installLanguage() and installJoomlaMultilingual() tests. Default here to run the test. - export CYPRESS_SKIP_INSTALL_LANGUAGES=${CYPRESS_SKIP_INSTALL_LANGUAGES:-0} + export CYPRESS_SKIP_INSTALL_LANGUAGES="${CYPRESS_SKIP_INSTALL_LANGUAGES:-0}" log "jbt-${instance} – Open locally installed Cypress GUI" npx cypress open --e2e --project . --config-file "${config_file}" # By the way, the same way it is possible to run Cypress headless from Docker host. else log "jbt-${instance} – Open jbt-cypress container Cypress GUI" - # Install the Cypress version used in this Joomla instance or installation/joomla-cypress, if needed - log "Installing Cypress (if needed)" - # # If it fails, try again with sudo, but specify the user's cache directory and chown afterwards. - # docker exec jbt-cypress bash -c "cd \"/jbt/${cypress_dir}\" && - # CYPRESS_CACHE_FOLDER=/jbt/cypress-cache \ - # npm install cypress" - # Open Cypress e.g. on Windows WSL2 Docker container. - docker exec jbt-cypress bash -c "cd \"/jbt/${cypress_dir}\" && \ + # Open Cypress e.g. on Windows WSL 2 Docker container. + docker exec jbt-cypress bash -c "cd '/jbt/${cypress_dir}' && \ CYPRESS_CACHE_FOLDER=/jbt/cypress-cache \ - CYPRESS_SKIP_INSTALL_LANGUAGES=$CYPRESS_SKIP_INSTALL_LANGUAGES \ - DISPLAY=:0 cypress open --env smtp_port=7325 --e2e --project ." + CYPRESS_SKIP_INSTALL_LANGUAGES='${CYPRESS_SKIP_INSTALL_LANGUAGES}' \ + DISPLAY=:0 \ + npx cypress open --env smtp_port=7325 --e2e --project . --config-file '${config_file}'" fi diff --git a/scripts/test.sh b/scripts/test.sh index 65203ed..fef5842 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -327,6 +327,7 @@ for instance in "${instancesToTest[@]}"; do # With https://github.com/joomla/joomla-cms/pull/44253 Joomla command line client usage has been added # to the System Tests. Hopefully, this is only temporary and can be replaced to reduce complexity and dependency. # Joomla command line client inside Docker container needs to wrote 'configuration.php' file. + # shellcheck disable=SC2012 # We need explict the ls command to get the file mode current_permissions=$(ls -l "joomla-${instance}/configuration.php" | awk '{print $1}' | sed 's/[@+]$//') if [ "${current_permissions}" != "-rw-r--r--" ]; then log "Chmod 644 'joomla-${instance}/configuration.php' for cli/joomla.php"