Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactor pg #4477

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
137 changes: 111 additions & 26 deletions .github/workflows/mirror_noir_subrepo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ 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
Expand All @@ -19,45 +21,128 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Get noir master's last sync commit
id: last_merge_hash
uses: actions/github-script@v7
with:
script: |
// NOTE: more robust heuristic needed if aztecbot opens different kinds of PRs
const response = await github.rest.search.commits({
q: 'author:AztecBot committer:web-flow repo:noir-lang/noir sort:committer-date'
});
console.log(response.data.items);
return response.data.items[0].sha;

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}


- 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-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
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`
# 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)
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
# 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 "$(compute_commit_message)" >> .COMMIT_MESSAGE

# We push using git subrepo (https://github.com/ingydotnet/git-subrepo)
# with some logic to recover from squashed parent commits
# We push to subrepo, commit to master. The commit is needed
# to continue to replay. If we still hit issues such as this
# action failing due to upstream changes, a manual resolution
# PR with ./scripts/git_subrepo.sh pull will be needed.
# 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 [email protected]
if ./scripts/git_subrepo.sh push $SUBREPO_PATH --branch=$BRANCH; then
git commit --amend -m "$(git log -1 --pretty=%B) [skip ci]"
git push
else
echo "Problems syncing noir. We may need to pull the subrepo."
exit 1
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

# 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

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
repository: noir-lang/noir
token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
- name: Create PR for Aztec Branch
continue-on-error: true
uses: repo-sync/pull-request@v2
with:
github_token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
pr_title: 'feat: Sync commits from `aztec-packages`'
pr_body: 'Development from [aztec-packages](https://github.com/AztecProtocol/aztec-packages).'
destination_branch: 'master'
source_branch: 'aztec-packages'
- 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
2 changes: 0 additions & 2 deletions .github/workflows/protocol-circuits-gate-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ inputs.tag || env.GITHUB_REF }}

- name: Install bleeding edge cmake
run: |
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/publish-bb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,15 @@ jobs:
ref: ${{ inputs.tag || env.GITHUB_REF }}

- name: Create Mac Build Environment
run: brew install cmake ninja
run: brew install cmake ninja llvm@16

- name: Compile Barretenberg
working-directory: barretenberg/cpp
run: |
cmake --preset default -DCMAKE_BUILD_TYPE=RelWithAssert
export PATH="/usr/local/opt/llvm@16/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/llvm@16/lib"
export CPPFLAGS="-I/usr/local/opt/llvm@16/include"
cmake -DCMAKE_BUILD_TYPE=RelWithAssert --preset default
cmake --build --preset default --target bb

- name: Package barretenberg artifact
Expand Down
6 changes: 3 additions & 3 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
".": "0.21.0",
"barretenberg": "0.21.0",
"barretenberg/ts": "0.21.0"
".": "0.23.0",
"barretenberg": "0.23.0",
"barretenberg/ts": "0.23.0"
}
Loading