Skip to content

Commit 98daabf

Browse files
committed
Fail build on error
1 parent 6b6a5fd commit 98daabf

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

.github/workflows/build_helper.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#########################################################################
22
# Modified from Michael Altfield's work:
33
# https://tech.michaelaltfield.net/2020/07/23/sphinx-rtd-github-pages-2/
4-
#########################################################################
4+
#########################################################################
5+
FAILED=0
56
echo "::group::Build env info"
67
pwd
78
ls -lah
89
echo "::endgroup::"
910
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
1011

1112
# make a new temp dir which will be our GitHub Pages docroot
12-
docroot=`mktemp -d`
13+
docroot=$(mktemp -d)
1314

1415
export REPO_NAME="${GITHUB_REPOSITORY##*/}"
1516

@@ -18,11 +19,11 @@ export REPO_NAME="${GITHUB_REPOSITORY##*/}"
1819
##############
1920

2021
# get a list of branches, excluding 'HEAD' and 'gh-pages'
21-
versions="`git for-each-ref '--format=%(refname:lstrip=-1)' refs/remotes/origin/ refs/tags | grep -viE '^(HEAD|gh-pages)$'`"
22+
versions="$(git for-each-ref '--format=%(refname:lstrip=-1)' refs/remotes/origin/ refs/tags | grep -viE '^(HEAD|gh-pages)$')"
2223
for current_version in ${versions}; do
2324
# make the current language available to conf.py
2425
export current_version
25-
git checkout ${current_version} >/dev/null 2>/dev/null
26+
git checkout "${current_version}" >/dev/null 2>/dev/null
2627

2728

2829
echo "::group::Pre-build info for ${current_version}"
@@ -40,7 +41,7 @@ for current_version in ${versions}; do
4041
##########
4142
# BUILDS #
4243
##########
43-
python ./build.py --latex --parallel --force-rebuild --emit-gh-annotations
44+
python ./build.py --latex --parallel --force-rebuild --emit-gh-annotations || FAILED=1
4445

4546
# HTML #
4647

@@ -66,7 +67,7 @@ git checkout latest
6667
git config --global user.name "${GITHUB_ACTOR}"
6768
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
6869

69-
pushd "${docroot}"
70+
pushd "${docroot}" || exit
7071

7172
# don't bother maintaining history; just generate fresh
7273
git init
@@ -109,14 +110,14 @@ EOF
109110
git add .
110111

111112
# commit all the new files
112-
msg="Updating Docs for commit ${GITHUB_SHA} made on `date -d"@${SOURCE_DATE_EPOCH}" --iso-8601=seconds` from ${GITHUB_REF} by ${GITHUB_ACTOR}"
113+
msg="Updating Docs for commit ${GITHUB_SHA} made on $(date -d"@${SOURCE_DATE_EPOCH}" --iso-8601=seconds) from ${GITHUB_REF} by ${GITHUB_ACTOR}"
113114
git commit -am "${msg}"
114115

115116
# overwrite the contents of the gh-pages branch on our github.com repo
116117
git push deploy gh-pages --force
117118
echo "::endgroup::"
118119

119-
popd # return to main repo sandbox root
120+
popd || exit # return to main repo sandbox root
120121

121-
# exit cleanly
122-
exit 0
122+
# exit based on FAILED state
123+
exit $FAILED

build.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,8 @@ def summarize_latex_logfile(logs):
244244
# see https://unix.stackexchange.com/questions/274428/how-do-i-reduce-the-size-of-a-pdf-file-that-contains-images
245245
subprocess.run(['gs', '-sDEVICE=pdfwrite', '-dPDFSETTINGS=/ebook', '-q', '-o', 'output/html/galloway_lab_protocols.pdf', 'output/latex/latex/gallowaylabprotocols.pdf'])
246246
#shutil.copyfile('output/latex/latex/gallowaylabprotocols.pdf', 'output/html/galloway_lab_protocols.pdf')
247+
248+
if args.emit_gh_annotations:
249+
for annotation in gh_annotations:
250+
if annotation.annotation_level == AnnotationLevel.ERROR:
251+
sys.exit(1)

0 commit comments

Comments
 (0)