Skip to content

Commit

Permalink
webservice: simplify setup
Browse files Browse the repository at this point in the history
* Don't copy webservice dir to www/js in CI/CD. Instead, just place a package.json file in www/js whose start command runs server.js in webservice dir. Avoid file import caveats.
* Move all dependencies from webservice package.json and put them in the central package.json. Avoids same dependency (with possibly different versions) coming from two places.
  • Loading branch information
siddharthvp committed Jun 13, 2024
1 parent c90631c commit b024cd2
Show file tree
Hide file tree
Showing 8 changed files with 1,428 additions and 5,580 deletions.
20 changes: 3 additions & 17 deletions .github/workflows/toolforge-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,11 @@ jobs:
echo "Restarting eventstream-router ...";
cd eventstream-router && npm restart && cd -;
fi;
if [[ "$(git diff --name-only HEAD HEAD@{1} | grep -c "webservice/")" -gt 0 ]]; then
if [[ "$(git diff --name-only HEAD HEAD@{1} | grep -c "webservice/package.json")" -gt 0 ]]; then
echo "Running npm install for SDZeroBot/webservice ...";
cd /data/project/sdzerobot/SDZeroBot/webservice && npm install --only=production;
fi;
echo "Syncing SDZeroBot/webservice with www/js ...";
cd /data/project/sdzerobot && rsync -avu --delete "SDZeroBot/webservice/" "www/js";
cp webservice/www-js-package.json /data/project/sdzerobot/www/js/package.json;
if [[ "$(git diff --name-only HEAD HEAD@{1} | grep -c "webservice/")" -gt 0 || "$(git diff --name-only HEAD HEAD@{1} | grep -c "web-endpoint")" -gt 0 || "$(git diff --name-only HEAD HEAD@{1} | grep -c "hbs")" -gt 0 || "$(git rev-list --format=%B --max-count=1 HEAD)" == *"!restart"* || "$(git rev-list --format=%B --max-count=1 HEAD)" == *"!web-restart"* ]]; then
echo "Restarting SDZeroBot webservice ...";
cd /data/project/sdzerobot/www/js;
if [[ ($(grep "\.\." *.ts | grep -v SDZeroBot | grep -v -c mwn) -gt 0) || ($(grep "\.\.\/\.\." routes/*.ts | grep -v SDZeroBot | grep -v -c mwn) -gt 0) ]]; then
echo "Suspicious imports found in webservice!";
grep "\.\." *.ts | grep -v SDZeroBot;
grep "\.\.\/\.\." routes/*.ts | grep -v SDZeroBot;
exit 1;
fi;
cd /data/project/sdzerobot/SDZeroBot/webservice;
npm restart;
elif [[ "$(git diff --name-only HEAD HEAD@{1} | grep -c "web-endpoint")" -gt 0 || "$(git diff --name-only HEAD HEAD@{1} | grep -c "hbs")" -gt 0 || "$(git rev-list --format=%B --max-count=1 HEAD)" == *"!restart"* || "$(git rev-list --format=%B --max-count=1 HEAD)" == *"!web-restart"* ]]; then
echo "Restarting SDZeroBot webservice ...";
cd /data/project/sdzerobot/www/js && npm restart;
fi;
'
host: login.toolforge.org
Expand Down
Loading

0 comments on commit b024cd2

Please sign in to comment.