-
Notifications
You must be signed in to change notification settings - Fork 1
/
silenced-lazy-ghcjs-build.sh
executable file
·56 lines (39 loc) · 1.5 KB
/
silenced-lazy-ghcjs-build.sh
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
#!/usr/bin/env bash
# Log file to dump GHCJS build into
ghcjsTmpLogFile=${ghcjsTmpLogFile:-'/tmp/ghcjsTmpLogFile.log'}
# Length of the GHCJS log tail (<40000)
ghcjsLogTailLength=${ghcjsLogTailLength:-'10000'}
GHCJS_BUILD(){
# NOTE: Function for GHCJS build that outputs its huge log into a file
# Run the build into Log (log is too long for Travis)
"$@" &> "$ghcjsTmpLogFile"
}
SILENT(){
# NOTE: Function that silences the build process
# In normal mode outputs only the /nix/store paths
echo "Log: $ghcjsTmpLogFile"
# Pass into the ghcjsbuild function the build command
if GHCJS_BUILD "$@"
then
# Output log lines for stdout -> cachix caching
grep '^/nix/store/' "$ghcjsTmpLogFile"
else
# Output log lines for stdout -> cachix caching
grep '^/nix/store/' "$ghcjsTmpLogFile"
# Propagate the error state, fail the CI build
exit 1
fi
}
MAIN() {
# Travis GHCJS build
# By itself, GHCJS creates >65000 lines of log that are >4MB in size, so Travis terminates due to log size quota.
# nixbuild --quiet (x5) does not work on GHC JS build
# So there was a need to make it build.
# The solution is to silence the stdout
# But Travis then terminates on 10 min no stdout timeout
# so HACK: SILENT wrapper allows to surpress the huge log, while still preserves the Cachix caching ability in any case of the build
# On build failure outputs the last 10000 lines of log (that should be more then enough), and terminates
SILENT ./ghcjs-build.sh
}
# Run the entry function of the script
MAIN