Skip to content

Commit aeb6ccd

Browse files
author
AztecBot
committed
Merge branch 'next' into merge-train/barretenberg
2 parents a2f3539 + 52b6e7d commit aeb6ccd

File tree

4 files changed

+166
-4
lines changed

4 files changed

+166
-4
lines changed

barretenberg/docs/netlify.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build]
2-
# Only build if changes are made in the docs directory
3-
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF"
2+
# Only build if docs-related files changed (docs/ or #include_code references)
3+
ignore = "./scripts/netlify-ignore-build.sh"
44

55
# Redirect root to /docs
66
[[redirects]]
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/usr/bin/env bash
2+
# Netlify ignore script: Skip builds if no docs-related files changed
3+
# Exit 0 = skip build, Exit 1 = proceed with build
4+
#
5+
# This script runs from the barretenberg/docs/ directory (Netlify base)
6+
#
7+
# Strategy:
8+
# - Production deploys (next branch): Compare against CACHED_COMMIT_REF (last deployed commit)
9+
# - PR previews (other branches): Compare against merge-base with next (changes introduced by PR)
10+
#
11+
# This ensures:
12+
# - Production builds when docs change on next (including nightly releases)
13+
# - PR previews only build when the PR has docs changes (no clutter on non-docs PRs)
14+
15+
set -euo pipefail
16+
17+
BASE_BRANCH="next"
18+
19+
# Determine the comparison reference based on deploy context
20+
if [ "${BRANCH:-}" = "$BASE_BRANCH" ]; then
21+
# Production deploy on the base branch - use CACHED_COMMIT_REF
22+
if [ -z "${CACHED_COMMIT_REF:-}" ]; then
23+
echo "Production deploy without cached commit reference - proceeding with build"
24+
exit 1
25+
fi
26+
COMPARE_REF="$CACHED_COMMIT_REF"
27+
echo "Production deploy: comparing $COMMIT_REF against last deployed commit $COMPARE_REF"
28+
else
29+
# PR preview or branch deploy - use merge-base to detect PR-specific changes
30+
# Fetch the base branch to ensure we have it available for merge-base comparison
31+
git fetch origin "$BASE_BRANCH" 2>/dev/null || true
32+
33+
COMPARE_REF=$(git merge-base "origin/$BASE_BRANCH" "$COMMIT_REF" 2>/dev/null || echo "")
34+
35+
if [ -z "$COMPARE_REF" ]; then
36+
echo "Could not determine merge base with $BASE_BRANCH - proceeding with build"
37+
exit 1
38+
fi
39+
echo "PR preview: comparing $COMMIT_REF against merge base $COMPARE_REF (from $BASE_BRANCH)"
40+
fi
41+
42+
# Check for ANY changes in the docs/ directory (current directory in Netlify context)
43+
if ! git diff --quiet "$COMPARE_REF" "$COMMIT_REF" -- .; then
44+
echo "Changes detected in barretenberg/docs/ directory - proceeding with build"
45+
exit 1
46+
fi
47+
48+
# Check for changes in barretenberg/cpp/src/barretenberg (Doxygen source for API docs)
49+
if ! git diff --quiet "$COMPARE_REF" "$COMMIT_REF" -- ../cpp/src/barretenberg; then
50+
echo "Changes detected in barretenberg/cpp/src/barretenberg - proceeding with build"
51+
exit 1
52+
fi
53+
54+
# Check for changes in barretenberg/cpp/docs (Doxygen config and additional source)
55+
if ! git diff --quiet "$COMPARE_REF" "$COMMIT_REF" -- ../cpp/docs; then
56+
echo "Changes detected in barretenberg/cpp/docs - proceeding with build"
57+
exit 1
58+
fi
59+
60+
# Extract all #include_code file references from markdown files
61+
# Pattern: #include_code identifier /path/to/file language
62+
# Paths are relative to repo root (may start with /) or relative to docs
63+
INCLUDE_CODE_PATHS=$(
64+
find . -type f \( -name "*.md" -o -name "*.mdx" \) 2>/dev/null | \
65+
xargs grep -h '^#include_code' 2>/dev/null | \
66+
awk '{ gsub("^/", "", $3); print $3 }' | \
67+
sort -u || true
68+
)
69+
70+
# Check each referenced external file for changes
71+
for path in $INCLUDE_CODE_PATHS; do
72+
if [ -n "$path" ]; then
73+
# Check if path exists relative to current dir or relative to repo root
74+
if [ -f "./$path" ]; then
75+
# Path is relative to docs/ - already covered by the docs/ check above
76+
continue
77+
fi
78+
# Path is relative to repo root
79+
if ! git diff --quiet "$COMPARE_REF" "$COMMIT_REF" -- "../../$path" 2>/dev/null; then
80+
echo "Changes detected in included file: $path - proceeding with build"
81+
exit 1
82+
fi
83+
fi
84+
done
85+
86+
echo "No docs-related changes detected - skipping build"
87+
exit 0

