Skip to content

Commit

Permalink
Add waiting script during docker initialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
jolelievre committed May 23, 2024
1 parent 704424f commit c0d6e60
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .docker/docker_run_git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ if [ "${DISABLE_MAKE}" != "1" ]; then

echo "\n* Build assets ...";
runuser -g www-data -u www-data -- /usr/bin/make assets

echo "\n* Wait for assets built...";
/usr/bin/make wait-assets
else
echo "\n* Build of assets was disabled...";
fi
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sanity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
uses: ./.github/actions/setup-env-export-logs
with:
DOCKER_PREFIX: prestashop
if: failure()
if: always()

- name: Run Tests
uses: ./.github/actions/ui-test
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ composer: ## Install PHP dependencies
assets: ## Rebuilds all the static assets, running npm install-clean as needed
./tools/assets/build.sh

wait-assets:
./tools/assets/wait-build.sh

front-core: ## Building core theme assets
./tools/assets/build.sh front-core

Expand Down
2 changes: 2 additions & 0 deletions tools/assets/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ function build {
rm -rf node_modules
fi

touch buildLock
npm ci
npm run build
rm buildLock
popd
}

Expand Down
60 changes: 60 additions & 0 deletions tools/assets/wait-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

###
# This script waits for assets to be built by checking the presence of the buildLock file
#

#http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
PROJECT_PATH=$(cd "$( dirname "$0" )/../../" && pwd)
ADMIN_DIR="${PROJECT_PATH}/${ADMIN_DIR:-admin-dev}"

if [[ ! -d $ADMIN_DIR ]]; then
echo "Could not find directory '$ADMIN_DIR'. Make sure to launch this script from the root directory of PrestaShop"
return 1
fi

if test $# -gt 0; then
case $1 in
admin-default)
echo ">>> Waiting for admin default theme..."
buildLocks="$ADMIN_DIR/themes/default/buildLock"
;;
admin-new-theme)
echo ">>> Waiting for admin new theme..."
buildLocks="$ADMIN_DIR/themes/new-theme/buildLock"
;;
front-core)
echo ">>> Waiting for core theme assets..."
buildLocks="$PROJECT_PATH/themes/buildLock"
;;
front-classic)
echo ">>> Waiting for classic theme assets..."
buildLocks="$PROJECT_PATH/themes/classic/_dev/buildLock"
;;
all)
echo ">>> Waiting for all assets..."
buildLocks="$ADMIN_DIR/themes/default/buildLock $ADMIN_DIR/themes/new-theme/buildLock $PROJECT_PATH/themes/classic/_dev/buildLock $PROJECT_PATH/themes/buildLock"
;;
*)
echo "Unknown asset to wait $1"
exit 1
;;
esac
else
echo ">>> Waiting for all assets..."
buildLocks="$ADMIN_DIR/themes/default/buildLock $ADMIN_DIR/themes/new-theme/buildLock $PROJECT_PATH/themes/classic/_dev/buildLock $PROJECT_PATH/themes/buildLock"
fi

echo Checking for all these lock files $buildLocks
for lockFile in $buildLocks; do
if [ -f $lockFile ]; then
echo Wait for $lockFile to be removed
sleep 1
while [ -f $lockFile ]; do
echo $lockFile still present wait a bit more
sleep 1
done
fi
echo $lockFile is no longer present
done

0 comments on commit c0d6e60

Please sign in to comment.