Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/scripts/ci.sh
Views: 1324
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 nats-server-ci' and 'pnpm database' in two other terminals."
7
echo "Run 'tail -F ci.log' in a terminal to monitor CI status."
8
9
while true; do
10
# wait -- best to do this first, since at initial startup we can't immediately kick off build,
11
# since nats-server needs to build a little to startup, and they will conflict.
12
sleep 30
13
14
# Fetch the latest commits from upstream
15
git fetch
16
17
# Check if local branch is behind the upstream branch
18
LOCAL=$(git rev-parse HEAD)
19
UPSTREAM=$(git rev-parse @{u})
20
21
if [ "$LOCAL" != "$UPSTREAM" ]; then
22
echo "`date` -- 👌 Changes detected in upstream. Pulling changes and executing commands."
23
echo "`date` -- 🔨 Pulling..." >> ci.log
24
25
git pull
26
git log -1 >> ci.log
27
if [ $? -eq 0 ]; then
28
echo "`date` -- ✔️ pulled" >> ci.log
29
echo "`date` -- 🏃 Running..." >> ci.log
30
./scripts/run-ci.sh
31
# cleanup -- temporary workaround -- should be part of test suite?
32
pkill -f `pwd`/packages/project/node_modules/@cocalc/project/bin/cocalc-project.js
33
if [ $? -eq 0 ]; then
34
echo "`date` -- 🎉 **SUCCESS**" >> ci.log
35
else
36
echo "`date` -- 🤖 **FAIL**" >> ci.log
37
fi
38
git log -1 >> ci.log
39
else
40
echo "🐛 failed to pull" >> ci.log
41
fi
42
echo "" >> ci.log
43
echo "`date` -- 🚧 Waiting for changes in upstream..." >> ci.log
44
fi
45
done
46