Skip to content

Commit

Permalink
Lets try noir sync
Browse files Browse the repository at this point in the history
  • Loading branch information
ludamad0 committed Feb 5, 2024
1 parent def3f13 commit 1b705f3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 140 deletions.
93 changes: 35 additions & 58 deletions .github/workflows/mirror_noir_subrepo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,92 +6,69 @@ name: Mirror to noir repo
# Don't allow multiple of these running at once:
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
on:
push:
branches:
- master
paths:
- 'noir/**'
- '!noir/.gitrepo'
- ad/chore/better-noir-sync
# paths:
# - 'noir/**'
# - '!noir/.gitrepo'

jobs:
mirror_repo:
runs-on: ubuntu-latest

steps:
- name: Get commit hash of last aztec-packages squash-merge
id: last_merge_hash
uses: actions/github-script@v5
with:
script: |
// TODO more robust heuristic if aztecbot does other things in noir
const response = await github.rest.search.commits({
q: 'author:AztecBot repo:noir-lang/noir branch:master',
order: 'asc'
});
return response.data.items[0].commit.tree.sha;
- name: Check for open PRs on noir-lang/noir
id: sync_pr_exists
uses: actions/github-script@v6
with:
github-token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
script: |
const { data: pullRequests } = await github.rest.pulls.list({
owner: 'noir-lang',
repo: 'noir',
state: 'open',
head: 'aztec-packages'
});
return pullRequests.length > 0;
- name: Checkout noir repo
- name: Checkout
uses: actions/checkout@v3
if: steps.sync_pr_exists.outputs.result == 'false'
with:
fetch-depth: 0
repository: noir-lang/noir
token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
- name: Reset noir-lang/noir branch if no PRs
uses: actions/checkout@v3
if: steps.sync_pr_exists.outputs.result == 'false'
run: |
git checkout aztec-packages
git reset --hard ${{steps.last_merge_hash.outputs.result}}
git push origin aztec-packages --force

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

# 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
SUBREPO_PATH=noir
BRANCH=aztec-packages
BRANCH=aztec2-packages
# identify ourselves, needed to commit
git config --global user.name AztecBot
git config --global user.email [email protected]
git config --file=noir/.gitrepo subrepo.commit abcdef
if ./scripts/git_subrepo.sh push $SUBREPO_PATH --branch=$BRANCH; then
BASE_NOIR_COMMIT=`git config --file=noir/.gitrepo subrepo.commit`
BASE_AZTEC_COMMIT=`git config --file=noir/.gitrepo subrepo.parent`
# Fix PR branch
git clone https://x-access-token:${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}@github.com/noir-lang/noir.git noir-repo
cd noir-repo
git checkout $BRANCH || git checkout -b $BRANCH
git reset --hard "$BASE_NOIR_COMMIT"
# Reset our branch to our expected target
git push origin $BRANCH --force
cd ..
# Now push to it with subrepo with all non-noise commit messages
MESSAGE=$(git log --pretty=format:"%s" $BASE_AZTEC_COMMIT..HEAD -- noir/ ':!noir/.gitrepo' | grep -v 'git subrepo || true')
git commit --allow-empty -m"chore: Sync to noir-lang/noir" -m"$MESSAGE"
COMMIT=$(git rev-parse HEAD)
if ./scripts/git_subrepo.sh push $SUBREPO_PATH --squash --branch=$BRANCH; then
git reset $COMMIT
git commit --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
- name: Create PR for Aztec Branch
if: steps.sync_pr_exists.outputs.result == 'false'
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'
# Formatted for updating the PR, overrides for release-please commit message parsing
PR_BODY="BEGIN_COMMIT_OVERRIDE\n$MESSAGE\nEND_COMMIT_OVERRIDE"
PR_URL=$(gh pr list --head aztec2-packages --json url --jq ".[0].url")
if [[ "$PR_URL" == "" ]]; then
gh pr create --title "feat: Sync from aztec-packages" --body "$PR_BODY" --base master --head aztec2-packages
else
gh pr edit "$PR_URL" --body "$PR_BODY"
fi
82 changes: 0 additions & 82 deletions .github/workflows/test_action.yml

This file was deleted.

0 comments on commit 1b705f3

Please sign in to comment.