-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile.sh
More file actions
executable file
·75 lines (62 loc) · 2.79 KB
/
compile.sh
File metadata and controls
executable file
·75 lines (62 loc) · 2.79 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
72
73
74
75
#!/usr/bin/env bash
# input validation
if ! [[ $TIMEOUT_MINUTES =~ ^[0-9]+$ ]] ; then
workflow="${GITHUB_WORKFLOW_REF%@*}"
workflow=".github/workflows/${workflow#*/.github/workflows/}"
workflow_lineno="$(sed -n '/timeout-minutes:/{=;q;}' < "$workflow")"
echo "::error file=$workflow,line=${workflow_lineno:-1},title=Invalid timeout-minutes value::The value '$TIMEOUT_MINUTES' of timeout-minutes is not a positive integer."
echo 'outcome=invalid' >> "$GITHUB_OUTPUT"
exit 1
fi
### Download BookML image
case $SCHEME in
full) scheme= ;;
*) scheme="-$SCHEME" ;;
esac
IMAGE="ghcr.io/vlmantova/bookml$scheme:$VERSION"
echo "::group::Downloading BookML image \`$IMAGE\`"
docker pull "$IMAGE"
ret="$?"
if [[ $ret != 0 ]] ; then
workflow="${GITHUB_WORKFLOW_REF%@*}"
workflow=".github/workflows/${workflow#*/.github/workflows/}"
workflow_lineno="$(sed -n '/scheme:/{=;q;}' < "$workflow")"
workflow_lineno="${workflow_lineno:-$(sed -n '/version:/{=;q;}' < "$workflow")}"
echo "::error file=$workflow,line=${workflow_lineno:-1},title=Could not download Docker image::Could not download Docker image $IMAGE. Check if version '$VERSION' and scheme '$SCHEME' are valid."
echo 'outcome=invalid' >> "$GITHUB_OUTPUT"
exit "$ret"
fi
echo "::endgroup::"
### end Download BookML image
### Compile with BookML image
echo "::add-matcher::$GITHUB_ACTION_PATH/bookml.json"
restartToken="restart-commands-$RANDOM$RANDOM"
echo "::stop-commands::$restartToken"
# TODO: parallel build
docker run --rm --interactive=true --volume="$GITHUB_WORKSPACE":/source \
--volume="$RUNNER_TEMP/auxdir":/auxdir --volume="$GITHUB_OUTPUT":/github-output\
--env=REPLACE_BOOKML="$REPLACE_BOOKML" --env=TIMEOUT_MINUTES="$TIMEOUT_MINUTES" \
--entrypoint /bin/bash "$IMAGE" -s <<'EOF'
if [[ $REPLACE_BOOKML == true ]] ; then
/run-bookml update || echo '::error title=Could not replace the bookml/ folder::Could not replace the bookml/ folder.'
fi
export max_print_line=10000
timeout "$TIMEOUT_MINUTES"m /run-bookml -k all AUX_DIR=/auxdir 2>&1 | tee /auxdir/bookml-report.log
case "${PIPESTATUS[0]}" in
124|137) outcome=timeout
echo "::error title=Compiling timed out::Increase \`timeout-minutes\` to allow more time." ;;
0) outcome=success ;;
*) outcome=failure ;;
esac
targets="$(grep '^ Targets: ' < /auxdir/bookml-report.log | head -n 1 | sed -E -e 's/^.*:\s*|(\s| )*$//g')"
outputs="${targets:+$(ls -C --width=0 $targets 2>/dev/null || :)}"
echo "outcome=$outcome" >> /github-output
echo "targets=$targets" >> /github-output
echo "outputs=$outputs" >> /github-output
EOF
echo "::$restartToken::"
echo "::remove-matcher owner=bookml-latex-errors::"
echo "::remove-matcher owner=bookml-latexml-errors::"
echo "::remove-matcher owner=bookml-latexml-warnings::"
grep -q '^outcome=success$' "$GITHUB_OUTPUT"
### end Compile with BookML image