Pull from noir repo #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a pull request from current Noir nightly. | |
name: Pull from noir repo | |
# Don't allow multiple of these running at once: | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: false | |
on: | |
schedule: | |
# Run every morning at 8 AM UTC | |
- cron: "0 8 * * *" | |
workflow_dispatch: | |
inputs: | |
ref: | |
description: 'The git reference to update to' | |
required: false | |
type: string | |
jobs: | |
mirror_repo: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} | |
- name: Enable Corepack | |
run: corepack enable | |
# Determine if there is already a PR to overwrite, and the current plus latest tags. | |
- 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 AztecProtocol/aztec-packages --head bump-noir --json url --jq ".[0].url") | |
echo "PR_URL=$PR_URL" >> $GITHUB_ENV | |
# Get the current Noir target | |
CURRENT_NOIR_REF=$(noir/scripts/sync.sh read-noir-repo-ref) | |
echo "CURRENT_NOIR_REF=$CURRENT_NOIR_REF" >> $GITHUB_ENV | |
# Get the latest nightly tag we can point to in Noir | |
if [[ "${{ github.event.inputs.ref }}" != "" ]]; then | |
LATEST_NOIR_NIGHTLY="${{ github.event.inputs.ref }}" | |
else | |
LATEST_NOIR_NIGHTLY=$(noir/scripts/sync.sh latest-nightly) | |
fi | |
echo "LATEST_NOIR_NIGHTLY=$LATEST_NOIR_NIGHTLY" >> $GITHUB_ENV | |
# Set PR body to be the concatenation of every message that happened in Noir since the last sync. | |
- name: Generate PR body | |
run: | | |
# clone noir repo for manipulations, we use aztec bot token for write-ability | |
git clone https://x-access-token:${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}@github.com/noir-lang/noir.git noir-repo | |
set -xue # print commands | |
# compute_commit_message: Create a filtered git log for release-please changelog / metadata | |
function compute_commit_message() { | |
cd noir-repo | |
# Create a filtered git log for release-please changelog / metadata | |
RAW_MESSAGE=$(git log --pretty=format:"%s" $CURRENT_NOIR_REF..$LATEST_NOIR_NIGHTLY || true) | |
# Fix Noir PR links and output message | |
echo "$RAW_MESSAGE" | sed -E 's/\(#([0-9]+)\)/(https:\/\/github.com\/noir-lang\/noir\/pull\/\1)/g' | |
cd .. | |
} | |
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 [email protected] | |
# Push a commit to the `bump-noir` branch that overrides the Noir ref. | |
- name: Push to branch | |
run: | | |
set -xue # print commands | |
BRANCH=bump-noir | |
cd noir | |
./bootstrap.sh bump-noir-repo-ref $BRANCH $LATEST_NOIR_NIGHTLY | |
# Update the PR from `bump-noir` to `master` with the latest message body. | |
- name: Update PR | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
run: | | |
set -xue # print commands | |
# Formatted for updating the PR, overrides for release-please commit message parsing | |
PR_BODY=""" | |
Automated pull of nightly from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. | |
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 AztecProtocol/aztec-packages --title "chore: Bump Noir reference" --body "$PR_BODY" --base $BRANCH_NAME --head bump-noir | |
else | |
echo "Updating existing PR." | |
gh pr edit "$PR_URL" --body "$PR_BODY" | |
fi |