-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild-all
More file actions
executable file
·72 lines (62 loc) · 2.25 KB
/
build-all
File metadata and controls
executable file
·72 lines (62 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
source ./functions.sh
# reads a list of packages to be built in order.
# it counts the packages to be build in parallel
# when it encounters a "-" it reports how many pending builds there are, and waits for all the previous packages to finish building.
# exit on any failure:
set -e
BUILD_CMD=${1:-build:types}
_FAILCOUNT=0
cat deps-order | while read package ; do {
if [[ $package == "-" ]]; then
if [[ $_FAILCOUNT -ge 1 ]]; then
wait
continue
fi
COUNT=$(jobs -p | wc -l)
echo "Waiting for $COUNT builds ..."
# wait || exit 1
# waits for a single job to finish, checks its exit status for success or failure
# if a job fails, the script will exit with status 1
# if a job succeeds, it shows how many jobs are still pending, and continues waiting for more jobs to finish.
while true; do
wait -n || {
echo
echo
echo 2>&1
echo "Build failed" 2>&1
# increment the failed count
_FAILCOUNT=$((_FAILCOUNT + 1))
}
COUNT=$(jobs -p | wc -l)
[[ $COUNT -eq 0 ]] && {
echo
if [[ $_FAILCOUNT -eq 0 ]] ; then {
echo " -- dependencies built; proceeding to next batch --"
} else {
echo " -- dependencies built; but ${_FAILCOUNT} failed; skipping remaining jobs --"
} fi
break
}
echo "Waiting for $COUNT builds ..."
done
else
if [[ $package == "-----" ]]; then
echo "Done!"
exit 0
fi
if [[ $_FAILCOUNT -ge 1 ]]; then
echo "Skipping $package"
continue
fi
echo "Building $package"
{
# runs pnpm build, labels the output, and prints the output even if the build fails.
# if the build fails, the subtask exits with the same status code as the build.
# if the build succeeds, the subtask exits with status code 0.
cd $package
pnpm $BUILD_CMD 1> >(labeledOutput "$package") || exit $?
} &
fi
} done
wait