Skip to content

Commit 8ee3377

Browse files
Michael Vasseurvmcj
authored andcommitted
Annotate GitHub actions log
The current build fails and the log is very hard to read
1 parent b58c97b commit 8ee3377

File tree

2 files changed

+49
-3
lines changed

2 files changed

+49
-3
lines changed

.github/workflows/build-domjudge-container-PR.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@ jobs:
6666
- name: Build and push
6767
run: |
6868
for IMG in domserver judgehost default-judgehost-chroot; do
69+
echo "::group::$IMG"
6970
IMAGE_NAME="${GITHUB_REPOSITORY_OWNER@L}/$IMG:${{ env.DOMJUDGE_VERSION }}"
7071
docker image tag "$IMAGE_NAME" ghcr.io/${GITHUB_REPOSITORY_OWNER@L}/$IMG:${{ env.PR_TAG }}
7172
docker image tag "$IMAGE_NAME" ${GITHUB_REPOSITORY_OWNER@L}/$IMG:${{ env.PR_TAG }}
7273
docker push ghcr.io/${GITHUB_REPOSITORY_OWNER@L}/$IMG:${{ env.PR_TAG }}
74+
echo "::endgroup::"
7375
done
7476
7577
- name: Check for wrong permisions

docker/build.sh

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,43 @@
1-
#!/bin/sh -eu
1+
#!/bin/sh -eux
22

3-
if [ -n "${CI+}" ]
3+
# Placeholders to annotate the Github actions logs
4+
trace_on () { true; }
5+
trace_off () { true; }
6+
section_start () { true; }
7+
section_end () { true; }
8+
9+
if [ -n "${CI+x}" ]
410
then
11+
if [ -n "${GITHUB_ACTION+x}" ]
512
set -x
6-
export PS4='(${0}:${LINENO}): - [$?] $ '
13+
then
14+
# Functions to annotate the Github actions logs
15+
trace_on () { set -x; }
16+
trace_off () {
17+
{ set +x; } 2>/dev/null
18+
}
19+
20+
section_start_internal () {
21+
echo "::group::$1"
22+
trace_on
23+
}
24+
25+
section_end_internal () {
26+
echo "::endgroup::"
27+
trace_on
28+
}
29+
30+
section_start () {
31+
trace_off
32+
section_start_internal "$@"
33+
}
34+
section_end () {
35+
trace_off
36+
section_end_internal
37+
}
38+
else
39+
export PS4='(${0}:${LINENO}): - [$?] $ '
40+
fi
741
fi
842

943
if [ "$#" -eq 0 ] || [ "$#" -gt 2 ]
@@ -24,6 +58,7 @@ fi
2458
URL=https://www.domjudge.org/releases/domjudge-${VERSION}.tar.gz
2559
FILE=domjudge.tar.gz
2660

61+
section_start "Download DOMjudge tarball"
2762
echo "[..] Downloading DOMjudge version ${VERSION}..."
2863

2964
if ! wget --quiet "${URL}" -O ${FILE}
@@ -33,19 +68,27 @@ then
3368
fi
3469

3570
echo "[ok] DOMjudge version ${VERSION} downloaded as domjudge.tar.gz"; echo
71+
section_end
3672

73+
section_start "Build domserver container"
3774
echo "[..] Building Docker image for domserver..."
3875
./build-domjudge.sh "${NAMESPACE}/domserver:${VERSION}"
3976
echo "[ok] Done building Docker image for domserver"
77+
section_end
4078

79+
section_start "Build judgehost container (with intermediate image)"
4180
echo "[..] Building Docker image for judgehost using intermediate build image..."
4281
./build-judgehost.sh "${NAMESPACE}/judgehost:${VERSION}"
4382
echo "[ok] Done building Docker image for judgehost"
83+
section_end
4484

85+
section_start "Build judgehost container (judging chroot)"
4586
echo "[..] Building Docker image for judgehost chroot..."
4687
docker build -t "${NAMESPACE}/default-judgehost-chroot:${VERSION}" -f judgehost/Dockerfile.chroot .
4788
echo "[ok] Done building Docker image for judgehost chroot"
89+
section_end
4890

91+
section_start "Push instructions"
4992
echo "All done. Image ${NAMESPACE}/domserver:${VERSION} and ${NAMESPACE}/judgehost:${VERSION} created"
5093
echo "If you are a DOMjudge maintainer with access to the domjudge organization on Docker Hub, you can now run the following command to push them to Docker Hub:"
5194
echo "$ docker push ${NAMESPACE}/domserver:${VERSION} && docker push ${NAMESPACE}/judgehost:${VERSION} && docker push $NAMESPACE}/default-judgehost-chroot:${VERSION}"
@@ -54,3 +97,4 @@ echo "$ docker tag ${NAMESPACE}/domserver:${VERSION} ${NAMESPACE}/domserver:late
5497
docker tag ${NAMESPACE}/judgehost:${VERSION} ${NAMESPACE}/judgehost:latest && \
5598
docker tag ${NAMESPACE}/default-judgehost-chroot:${VERSION} ${NAMESPACE}/default-judgehost-chroot:latest && \
5699
docker push ${NAMESPACE}/domserver:latest && docker push ${NAMESPACE}/judgehost:latest && docker push ${NAMESPACE}/default-judgehost-chroot:latest"
100+
section_end

0 commit comments

Comments
 (0)