Skip to content

feat: Brillig pointer codegen and execution (#5737) #10

feat: Brillig pointer codegen and execution (#5737)

feat: Brillig pointer codegen and execution (#5737) #10

# Mirror a special 'aztec' branch on noir any changes that have accumulated in aztec.
# Might fail if we have pushed changes to noir that we don't expect - in which case we need an explicit pull PR.
# See the last example of such a PR for instructions.
name: Mirror to noir repo
# Don't allow multiple of these running at once:
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
on:
workflow_dispatch: {}
push:
branches:
- master
paths:
- "noir/noir-repo/**"
- "!noir/noir-repo/.gitrepo"
jobs:
mirror_repo:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
- name: Check for existing PR
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-packages --json url --jq ".[0].url")
echo "PR_URL=$PR_URL" >> $GITHUB_ENV
# What was our last merge?
LAST_PR_MERGE=`gh pr list --repo=noir-lang/noir --state merged --head aztec-packages --json mergeCommit --jq=.[0].mergeCommit.oid`
echo "LAST_PR_MERGE=$LAST_PR_MERGE" >> $GITHUB_ENV
- name: Generate PR body
run: |
set -xue # print commands
# compute_commit_message: Create a filtered git log for release-please changelog / metadata
function compute_commit_message() {
# Detect our last sync commit (written by this action before pushing) with a fallback for the first time we ever do this
AZTEC_SYNC_COMMIT=$(curl https://raw.githubusercontent.com/noir-lang/noir/master/.aztec-sync-commit)
if [ "$AZTEC_SYNC_COMMIT" = "404: Not Found" ] ; then
AZTEC_SYNC_COMMIT="a7889f8d21684099306b72a87e0fb57b3bba0cb4"
fi
# Create a filtered git log for release-please changelog / metadata
RAW_MESSAGE=$(git log --pretty=format:"%s" $AZTEC_SYNC_COMMIT..HEAD -- noir/noir-repo/ ':!noir/noir-repo/.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 "$(compute_commit_message)" >> .PR_BODY_MESSAGE
- name: Set git configure for commits
run: |
# identify ourselves, needed to commit
git config --global user.name AztecBot
git config --global user.email tech@aztecprotocol.com
# 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
SUBREPO_PATH=noir/noir-repo
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
BASE_NOIR_COMMIT="$LAST_PR_MERGE"
COMMIT=$(git rev-parse HEAD)
COMMIT_MESSAGE=$(git log -1 --pretty=format:%B)
# Fix Aztec PR links and output message
COMMIT_MESSAGE=$(echo "$COMMIT_MESSAGE" | sed -E 's/\(#([0-9]+)\)/(https:\/\/github.com\/AztecProtocol\/aztec-packages\/pull\/\1)/g')
# 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_noir_staging_branch: 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() {
echo "$COMMIT" > $SUBREPO_PATH/.aztec-sync-commit && git add $SUBREPO_PATH/.aztec-sync-commit
# force gitrepo to point to the right HEAD (we ignore .gitrepo contents otherwise)
git config --file="$SUBREPO_PATH/.gitrepo" subrepo.commit "$BASE_NOIR_COMMIT"
# make a new commit with our previous message
git commit -am "$COMMIT_MESSAGE"
# 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"
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 origin/$STAGING_BRANCH -m "$COMMIT_MESSAGE"
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
# Formatted for updating the PR, overrides for release-please commit message parsing
PR_BODY="""
Automated pull of Noir development from [aztec-packages](https://github.com/AztecProtocol/aztec-packages).
BEGIN_COMMIT_OVERRIDE
$(cat .PR_BODY_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
echo "Updating existing PR."
gh pr edit "$PR_URL" --body "$PR_BODY"
fi