Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/scripts/ci.sh
1447 views
1
#!/bin/bash
2
3
echo >> ci.log
4
echo "`date` -- 📈 Starting local CoCalc CI." >> ci.log
5
echo "`date` -- 🚧 Waiting for changes in upstream..." >> ci.log
6
echo "You must ALSO run 'pnpm database' in another other terminals."
7
echo "Run 'tail -F ci.log' in a terminal to monitor CI status."
8
9
while true; do
10
# Fetch the latest commits from upstream
11
git fetch
12
13
# Check if local branch is behind the upstream branch
14
LOCAL=$(git rev-parse HEAD)
15
UPSTREAM=$(git rev-parse @{u})
16
17
if [ "$LOCAL" != "$UPSTREAM" ]; then
18
echo "`date` -- 👌 Changes detected in upstream. Pulling changes and executing commands."
19
echo "`date` -- 🔨 Pulling..." >> ci.log
20
21
git pull
22
git log -1 >> ci.log
23
if [ $? -eq 0 ]; then
24
echo "`date` -- ✔️ pulled" >> ci.log
25
echo "`date` -- 🏃 Running..." >> ci.log
26
./scripts/run-ci.sh
27
# cleanup -- temporary workaround -- should be part of test suite?
28
pkill -f `pwd`/packages/project/node_modules/@cocalc/project/bin/cocalc-project.js
29
if [ $? -eq 0 ]; then
30
echo "`date` -- 🎉 **SUCCESS**" >> ci.log
31
else
32
echo "`date` -- 🤖 **FAIL**" >> ci.log
33
fi
34
git log -1 >> ci.log
35
else
36
echo "🐛 failed to pull" >> ci.log
37
fi
38
echo "" >> ci.log
39
echo "`date` -- 🚧 Waiting for changes in upstream..." >> ci.log
40
fi
41
done
42