Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
ludamad0 committed Feb 5, 2024
1 parent d1e5d64 commit ec8bb70
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 1 deletion.
14 changes: 13 additions & 1 deletion .github/workflows/mirror_noir_subrepo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,24 @@ 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 }}

# 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
Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/test_action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Find Recent Closed PR

on:
push:
branches: [ ad/chore/better-noir-sync ]

jobs:
find-pr:
runs-on: ubuntu-latest

steps:
- name: Get commit hash of last aztec2-packages squash-merge
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: Check for open PRs on noir-lang/noir
id: sync_pr_exists
uses: actions/github-script@v7
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: 'noir-lang:aztec2-packages',
per_page: 1
});
console.log({pullRequests})
return pullRequests.length > 0;
- name: Checkout noir repo
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
if: steps.sync_pr_exists.outputs.result == 'false'
run: |
set -x # print commands
git checkout aztec2-packages || git checkout -b aztec2-packages
git reset --hard ${{ steps.last_merge_hash.outputs.result }}
git push origin aztec2-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.
- name: Push to branch
run: |
SUBREPO_PATH=noir
BRANCH=aztec2-packages
# identify ourselves, needed to commit
git config --global user.name AztecBot
git config --global user.email [email protected]
if [ ${{steps.sync_pr_exists.outputs.result}} = "false" ] ; then
echo "Resetting noir push base to PR base as we have a new PR."
git config --file=noir/.gitrepo subrepo.commit ${{steps.last_merge_hash.outputs.result}}
fi
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
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 `aztec2-packages`'
# pr_body: 'Development from [aztec2-packages](https://github.com/AztecProtocol/aztec2-packages).'
# destination_branch: 'master'
# source_branch: 'aztec2-packages'

0 comments on commit ec8bb70

Please sign in to comment.