From d0059bffefab648e01aac822f5a899e5afbf749b Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 12 Feb 2024 16:47:22 +0000 Subject: [PATCH 01/11] fix: mirror noir pass 3 --- .github/workflows/mirror_noir_subrepo.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mirror_noir_subrepo.yml b/.github/workflows/mirror_noir_subrepo.yml index 2c8174675c5..1dddeace457 100644 --- a/.github/workflows/mirror_noir_subrepo.yml +++ b/.github/workflows/mirror_noir_subrepo.yml @@ -41,9 +41,13 @@ jobs: # Get the last sync PR's last commit state LAST_MERGED_PR_HASH=`gh pr list --repo=noir-lang/noir --state merged --head aztec-packages --json headRefOid --jq=.[0].headRefOid` # Use a commit heuristic where we look at when .gitrepo first started to look at that commit state (through a push) - COMMIT_HEURISTIC=$(git log -p -S"$LAST_MERGED_PR_HASH" --reverse --source -- noir/.gitrepo | grep -m 1 '^commit' | awk '{print $2}' || true) + COMMIT_HEURISTIC=$(git log -p -S"$LAST_MERGED_PR_HASH" --reverse --source -- noir/.gitrepo | grep -m 1 '^commit' | awk '{print $2}' || true) BASE_AZTEC_COMMIT=`git config --file=noir/.gitrepo subrepo.parent` - if [[ "$COMMIT_HEURISTIC" = "" ]] ; then + if [[ " $COMMIT_HEURISTIC" = "" ]] ; then + # If that doesn't work, look for the last 'method = pull' commit + COMMIT_HEURISTIC=$(git log -p -S"method = pull" --reverse --source -- noir/.gitrepo | grep -m 1 '^commit' | awk '{print $2}' || true) + fi + if [[ " $COMMIT_HEURISTIC" = "" ]] ; then # It it fails, just use our gitrepo parent commit (last time we pushed or pulled) COMMIT_HEURISTIC=$BASE_AZTEC_COMMIT fi From 0af61137e1b777cab48655a8a6a5e896c3522637 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 12 Feb 2024 16:48:25 +0000 Subject: [PATCH 02/11] REVERTME: more logic for recovery --- .github/workflows/mirror_noir_subrepo.yml | 160 +++++++++++----------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/.github/workflows/mirror_noir_subrepo.yml b/.github/workflows/mirror_noir_subrepo.yml index 1dddeace457..03b3281b91a 100644 --- a/.github/workflows/mirror_noir_subrepo.yml +++ b/.github/workflows/mirror_noir_subrepo.yml @@ -33,13 +33,13 @@ jobs: # Enable gh executable. We spread out the API requests between the github actions bot token, and aztecbot export GH_TOKEN="${{ secrets.GITHUB_TOKEN }}" # Do we have a PR active? - PR_URL=$(gh pr list --repo noir-lang/noir --head aztec-packages --json url --jq ".[0].url") + PR_URL=$(gh pr list --repo noir-lang/noir --head aztec-sync-test --json url --jq ".[0].url") echo "PR_URL=$PR_URL" >> $GITHUB_ENV # compute_commit_message: Create a filtered git log for release-please changelog / metadata function compute_commit_message() { # Get the last sync PR's last commit state - LAST_MERGED_PR_HASH=`gh pr list --repo=noir-lang/noir --state merged --head aztec-packages --json headRefOid --jq=.[0].headRefOid` + LAST_MERGED_PR_HASH=`gh pr list --repo=noir-lang/noir --state merged --head aztec-sync-test --json headRefOid --jq=.[0].headRefOid` # Use a commit heuristic where we look at when .gitrepo first started to look at that commit state (through a push) COMMIT_HEURISTIC=$(git log -p -S"$LAST_MERGED_PR_HASH" --reverse --source -- noir/.gitrepo | grep -m 1 '^commit' | awk '{print $2}' || true) BASE_AZTEC_COMMIT=`git config --file=noir/.gitrepo subrepo.parent` @@ -54,87 +54,87 @@ jobs: # Create a filtered git log for release-please changelog / metadata RAW_MESSAGE=$(git log --pretty=format:"%s" $COMMIT_HEURISTIC..HEAD -- noir/ ':!noir/.gitrepo' | grep -v 'git subrepo' || true) # Fix Aztec PR links and output message - echo "$RAW_MESSAGE" | sed -E 's/\(#([0-9]+)\)/(https:\/\/github.com\/AztecProtocol\/aztec-packages\/pull\/\1)/g' + echo "$RAW_MESSAGE" | sed -E 's/\(#([0-9]+)\)/(https:\/\/github.com\/AztecProtocol\/aztec-sync-test\/pull\/\1)/g' } echo "$(compute_commit_message)" >> .COMMIT_MESSAGE - # We push using git subrepo (https://github.com/ingydotnet/git-subrepo) - # and push all Aztec commits as a single commit with metadata. - - name: Push to branch - run: | - set -xue # print commands - # Enable gh executable. We spread out the API requests between the github actions bot token, and aztecbot - export GH_TOKEN="${{ secrets.GITHUB_TOKEN }}" - SUBREPO_PATH=noir - BRANCH=aztec-packages - if [[ "$PR_URL" == "" ]]; then - # if no staging branch, we can overwrite - STAGING_BRANCH=$BRANCH - else - # otherwise we first reset our staging branch - STAGING_BRANCH=$BRANCH-staging - fi - # identify ourselves, needed to commit - git config --global user.name AztecBot - git config --global user.email tech@aztecprotocol.com - BASE_NOIR_COMMIT=`git config --file=noir/.gitrepo subrepo.commit` - BASE_AZTEC_COMMIT=`git config --file=noir/.gitrepo subrepo.parent` + # # We push using git subrepo (https://github.com/ingydotnet/git-subrepo) + # # and push all Aztec commits as a single commit with metadata. + # - name: Push to branch + # run: | + # set -xue # print commands + # # Enable gh executable. We spread out the API requests between the github actions bot token, and aztecbot + # export GH_TOKEN="${{ secrets.GITHUB_TOKEN }}" + # SUBREPO_PATH=noir + # BRANCH=aztec-sync-test + # if [[ "$PR_URL" == "" ]]; then + # # if no staging branch, we can overwrite + # STAGING_BRANCH=$BRANCH + # else + # # otherwise we first reset our staging branch + # STAGING_BRANCH=$BRANCH-staging + # fi + # # identify ourselves, needed to commit + # git config --global user.name AztecBot + # git config --global user.email tech@aztecprotocol.com + # BASE_NOIR_COMMIT=`git config --file=noir/.gitrepo subrepo.commit` + # BASE_AZTEC_COMMIT=`git config --file=noir/.gitrepo subrepo.parent` - # clone noir repo for manipulations, we use aztec bot token for writeability - git clone https://x-access-token:${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}@github.com/noir-lang/noir.git noir-repo + # # clone noir repo for manipulations, we use aztec bot token for writeability + # git clone https://x-access-token:${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}@github.com/noir-lang/noir.git noir-repo - # reset_pr: Reset aztec-packages staging. If no PR, this is the PR branch. - function reset_noir_staging_branch() { - cd noir-repo - git checkout $STAGING_BRANCH || git checkout -b $STAGING_BRANCH - git reset --hard "$BASE_NOIR_COMMIT" - # Reset our branch to our expected target - git push origin $STAGING_BRANCH --force - cd .. - } - # force_sync_staging: Push to our aztec-packages staging branch. - function force_sync_staging() { - MESSAGE=$(cat .COMMIT_MESSAGE) - git commit --allow-empty -m"chore: Sync to noir-lang/noir" -m"$MESSAGE" - COMMIT=$(git rev-parse HEAD) - # Now push to it with subrepo with computed commit messages - if ./scripts/git-subrepo/lib/git-subrepo push $SUBREPO_PATH --squash --branch=$STAGING_BRANCH; then - git reset $COMMIT - git commit --allow-empty --amend -am "$(git log -1 --pretty=%B) [skip ci]" - git push - else - echo "Problems syncing noir. We may need to pull the subrepo." - exit 1 - fi - } - # merge_staging_branch: Merge our staging branch into aztec-packages. - function merge_staging_branch() { - # Fix PR branch - cd noir-repo - git fetch # see recent change - git checkout $BRANCH || git checkout -b $BRANCH - git merge -Xtheirs $STAGING_BRANCH - git push origin $BRANCH - cd .. - } - reset_noir_staging_branch - force_sync_staging - if [[ "$PR_URL" != "" ]]; then - merge_staging_branch - fi + # # reset_pr: Reset aztec-sync-test staging. If no PR, this is the PR branch. + # function reset_noir_staging_branch() { + # cd noir-repo + # git checkout $STAGING_BRANCH || git checkout -b $STAGING_BRANCH + # git reset --hard "$BASE_NOIR_COMMIT" + # # Reset our branch to our expected target + # git push origin $STAGING_BRANCH --force + # cd .. + # } + # # force_sync_staging: Push to our aztec-sync-test staging branch. + # function force_sync_staging() { + # MESSAGE=$(cat .COMMIT_MESSAGE) + # git commit --allow-empty -m"chore: Sync to noir-lang/noir" -m"$MESSAGE" + # COMMIT=$(git rev-parse HEAD) + # # Now push to it with subrepo with computed commit messages + # if ./scripts/git-subrepo/lib/git-subrepo push $SUBREPO_PATH --squash --branch=$STAGING_BRANCH; then + # git reset $COMMIT + # git commit --allow-empty --amend -am "$(git log -1 --pretty=%B) [skip ci]" + # git push + # else + # echo "Problems syncing noir. We may need to pull the subrepo." + # exit 1 + # fi + # } + # # merge_staging_branch: Merge our staging branch into aztec-sync-test. + # function merge_staging_branch() { + # # Fix PR branch + # cd noir-repo + # git fetch # see recent change + # git checkout $BRANCH || git checkout -b $BRANCH + # git merge -Xtheirs $STAGING_BRANCH + # git push origin $BRANCH + # cd .. + # } + # reset_noir_staging_branch + # force_sync_staging + # if [[ "$PR_URL" != "" ]]; then + # merge_staging_branch + # fi - - name: Update PR - run: | - set -xue # print commands - MESSAGE=$(cat .COMMIT_MESSAGE) - # Formatted for updating the PR, overrides for release-please commit message parsing - PR_BODY="""BEGIN_COMMIT_OVERRIDE - $MESSAGE - END_COMMIT_OVERRIDE""" - # for cross-opening PR in noir repo, we use aztecbot's token - export GH_TOKEN=${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} - if [[ "$PR_URL" == "" ]]; then - gh pr create --repo noir-lang/noir --title "feat: Sync from aztec-packages" --body "$PR_BODY" --base master --head aztec-packages - else - gh pr edit "$PR_URL" --body "$PR_BODY" - fi + # - name: Update PR + # run: | + # set -xue # print commands + # MESSAGE=$(cat .COMMIT_MESSAGE) + # # Formatted for updating the PR, overrides for release-please commit message parsing + # PR_BODY="""BEGIN_COMMIT_OVERRIDE + # $MESSAGE + # END_COMMIT_OVERRIDE""" + # # for cross-opening PR in noir repo, we use aztecbot's token + # export GH_TOKEN=${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} + # if [[ "$PR_URL" == "" ]]; then + # gh pr create --repo noir-lang/noir --title "feat: Sync from aztec-sync-test" --body "$PR_BODY" --base master --head aztec-sync-test + # else + # gh pr edit "$PR_URL" --body "$PR_BODY" + # fi From faa1503e8ebcf2f32a892037dcf8be985f0156c9 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 12 Feb 2024 16:50:33 +0000 Subject: [PATCH 03/11] Fix --- .github/workflows/mirror_noir_subrepo.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mirror_noir_subrepo.yml b/.github/workflows/mirror_noir_subrepo.yml index 03b3281b91a..f5bae06fd18 100644 --- a/.github/workflows/mirror_noir_subrepo.yml +++ b/.github/workflows/mirror_noir_subrepo.yml @@ -43,11 +43,11 @@ jobs: # Use a commit heuristic where we look at when .gitrepo first started to look at that commit state (through a push) COMMIT_HEURISTIC=$(git log -p -S"$LAST_MERGED_PR_HASH" --reverse --source -- noir/.gitrepo | grep -m 1 '^commit' | awk '{print $2}' || true) BASE_AZTEC_COMMIT=`git config --file=noir/.gitrepo subrepo.parent` - if [[ " $COMMIT_HEURISTIC" = "" ]] ; then + if [[ "$COMMIT_HEURISTIC" = "" ]] ; then # If that doesn't work, look for the last 'method = pull' commit COMMIT_HEURISTIC=$(git log -p -S"method = pull" --reverse --source -- noir/.gitrepo | grep -m 1 '^commit' | awk '{print $2}' || true) fi - if [[ " $COMMIT_HEURISTIC" = "" ]] ; then + if [[ "$COMMIT_HEURISTIC" = "" ]] ; then # It it fails, just use our gitrepo parent commit (last time we pushed or pulled) COMMIT_HEURISTIC=$BASE_AZTEC_COMMIT fi From 5c18dd43b2041a8a0b2e23902a75ed5ec7b12efe Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 12 Feb 2024 16:52:43 +0000 Subject: [PATCH 04/11] dont use reverse for looking for latest pull --- .github/workflows/mirror_noir_subrepo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mirror_noir_subrepo.yml b/.github/workflows/mirror_noir_subrepo.yml index f5bae06fd18..c6311163f24 100644 --- a/.github/workflows/mirror_noir_subrepo.yml +++ b/.github/workflows/mirror_noir_subrepo.yml @@ -45,7 +45,7 @@ jobs: BASE_AZTEC_COMMIT=`git config --file=noir/.gitrepo subrepo.parent` if [[ "$COMMIT_HEURISTIC" = "" ]] ; then # If that doesn't work, look for the last 'method = pull' commit - COMMIT_HEURISTIC=$(git log -p -S"method = pull" --reverse --source -- noir/.gitrepo | grep -m 1 '^commit' | awk '{print $2}' || true) + COMMIT_HEURISTIC=$(git log -p -S"method = pull" --source -- noir/.gitrepo | grep -m 1 '^commit' | awk '{print $2}' || true) fi if [[ "$COMMIT_HEURISTIC" = "" ]] ; then # It it fails, just use our gitrepo parent commit (last time we pushed or pulled) From 32f0023846afb98c456f896a2e487c51ac13dcb4 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 12 Feb 2024 17:23:48 +0000 Subject: [PATCH 05/11] alt automation --- .github/workflows/mirror_noir_subrepo.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/mirror_noir_subrepo.yml b/.github/workflows/mirror_noir_subrepo.yml index c6311163f24..85c1360aa99 100644 --- a/.github/workflows/mirror_noir_subrepo.yml +++ b/.github/workflows/mirror_noir_subrepo.yml @@ -41,12 +41,15 @@ jobs: # Get the last sync PR's last commit state LAST_MERGED_PR_HASH=`gh pr list --repo=noir-lang/noir --state merged --head aztec-sync-test --json headRefOid --jq=.[0].headRefOid` # Use a commit heuristic where we look at when .gitrepo first started to look at that commit state (through a push) - COMMIT_HEURISTIC=$(git log -p -S"$LAST_MERGED_PR_HASH" --reverse --source -- noir/.gitrepo | grep -m 1 '^commit' | awk '{print $2}' || true) - BASE_AZTEC_COMMIT=`git config --file=noir/.gitrepo subrepo.parent` - if [[ "$COMMIT_HEURISTIC" = "" ]] ; then - # If that doesn't work, look for the last 'method = pull' commit - COMMIT_HEURISTIC=$(git log -p -S"method = pull" --source -- noir/.gitrepo | grep -m 1 '^commit' | awk '{print $2}' || true) - fi + for i in {0..10}; do + # Search backwards for 10 commits in case some commits got in the last PR without syncing to aztec + HASH=`git rev-parse $LAST_MERGED_PR_HASH~$i` + COMMIT_HEURISTIC=$(git log -p -S"$HASH" --reverse --source -- noir/.gitrepo | grep -m 1 '^commit' | awk '{print $2}' || true) + BASE_AZTEC_COMMIT=`git config --file=noir/.gitrepo subrepo.parent` + if [[ "$COMMIT_HEURISTIC" != "" ]] ; then + break + fi + done if [[ "$COMMIT_HEURISTIC" = "" ]] ; then # It it fails, just use our gitrepo parent commit (last time we pushed or pulled) COMMIT_HEURISTIC=$BASE_AZTEC_COMMIT From 5d442421ae075d8d9ae555b30053a9c1b9ea4079 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 12 Feb 2024 17:29:26 +0000 Subject: [PATCH 06/11] alt automation --- .github/workflows/mirror_noir_subrepo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mirror_noir_subrepo.yml b/.github/workflows/mirror_noir_subrepo.yml index 85c1360aa99..080f22b9627 100644 --- a/.github/workflows/mirror_noir_subrepo.yml +++ b/.github/workflows/mirror_noir_subrepo.yml @@ -39,7 +39,7 @@ jobs: # compute_commit_message: Create a filtered git log for release-please changelog / metadata function compute_commit_message() { # Get the last sync PR's last commit state - LAST_MERGED_PR_HASH=`gh pr list --repo=noir-lang/noir --state merged --head aztec-sync-test --json headRefOid --jq=.[0].headRefOid` + LAST_MERGED_PR_HASH=`gh pr list --repo=noir-lang/noir --state merged --head aztec-packages --json headRefOid --jq=.[0].headRefOid` # Use a commit heuristic where we look at when .gitrepo first started to look at that commit state (through a push) for i in {0..10}; do # Search backwards for 10 commits in case some commits got in the last PR without syncing to aztec From e0cb2142b8faadcb0c5f6f10a8c845c48a074c17 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 12 Feb 2024 17:40:19 +0000 Subject: [PATCH 07/11] foolish optimism --- .github/workflows/mirror_noir_subrepo.yml | 160 +++++++++++----------- 1 file changed, 81 insertions(+), 79 deletions(-) diff --git a/.github/workflows/mirror_noir_subrepo.yml b/.github/workflows/mirror_noir_subrepo.yml index 080f22b9627..b0985aca242 100644 --- a/.github/workflows/mirror_noir_subrepo.yml +++ b/.github/workflows/mirror_noir_subrepo.yml @@ -27,6 +27,11 @@ jobs: fetch-depth: 0 token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} + - name: Clone noir: + run: | + # clone noir repo for manipulations, we use aztec bot token for writeability + git clone https://x-access-token:${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}@github.com/noir-lang/noir.git noir-repo + - name: Setup env run: | set -xue # print commands @@ -43,7 +48,7 @@ jobs: # Use a commit heuristic where we look at when .gitrepo first started to look at that commit state (through a push) for i in {0..10}; do # Search backwards for 10 commits in case some commits got in the last PR without syncing to aztec - HASH=`git rev-parse $LAST_MERGED_PR_HASH~$i` + HASH=`cd noir && git rev-parse $LAST_MERGED_PR_HASH~$i` COMMIT_HEURISTIC=$(git log -p -S"$HASH" --reverse --source -- noir/.gitrepo | grep -m 1 '^commit' | awk '{print $2}' || true) BASE_AZTEC_COMMIT=`git config --file=noir/.gitrepo subrepo.parent` if [[ "$COMMIT_HEURISTIC" != "" ]] ; then @@ -61,83 +66,80 @@ jobs: } echo "$(compute_commit_message)" >> .COMMIT_MESSAGE - # # We push using git subrepo (https://github.com/ingydotnet/git-subrepo) - # # and push all Aztec commits as a single commit with metadata. - # - name: Push to branch - # run: | - # set -xue # print commands - # # Enable gh executable. We spread out the API requests between the github actions bot token, and aztecbot - # export GH_TOKEN="${{ secrets.GITHUB_TOKEN }}" - # SUBREPO_PATH=noir - # BRANCH=aztec-sync-test - # if [[ "$PR_URL" == "" ]]; then - # # if no staging branch, we can overwrite - # STAGING_BRANCH=$BRANCH - # else - # # otherwise we first reset our staging branch - # STAGING_BRANCH=$BRANCH-staging - # fi - # # identify ourselves, needed to commit - # git config --global user.name AztecBot - # git config --global user.email tech@aztecprotocol.com - # BASE_NOIR_COMMIT=`git config --file=noir/.gitrepo subrepo.commit` - # BASE_AZTEC_COMMIT=`git config --file=noir/.gitrepo subrepo.parent` - - # # clone noir repo for manipulations, we use aztec bot token for writeability - # git clone https://x-access-token:${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}@github.com/noir-lang/noir.git noir-repo + # We push using git subrepo (https://github.com/ingydotnet/git-subrepo) + # and push all Aztec commits as a single commit with metadata. + - name: Push to branch + run: | + set -xue # print commands + # Enable gh executable. We spread out the API requests between the github actions bot token, and aztecbot + export GH_TOKEN="${{ secrets.GITHUB_TOKEN }}" + SUBREPO_PATH=noir + BRANCH=aztec-sync-test + if [[ "$PR_URL" == "" ]]; then + # if no staging branch, we can overwrite + STAGING_BRANCH=$BRANCH + else + # otherwise we first reset our staging branch + STAGING_BRANCH=$BRANCH-staging + fi + # identify ourselves, needed to commit + git config --global user.name AztecBot + git config --global user.email tech@aztecprotocol.com + BASE_NOIR_COMMIT=`git config --file=noir/.gitrepo subrepo.commit` + BASE_AZTEC_COMMIT=`git config --file=noir/.gitrepo subrepo.parent` - # # reset_pr: Reset aztec-sync-test staging. If no PR, this is the PR branch. - # function reset_noir_staging_branch() { - # cd noir-repo - # git checkout $STAGING_BRANCH || git checkout -b $STAGING_BRANCH - # git reset --hard "$BASE_NOIR_COMMIT" - # # Reset our branch to our expected target - # git push origin $STAGING_BRANCH --force - # cd .. - # } - # # force_sync_staging: Push to our aztec-sync-test staging branch. - # function force_sync_staging() { - # MESSAGE=$(cat .COMMIT_MESSAGE) - # git commit --allow-empty -m"chore: Sync to noir-lang/noir" -m"$MESSAGE" - # COMMIT=$(git rev-parse HEAD) - # # Now push to it with subrepo with computed commit messages - # if ./scripts/git-subrepo/lib/git-subrepo push $SUBREPO_PATH --squash --branch=$STAGING_BRANCH; then - # git reset $COMMIT - # git commit --allow-empty --amend -am "$(git log -1 --pretty=%B) [skip ci]" - # git push - # else - # echo "Problems syncing noir. We may need to pull the subrepo." - # exit 1 - # fi - # } - # # merge_staging_branch: Merge our staging branch into aztec-sync-test. - # function merge_staging_branch() { - # # Fix PR branch - # cd noir-repo - # git fetch # see recent change - # git checkout $BRANCH || git checkout -b $BRANCH - # git merge -Xtheirs $STAGING_BRANCH - # git push origin $BRANCH - # cd .. - # } - # reset_noir_staging_branch - # force_sync_staging - # if [[ "$PR_URL" != "" ]]; then - # merge_staging_branch - # fi + # reset_pr: Reset aztec-sync-test staging. If no PR, this is the PR branch. + function reset_noir_staging_branch() { + cd noir-repo + git checkout $STAGING_BRANCH || git checkout -b $STAGING_BRANCH + git reset --hard "$BASE_NOIR_COMMIT" + # Reset our branch to our expected target + git push origin $STAGING_BRANCH --force + cd .. + } + # force_sync_staging: Push to our aztec-sync-test staging branch. + function force_sync_staging() { + MESSAGE=$(cat .COMMIT_MESSAGE) + git commit --allow-empty -m"chore: Sync to noir-lang/noir" -m"$MESSAGE" + COMMIT=$(git rev-parse HEAD) + # Now push to it with subrepo with computed commit messages + if ./scripts/git-subrepo/lib/git-subrepo push $SUBREPO_PATH --squash --branch=$STAGING_BRANCH; then + git reset $COMMIT + git commit --allow-empty --amend -am "$(git log -1 --pretty=%B) [skip ci]" + git push + else + echo "Problems syncing noir. We may need to pull the subrepo." + exit 1 + fi + } + # merge_staging_branch: Merge our staging branch into aztec-sync-test. + function merge_staging_branch() { + # Fix PR branch + cd noir-repo + git fetch # see recent change + git checkout $BRANCH || git checkout -b $BRANCH + git merge -Xtheirs $STAGING_BRANCH + git push origin $BRANCH + cd .. + } + reset_noir_staging_branch + force_sync_staging + if [[ "$PR_URL" != "" ]]; then + merge_staging_branch + fi - # - name: Update PR - # run: | - # set -xue # print commands - # MESSAGE=$(cat .COMMIT_MESSAGE) - # # Formatted for updating the PR, overrides for release-please commit message parsing - # PR_BODY="""BEGIN_COMMIT_OVERRIDE - # $MESSAGE - # END_COMMIT_OVERRIDE""" - # # for cross-opening PR in noir repo, we use aztecbot's token - # export GH_TOKEN=${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} - # if [[ "$PR_URL" == "" ]]; then - # gh pr create --repo noir-lang/noir --title "feat: Sync from aztec-sync-test" --body "$PR_BODY" --base master --head aztec-sync-test - # else - # gh pr edit "$PR_URL" --body "$PR_BODY" - # fi + - name: Update PR + run: | + set -xue # print commands + MESSAGE=$(cat .COMMIT_MESSAGE) + # Formatted for updating the PR, overrides for release-please commit message parsing + PR_BODY="""BEGIN_COMMIT_OVERRIDE + $MESSAGE + END_COMMIT_OVERRIDE""" + # for cross-opening PR in noir repo, we use aztecbot's token + export GH_TOKEN=${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} + if [[ "$PR_URL" == "" ]]; then + gh pr create --repo noir-lang/noir --title "feat: Sync from aztec-sync-test" --body "$PR_BODY" --base master --head aztec-sync-test + else + gh pr edit "$PR_URL" --body "$PR_BODY" + fi From d96d36844f813ea144f170a0669688005182527b Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 12 Feb 2024 17:43:33 +0000 Subject: [PATCH 08/11] foolish optimism --- .github/workflows/mirror_noir_subrepo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mirror_noir_subrepo.yml b/.github/workflows/mirror_noir_subrepo.yml index b0985aca242..1958a9ba1c7 100644 --- a/.github/workflows/mirror_noir_subrepo.yml +++ b/.github/workflows/mirror_noir_subrepo.yml @@ -27,7 +27,7 @@ jobs: fetch-depth: 0 token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} - - name: Clone noir: + - name: Clone noir run: | # clone noir repo for manipulations, we use aztec bot token for writeability git clone https://x-access-token:${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}@github.com/noir-lang/noir.git noir-repo From 0ea858b006250e4dbeb8298d2ce138a72dfa42e5 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 12 Feb 2024 18:04:20 +0000 Subject: [PATCH 09/11] test sync --- .github/workflows/mirror_noir_subrepo.yml | 36 ++++++++--------------- noir/.gitrepo | 2 +- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/.github/workflows/mirror_noir_subrepo.yml b/.github/workflows/mirror_noir_subrepo.yml index 1958a9ba1c7..3c292ac4ffd 100644 --- a/.github/workflows/mirror_noir_subrepo.yml +++ b/.github/workflows/mirror_noir_subrepo.yml @@ -27,18 +27,13 @@ jobs: fetch-depth: 0 token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} - - name: Clone noir - run: | - # clone noir repo for manipulations, we use aztec bot token for writeability - git clone https://x-access-token:${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}@github.com/noir-lang/noir.git noir-repo - - name: Setup env run: | set -xue # print commands # Enable gh executable. We spread out the API requests between the github actions bot token, and aztecbot export GH_TOKEN="${{ secrets.GITHUB_TOKEN }}" # Do we have a PR active? - PR_URL=$(gh pr list --repo noir-lang/noir --head aztec-sync-test --json url --jq ".[0].url") + PR_URL=$(gh pr list --repo noir-lang/noir --head aztec-packages --json url --jq ".[0].url") echo "PR_URL=$PR_URL" >> $GITHUB_ENV # compute_commit_message: Create a filtered git log for release-please changelog / metadata @@ -46,15 +41,8 @@ jobs: # Get the last sync PR's last commit state LAST_MERGED_PR_HASH=`gh pr list --repo=noir-lang/noir --state merged --head aztec-packages --json headRefOid --jq=.[0].headRefOid` # Use a commit heuristic where we look at when .gitrepo first started to look at that commit state (through a push) - for i in {0..10}; do - # Search backwards for 10 commits in case some commits got in the last PR without syncing to aztec - HASH=`cd noir && git rev-parse $LAST_MERGED_PR_HASH~$i` - COMMIT_HEURISTIC=$(git log -p -S"$HASH" --reverse --source -- noir/.gitrepo | grep -m 1 '^commit' | awk '{print $2}' || true) - BASE_AZTEC_COMMIT=`git config --file=noir/.gitrepo subrepo.parent` - if [[ "$COMMIT_HEURISTIC" != "" ]] ; then - break - fi - done + COMMIT_HEURISTIC=$(git log -p -S"$LAST_MERGED_PR_HASH" --reverse --source -- noir/.gitrepo | grep -m 1 '^commit' | awk '{print $2}' || true) + BASE_AZTEC_COMMIT=`git config --file=noir/.gitrepo subrepo.parent` if [[ "$COMMIT_HEURISTIC" = "" ]] ; then # It it fails, just use our gitrepo parent commit (last time we pushed or pulled) COMMIT_HEURISTIC=$BASE_AZTEC_COMMIT @@ -62,7 +50,7 @@ jobs: # Create a filtered git log for release-please changelog / metadata RAW_MESSAGE=$(git log --pretty=format:"%s" $COMMIT_HEURISTIC..HEAD -- noir/ ':!noir/.gitrepo' | grep -v 'git subrepo' || true) # Fix Aztec PR links and output message - echo "$RAW_MESSAGE" | sed -E 's/\(#([0-9]+)\)/(https:\/\/github.com\/AztecProtocol\/aztec-sync-test\/pull\/\1)/g' + echo "$RAW_MESSAGE" | sed -E 's/\(#([0-9]+)\)/(https:\/\/github.com\/AztecProtocol\/aztec-packages\/pull\/\1)/g' } echo "$(compute_commit_message)" >> .COMMIT_MESSAGE @@ -74,7 +62,7 @@ jobs: # Enable gh executable. We spread out the API requests between the github actions bot token, and aztecbot export GH_TOKEN="${{ secrets.GITHUB_TOKEN }}" SUBREPO_PATH=noir - BRANCH=aztec-sync-test + BRANCH=aztec-packages if [[ "$PR_URL" == "" ]]; then # if no staging branch, we can overwrite STAGING_BRANCH=$BRANCH @@ -88,7 +76,10 @@ jobs: BASE_NOIR_COMMIT=`git config --file=noir/.gitrepo subrepo.commit` BASE_AZTEC_COMMIT=`git config --file=noir/.gitrepo subrepo.parent` - # reset_pr: Reset aztec-sync-test staging. If no PR, this is the PR branch. + # clone noir repo for manipulations, we use aztec bot token for writeability + git clone https://x-access-token:${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}@github.com/noir-lang/noir.git noir-repo + + # reset_pr: Reset aztec-packages staging. If no PR, this is the PR branch. function reset_noir_staging_branch() { cd noir-repo git checkout $STAGING_BRANCH || git checkout -b $STAGING_BRANCH @@ -97,22 +88,21 @@ jobs: git push origin $STAGING_BRANCH --force cd .. } - # force_sync_staging: Push to our aztec-sync-test staging branch. + # force_sync_staging: Push to our aztec-packages staging branch. function force_sync_staging() { MESSAGE=$(cat .COMMIT_MESSAGE) git commit --allow-empty -m"chore: Sync to noir-lang/noir" -m"$MESSAGE" COMMIT=$(git rev-parse HEAD) # Now push to it with subrepo with computed commit messages if ./scripts/git-subrepo/lib/git-subrepo push $SUBREPO_PATH --squash --branch=$STAGING_BRANCH; then + # We don't push a commit to aztec anymore so that we can maintain the 'commit' as our last pull branch git reset $COMMIT - git commit --allow-empty --amend -am "$(git log -1 --pretty=%B) [skip ci]" - git push else echo "Problems syncing noir. We may need to pull the subrepo." exit 1 fi } - # merge_staging_branch: Merge our staging branch into aztec-sync-test. + # merge_staging_branch: Merge our staging branch into aztec-packages. function merge_staging_branch() { # Fix PR branch cd noir-repo @@ -139,7 +129,7 @@ jobs: # for cross-opening PR in noir repo, we use aztecbot's token export GH_TOKEN=${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} if [[ "$PR_URL" == "" ]]; then - gh pr create --repo noir-lang/noir --title "feat: Sync from aztec-sync-test" --body "$PR_BODY" --base master --head aztec-sync-test + gh pr create --repo noir-lang/noir --title "feat: Sync from aztec-packages" --body "$PR_BODY" --base master --head aztec-packages else gh pr edit "$PR_URL" --body "$PR_BODY" fi diff --git a/noir/.gitrepo b/noir/.gitrepo index 2274fa26d93..8d5ef1404cc 100644 --- a/noir/.gitrepo +++ b/noir/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/noir-lang/noir branch = aztec-packages - commit = 5f5843e35052b9d3599b8ab4f7633db0a225e82f + commit = 6ff518af281afe601edb8574d425b07d9d2f9c5d parent = e5ca533ea4513cf3c6b7e3eb057083838b861a6b method = merge cmdver = 0.4.6 From e0bc3853e6010c50bbe2fb914e0cdb783714055d Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 12 Feb 2024 18:07:19 +0000 Subject: [PATCH 10/11] test sync --- noir/.gitrepo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noir/.gitrepo b/noir/.gitrepo index 8d5ef1404cc..f8b66efc119 100644 --- a/noir/.gitrepo +++ b/noir/.gitrepo @@ -7,6 +7,6 @@ remote = https://github.com/noir-lang/noir branch = aztec-packages commit = 6ff518af281afe601edb8574d425b07d9d2f9c5d - parent = e5ca533ea4513cf3c6b7e3eb057083838b861a6b + parent = 2082fedfb03d4882a269881f51c5337263bc539b method = merge cmdver = 0.4.6 From 94b2aff3253d141d293c7f1904a6cd7b9cceafd5 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 12 Feb 2024 18:14:17 +0000 Subject: [PATCH 11/11] Try merge staging branch --- .github/workflows/mirror_noir_subrepo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mirror_noir_subrepo.yml b/.github/workflows/mirror_noir_subrepo.yml index 3c292ac4ffd..165f3133f53 100644 --- a/.github/workflows/mirror_noir_subrepo.yml +++ b/.github/workflows/mirror_noir_subrepo.yml @@ -108,7 +108,7 @@ jobs: cd noir-repo git fetch # see recent change git checkout $BRANCH || git checkout -b $BRANCH - git merge -Xtheirs $STAGING_BRANCH + git merge -Xtheirs origin/$STAGING_BRANCH git push origin $BRANCH cd .. }