docs/netlify.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# BUILD CONFIGURATION
33
# =============================================================================
44
[build]
5-
# Only build if changes are made in the docs directory
6-
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF"
5+
# Only build if docs-related files changed (docs/, aztec-nr/, or #include_code references)
6+
ignore = "./scripts/netlify-ignore-build.sh"
77
command = "yarn build"
88
functions = "netlify/functions"
99

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env bash
2+
# Netlify ignore script: Skip builds if no docs-related files changed
3+
# Exit 0 = skip build, Exit 1 = proceed with build
4+
#
5+
# This script runs from the docs/ directory (Netlify base)
6+
#
7+
# Strategy:
8+
# - Production deploys (next branch): Compare against CACHED_COMMIT_REF (last deployed commit)
9+
# - PR previews (other branches): Compare against merge-base with next (changes introduced by PR)
10+
#
11+
# This ensures:
12+
# - Production builds when docs change on next (including nightly releases)
13+
# - PR previews only build when the PR has docs changes (no clutter on non-docs PRs)
14+
15+
set -euo pipefail
16+
17+
BASE_BRANCH="next"
18+
19+
# Determine the comparison reference based on deploy context
20+
if [ "${BRANCH:-}" = "$BASE_BRANCH" ]; then
21+
# Production deploy on the base branch - use CACHED_COMMIT_REF
22+
if [ -z "${CACHED_COMMIT_REF:-}" ]; then
23+
echo "Production deploy without cached commit reference - proceeding with build"
24+
exit 1
25+
fi
26+
COMPARE_REF="$CACHED_COMMIT_REF"
27+
echo "Production deploy: comparing $COMMIT_REF against last deployed commit $COMPARE_REF"
28+
else
29+
# PR preview or branch deploy - use merge-base to detect PR-specific changes
30+
# Fetch the base branch to ensure we have it available for merge-base comparison
31+
git fetch origin "$BASE_BRANCH" 2>/dev/null || true
32+
33+
COMPARE_REF=$(git merge-base "origin/$BASE_BRANCH" "$COMMIT_REF" 2>/dev/null || echo "")
34+
35+
if [ -z "$COMPARE_REF" ]; then
36+
echo "Could not determine merge base with $BASE_BRANCH - proceeding with build"
37+
exit 1
38+
fi
39+
echo "PR preview: comparing $COMMIT_REF against merge base $COMPARE_REF (from $BASE_BRANCH)"
40+
fi
41+
42+
# Check for ANY changes in the docs/ directory (current directory in Netlify context)
43+
if ! git diff --quiet "$COMPARE_REF" "$COMMIT_REF" -- .; then
44+
echo "Changes detected in docs/ directory - proceeding with build"
45+
exit 1
46+
fi
47+
48+
# Check for changes in noir-projects/aztec-nr (source for autogenerated aztec-nr docs)
49+
if ! git diff --quiet "$COMPARE_REF" "$COMMIT_REF" -- ../noir-projects/aztec-nr; then
50+
echo "Changes detected in noir-projects/aztec-nr - proceeding with build"
51+
exit 1
52+
fi
53+
54+
# Extract all #include_code file references from markdown files
55+
# Pattern: #include_code identifier /path/to/file language
56+
# Paths are relative to repo root
57+
INCLUDE_CODE_PATHS=$(
58+
find . -type f \( -name "*.md" -o -name "*.mdx" \) 2>/dev/null | \
59+
xargs grep -h '^#include_code' 2>/dev/null | \
60+
awk '{ gsub("^/", "", $3); print $3 }' | \
61+
sort -u || true
62+
)
63+
64+
# Check each referenced external file for changes
65+
for path in $INCLUDE_CODE_PATHS; do
66+
if [ -n "$path" ]; then
67+
if ! git diff --quiet "$COMPARE_REF" "$COMMIT_REF" -- "../$path" 2>/dev/null; then
68+
echo "Changes detected in included file: $path - proceeding with build"
69+
exit 1
70+
fi
71+
fi
72+
done
73+
74+
echo "No docs-related changes detected - skipping build"
75+
exit 0

0 commit comments

Comments
 (0)