Skip to content

Commit

Permalink
Restore installation folder with www-data
Browse files Browse the repository at this point in the history
And moved the functionality to helper.sh as it is used in two places.
  • Loading branch information
muhme committed Dec 14, 2024
1 parent 368b42c commit cdeb072
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 32 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.10
2.1.11
15 changes: 1 addition & 14 deletions scripts/cypress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,7 @@ fi
if ${joomla_cypress}; then
cypress_dir="installation/joomla-cypress"
# joomla-cypress' installJoomlaMultilingualSite() test deletes installation directory – restore it
if [ ! -d "joomla-${instance}/installation" ]; then
if [ -d "installation/joomla-${instance}/installation" ]; then
log "jbt-${instance} – Restoring 'joomla-${instance}/installation' directory"
cp -r "installation/joomla-${instance}/installation" "joomla-${instance}/installation" 2>/dev/null ||
sudo cp -r "installation/joomla-${instance}/installation" "joomla-${instance}/installation"
if [ -f "joomla-${instance}/package.json" ]; then
log "jbt-${instance} – Running npm clean install"
docker exec "jbt-${instance}" bash -c 'cd /var/www/html && npm ci'
fi
else
error "jbt-${instance} – Missing 'joomla-${instance}/installation' directory"
# Proceed in the hope that it will not be needed
fi
fi
restoreInstallationFolder "${instance}"
else
cypress_dir="joomla-${instance}"
# With https://github.com/joomla/joomla-cms/pull/44253 Joomla command line client usage has been added
Expand Down
24 changes: 24 additions & 0 deletions scripts/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,30 @@ isValidTestName() {
return 1 # No
}

# The Cypress custom command installJoomlaMultilingualSite() deletes the Joomla installation folder.
# Restore the saved installation folder and set ownership to www-data:www-data.
#
restoreInstallationFolder() {
local instance="$1"

if [ ! -d "joomla-${instance}/installation" ]; then
if [ -d "installation/joomla-${instance}/installation" ]; then
log "jbt-${instance} – Restoring 'joomla-${instance}/installation' directory"
cp -r "installation/joomla-${instance}/installation" "joomla-${instance}/installation" 2>/dev/null ||
sudo cp -r "installation/joomla-${instance}/installation" "joomla-${instance}/installation"
if [ -f "joomla-${instance}/package.json" ]; then
log "jbt-${instance} – Running npm clean install"
docker exec "jbt-${instance}" bash -c 'cd /var/www/html && npm ci'
fi
# Restored files are owned by root and next time installJoomlaMultilingualSite() will fail deleting them.
docker exec "jbt-${instance}" bash -c 'chown -R www-data:www-data /var/www/html >/dev/null 2>&1 || true &' &
else
error "jbt-${instance} – Missing 'joomla-${instance}/installation' directory"
# Proceed in the hope that it will not be needed
fi
fi
}

# Return script running time e.g. as "17 seconds" or as "3:18".
#
runningTime() {
Expand Down
19 changes: 2 additions & 17 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -240,23 +240,8 @@ for instance in "${instancesToTest[@]}"; do
# Cypress tests?
if [[ "${actualTest}" =~ ^(system|joomla-cypress)$ ]]; then
spec="${spec_argument}"

# joomla-cypress' installJoomlaMultilingualSite() test deletes installation directory – restore it
if [ ! -d "joomla-${instance}/installation" ]; then
if [ -d "installation/joomla-${instance}/installation" ]; then
log "jbt-${instance} – Restoring 'joomla-${instance}/installation' directory"
cp -r "installation/joomla-${instance}/installation" "joomla-${instance}/installation" 2>/dev/null ||
sudo cp -r "installation/joomla-${instance}/installation" "joomla-${instance}/installation"
if [ -f "joomla-${instance}/package.json" ]; then
log "jbt-${instance} – Running npm clean install"
docker exec "jbt-${instance}" bash -c 'cd /var/www/html && npm ci'
fi
else
error "jbt-${instance} – Missing 'joomla-${instance}/installation' directory"
# Continue in the hope that it is not needed
fi
fi

restoreInstallationFolder "${instance}"
# Handle .js or .mjs from PR https://github.com/joomla/joomla-cms/pull/43676 – [4.4] Move the Cypress Tests to ESM
if [ -f "joomla-${instance}/cypress.config.dist.js" ]; then
extension="js"
Expand Down Expand Up @@ -327,7 +312,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
# 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 cdeb072

Please sign in to comment.