Skip to content

Commit 125ab1d

Browse files
authored
fix: map relative path to protocol circuits (AztecProtocol#3694)
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)
1 parent 93f9315 commit 125ab1d

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

.github/workflows/mirror_repos.yml

+26-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name: Mirror Repositories
99
on:
1010
schedule:
1111
# Run the workflow every night at 2:00 AM UTC.
12-
- cron: '0 2 * * *'
12+
- cron: "0 2 * * *"
1313

1414
jobs:
1515
mirror-to-build-system-repo:
@@ -72,9 +72,33 @@ jobs:
7272
git config --global user.name AztecBot
7373
git config --global user.email tech@aztecprotocol.com
7474
75+
monorepo_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
76+
# list all aztec-packages tags, take the "highest" version
77+
monorepo_tag="$(git tag --list aztec-packages-v* | sort --version-sort | tail -1)"
78+
monorepo_protocol_circuits_path="yarn-project/noir-protocol-circuits"
79+
nargo_file="$SUBREPO_PATH/aztec/Nargo.toml"
80+
81+
# match lines like this:
82+
# protocol_types = { path = "../../noir-protocol-circuits/src/crates/types" }
83+
# and replace with
84+
# protocol_types = { git="https://github.com/aztecprotocol/aztec-packages", tag="aztec-packages-v0.16.9", directory="yarn-project/noir-protocol-circuits/src/crates/types" }
85+
sed --regexp-extended --in-place \
86+
"s;path\s*=\s*\".*noir-protocol-circuits(.*)\";git=\"$monorepo_url\", tag=\"$monorepo_tag\", directory=\"$monorepo_protocol_circuits_path\1\";" \
87+
$nargo_file
88+
89+
git commit --all --message "chore: replace relative paths to noir-protocol-circuits"
90+
7591
if ./scripts/git_subrepo.sh push $SUBREPO_PATH --branch=master; then
7692
git fetch # in case a commit came after this
7793
git rebase origin/master
78-
git commit --amend -m "$(git log -1 --pretty=%B) [skip ci]"
94+
95+
# restore old Nargo.toml
96+
# We have to go back two generations. History looks like this:
97+
# HEAD <--- the commit generated by git_subrepo
98+
# HEAD~1 <--- the chore commit created above
99+
# HEAD~2 <--- the original commit we were supposed to mirror or the tip of master after rebase
100+
git restore --source=HEAD~2 -- $nargo_file
101+
git commit --all --amend -m "$(git log -1 --pretty=%B) [skip ci]"
102+
79103
git push
80104
fi

0 commit comments

Comments
 (0)