Skip to content

Commit

Permalink
Fixes/Improvements after testing Windows
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
muhme committed Dec 14, 2024
1 parent 380179e commit 368b42c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.9
2.1.10
4 changes: 3 additions & 1 deletion scripts/create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
53 changes: 25 additions & 28 deletions scripts/cypress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -97,43 +113,24 @@ 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'.
export CYPRESS_SERVER_UPLOAD_FOLDER='/jbt/installation/joomla-cypress/cypress/fixtures/mod_hello_world'

# 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
1 change: 1 addition & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 368b42c

Please sign in to comment.