Skip to content
Merged
2 changes: 2 additions & 0 deletions noir/.rebuild_patterns
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
^noir/scripts/bootstrap_packages.sh
^noir/scripts/test_js_packages.sh
^noir/scripts/test_native.sh
^noir/noir-repo-ref
^noir/noir-repo.patch
33 changes: 24 additions & 9 deletions noir/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,34 @@ function noir_sync {
# Calculate the content hash for caching, taking into account that `noir-repo`
# is not part of the `aztec-packages` repo itself, so the `git ls-tree` used
# by `cache_content_hash` would not take those files into account.
function noir_repo_content_hash {
echo $(REPO_PATH=./noir-repo AZTEC_CACHE_COMMIT=HEAD cache_content_hash $@)
}

# Get the cache content hash. It should only be based on files committed to `aztec-packages`
# in order to be able to support using `AZTEC_CACHE_COMMIT` for historical queries.
function noir_content_hash {
function noir_repo_content_hash {
echo $(REPO_PATH=./noir-repo cache_content_hash $@)
}
with_tests=${1:-0}
# Currently we don't make a distinction between test and non-test hash
tests=${1:-0}

# If there are changes in the noir-repo which aren't just due to the patch applied to it,
# then just disable the cache. We could have workarounds, such as committing the content
# hash that we can calculate with `noir_repo_content_hash` to files, but it's considered
# gross. The tradeoff is that we rebuild based on *any* change captured in the `noir-repo-ref`,
# and that if we add new commits to a feature branch in `noir-repo` then we'd need to return
# the actual content hash if we wanted the build to use caching.
noir_hash=$(cache_content_hash .rebuild_patterns)
noir_repo_hash=$(noir_repo_content_hash .noir-repo.rebuild_patterns)
if [ "$with_tests" == "1" ]; then
noir_repo_hash_tests=$(noir_repo_content_hash .noir-repo.rebuild_patterns_tests)

if [ "${AZTEC_CACHE_COMMIT:-HEAD}" != "HEAD" ]; then
# Ignore the current content of noir-repo, it doesn't support history anyway.
echo $noir_hash
elif [ -f .noir-repo.force-cache ]; then
echo $(hash_str $noir_hash $(noir_repo_content_hash .noir_repo.rebuild_patterns .noir_repo.rebuild_patterns_tests))
Comment thread
aakoshh marked this conversation as resolved.
Outdated
elif scripts/sync.sh has-changes; then
echo "disabled-cache"
else
noir_repo_hash_tests=""
echo $noir_hash
Comment thread
aakoshh marked this conversation as resolved.
fi
echo $(hash_str $noir_hash $noir_repo_hash $noir_repo_hash_tests)
}

# Builds nargo, acvm and profiler binaries.
Expand Down
9 changes: 9 additions & 0 deletions noir/scripts/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ function has_fixup_and_patch {
find_fixup_commit>/dev/null && has_patch_commit
}

# Indicate that the repo has changes, either uncommitted, or unpatched.
function has_changes {
has_uncommitted_changes || ! is_last_commit_patch
}

# Indicate that we have to switch to the wanted branch.
function needs_switch {
! repo_exists && return 0 # true
Expand Down Expand Up @@ -367,6 +372,7 @@ function info {
echo_info "Last commit is patch" $(yesno is_last_commit_patch)
echo_info "Has fixup and patch" $(yesno has_fixup_and_patch)
echo_info "Has uncommitted changes" $(yesno has_uncommitted_changes)
echo_info "Has changes changes" $(yesno has_changes)
echo_info "Latest nightly" $(latest_nightly)
}

Expand All @@ -386,6 +392,9 @@ case "$cmd" in
"needs-patch")
[ -d noir-repo ] && [ -d noir-repo/.git ] && needs_patch && exit 0 || exit 1
;;
"has-changes")
has_changes && exit 0 || exit 1
;;
"latest-nightly")
echo $(latest_nightly)
;;
Expand Down