Skip to content

Commit

Permalink
fix: map relative path to protocol circuits (AztecProtocol#3694)
Browse files Browse the repository at this point in the history
This PR fixes an issue with how we mirror code in the monorepo to
aztecprotocol/aztec-nr.

A while back the root aztec library added a dependency on
noir-protocol-circuits. In the monorepo this is achieved by use of a
relative path in Nargo.toml. This works fine for contracts that pull in
Aztec.nr through the monorepo (see also AztecProtocol#3604) but it breaks projects
that use
[AztecProtocol/aztec-nr](https://github.com/AztecProtocol/aztec-nr)
because the relative path won't exist in the mirrored repo.

What this PR does is map any relative dependencies to protocol circuits
to a git dependency before pushing that commit to the mirrored repo. It
then undoes this change before pushing to the monorepo (we want to keep
using relative paths in the monorepo).

I would've preferred using `yq` since it claims it suports TOML (and is
included in the default Github actions package list) but its support is
limited to only basic types (so no objects like `{path="..."}`) and it
can only read toml but not write it.

mikefarah/yq#1364 (comment)
  • Loading branch information
alexghr authored Dec 15, 2023
1 parent 8af8f9b commit 9b5983e
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/mirror_repos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name: Mirror Repositories
on:
schedule:
# Run the workflow every night at 2:00 AM UTC.
- cron: '0 2 * * *'
- cron: "0 2 * * *"

jobs:
mirror-to-build-system-repo:
Expand Down Expand Up @@ -72,9 +72,33 @@ jobs:
git config --global user.name AztecBot
git config --global user.email tech@aztecprotocol.com
monorepo_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
# list all aztec-packages tags, take the "highest" version
monorepo_tag="$(git tag --list aztec-packages-v* | sort --version-sort | tail -1)"
monorepo_protocol_circuits_path="yarn-project/noir-protocol-circuits"
nargo_file="$SUBREPO_PATH/aztec/Nargo.toml"
# match lines like this:
# protocol_types = { path = "../../noir-protocol-circuits/src/crates/types" }
# and replace with
# protocol_types = { git="https://github.com/aztecprotocol/aztec-packages", tag="aztec-packages-v0.16.9", directory="yarn-project/noir-protocol-circuits/src/crates/types" }
sed --regexp-extended --in-place \
"s;path\s*=\s*\".*noir-protocol-circuits(.*)\";git=\"$monorepo_url\", tag=\"$monorepo_tag\", directory=\"$monorepo_protocol_circuits_path\1\";" \
$nargo_file
git commit --all --message "chore: replace relative paths to noir-protocol-circuits"
if ./scripts/git_subrepo.sh push $SUBREPO_PATH --branch=master; then
git fetch # in case a commit came after this
git rebase origin/master
git commit --amend -m "$(git log -1 --pretty=%B) [skip ci]"
# restore old Nargo.toml
# We have to go back two generations. History looks like this:
# HEAD <--- the commit generated by git_subrepo
# HEAD~1 <--- the chore commit created above
# HEAD~2 <--- the original commit we were supposed to mirror or the tip of master after rebase
git restore --source=HEAD~2 -- $nargo_file
git commit --all --amend -m "$(git log -1 --pretty=%B) [skip ci]"
git push
fi

0 comments on commit 9b5983e

Please sign in to comment.