Skip to content

Commit 170999d

Browse files
committed
Always fail on Mintlify parsing errors
For some reason Mintlify CLI returns 0 even when parsing errors exist - this is likely the case when these errors appear in files that are not (yet) referenced by docs.json.
1 parent 3d8663c commit 170999d

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

mintlify/Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,44 @@
1+
# This Dockerfile is way more complex than it should be thanks to a bug in the
2+
# Mintlify CLI: It does not fail when it discovers parsing errors in .mdx
3+
# files that are not (yet) referenced by docs.json.
4+
# We work around this issue by running mint via script(1) - unlike tee(1) it
5+
# is able to redirect output to a file while preserving colored output in the
6+
# terminal. Then we check the file contents for actual parsing errors.
7+
# Unfortunately the newest readily available version of script is too old,
8+
# so we need to build our own binary (called script2) in the build stage.
9+
10+
# Build stage
11+
FROM gcr.io/bazel-public/ubuntu2404 AS builder
12+
13+
# Install build dependencies
14+
RUN apt-get update && apt-get install -y \
15+
wget \
16+
build-essential \
17+
tar \
18+
&& rm -rf /var/lib/apt/lists/*
19+
20+
WORKDIR /build
21+
22+
# Download, extract, and build util-linux
23+
RUN wget -c "https://www.kernel.org/pub/linux/utils/util-linux/v2.42/util-linux-2.42.1.tar.gz" -O util-linux.tar.gz \
24+
&& tar -xzvf util-linux.tar.gz \
25+
&& cd util-linux-2.42.1 \
26+
&& ./configure --disable-all-programs --enable-scriptutils \
27+
&& make
28+
129
# Use the Bazel public image as the base
230
FROM gcr.io/bazel-public/ubuntu2404
331

432
# Install dependencies: jq and deps of nodejs
533
RUN apt-get update && apt-get install -y \
634
jq ca-certificates curl gnupg
735

36+
# Copy the compiled binary from the builder stage
37+
COPY --from=builder /build/util-linux-2.42.1/script /usr/bin/script2
38+
39+
# Ensure it's executable
40+
RUN chmod +x /usr/bin/script2
41+
842
# Install nodejs as per https://github.com/nodesource/distributions/wiki/Repository-Manual-Installation#debian-systems
943
RUN mkdir -p /etc/apt/keyrings && \
1044
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \

mintlify/check_docs.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,14 @@ fi
3434

3535
echo "+++ :male-detective::books: Checking documentation with Mintlify"
3636

37+
LOG_FILE="log.txt"
3738
# https://www.mintlify.com/docs/installation#validate-documentation-build
3839
# If validation fails, we annotate the build and exit.
39-
if ! mint validate; then
40+
# "mint validate" sometimes returns 0 even though parsing errors exist
41+
# (this usually happens if the file is not yet referenced by docs.json).
42+
# That's why we use `script` to print to stdout and a file while preserving
43+
# colored output, then check the file for parsing errors.
44+
if ! script2 -eq "$LOG_FILE" -- "mint validate" || grep -q "parsing error" "$LOG_FILE"; then
4045
cat /usr/local/annotation.html | buildkite-agent annotate --style "error" --context "mdx_parser"
4146
exit 1
4247
fi

0 commit comments

Comments
 (0)