Skip to content

Commit b3182ed

Browse files
authored
chore: Necessary fixes to earthly book building | NPG-000 (#544)
# Description fix: add rustfmt to run rustdoc-tests. feat: retry commands in entry scripts up to 6 times ## Type of change Please delete options that are not relevant. - [x] Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? - [x] Running `earthly -P ./containers/book+build-docs` locally. ## Checklist - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules
1 parent 79165d5 commit b3182ed

File tree

3 files changed

+48
-12
lines changed

3 files changed

+48
-12
lines changed

containers/book/Earthfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ FROM debian:stable-slim
44

55
builder:
66
FROM ghcr.io/input-output-hk/catalyst-gh-tools:v1.4.3
7+
RUN rustup component add rustfmt
78

89
COPY --dir ../..+rust-source/src .
910
COPY --dir ../..+rust-source/tests .
@@ -20,6 +21,7 @@ rustdoc-test:
2021
rustdoc:
2122
FROM +builder
2223

24+
BUILD +rustdoc-test
2325
RUN rustup component add rustfmt --toolchain nightly-x86_64-unknown-linux-gnu
2426
ENV RUSTDOCFLAGS="$RUSTDOCFLAGS --enable-index-page -Zunstable-options"
2527
RUN cargo +nightly doc \
@@ -55,7 +57,7 @@ builder-chapter-8:
5557

5658
RUN mkdir /db-diagrams
5759

58-
CMD ["./build-db-diagrams.sh"]
60+
ENTRYPOINT ["./build-db-diagrams.sh"]
5961

6062
# Need to be run with the -P flag
6163
build-chapter-8:
@@ -93,7 +95,9 @@ mdbook:
9395

9496
# Add an empty '.git' folder, needed by mdbook-open-on-gh for relative path calculation
9597
RUN mkdir .git
96-
CMD while ! mdbook build; do sleep 1; done;
98+
COPY build-mdbook.sh .
99+
RUN chmod ugo+x ./build-mdbook.sh
100+
ENTRYPOINT ["./build-mdbook.sh"]
97101

98102
#RUN mdbook build
99103
SAVE ARTIFACT book

containers/book/build-db-diagrams.sh

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
#!/bin/bash
2-
echo "Starting to build Event DB diagrams."
2+
echo "Starting to build EventDB diagrams."
33
# doc-event-db-setup
4-
echo "Initializing Event DB."
4+
echo "Initializing EventDB."
55
pushd src/event-db
66
# [tasks.doc-event-db-init]
7-
while ! psql -e -f setup/setup-db.sql \
7+
# retry up to six times every 5 seconds
8+
if ! (r=6; while ! psql -e -f setup/setup-db.sql \
89
-v dbName=CatalystEventDocs \
9-
-v dbDescription="Local Docs Catalayst Event DB" \
10+
-v dbDescription="Local Docs Catalayst EventDB" \
1011
-v dbUser="catalyst-event-docs" \
11-
-v dbUserPw="CHANGE_ME" ${@};
12-
do sleep 1;
13-
done;
12+
-v dbUserPw="CHANGE_ME" ${@}; do
13+
((--r))||exit
14+
echo "Failed to initialize EventDB. Retrying."
15+
sleep 5; done;) ; then
16+
echo "EventDB initialization failed."
17+
exit 1;
18+
fi
19+
echo "Initialized EventDB"
20+
1421
# [tasks.run-event-doc-db-migration]
1522
refinery migrate -e DATABASE_URL -c refinery.toml -p ./migrations
1623

1724

18-
## Build the Event DB Documentation (Images of Schema)
25+
## Build the EventDB Documentation (Images of Schema)
1926
popd
20-
echo "Building Event DB diagrams."
27+
echo "Building EventDB diagrams."
2128
# [tasks.build-db-docs-overview-diagram]
2229
dbviz -d CatalystEventDocs \
2330
-h postgres \
@@ -115,4 +122,4 @@ dbviz -d CatalystEventDocs \
115122
moderation \
116123
> /db-diagrams/event-db-moderation.dot
117124

118-
echo "Finished building Event DB diagrams."
125+
echo "Finished building EventDB diagrams."

containers/book/build-mdbook.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# Enable strict mode
4+
set +x
5+
set -o errexit
6+
set -o pipefail
7+
set -o nounset
8+
set -o functrace
9+
set -o errtrace
10+
set -o monitor
11+
set -o posix
12+
shopt -s dotglob
13+
14+
echo ">>> Building mdbook..."
15+
CMD="mdbook build"
16+
# will retry to build 6 times every 5 seconds
17+
if ! (r=6; while ! eval "$CMD" ; do
18+
((--r))||exit
19+
echo "Build failed. Retrying.";
20+
sleep 5;done) ; then
21+
exit 1
22+
fi
23+
24+
echo ">>> Build successful.";
25+
exit 0

0 commit comments

Comments
 (0)