Skip to content

Update openvm patches #94

Update openvm patches

Update openvm patches #94

name: "Update openvm patches"
on:
workflow_dispatch:
inputs:
STARK_BACKEND_REV:
description: "Optional ref for openvm-stark-backend (defaults to main head)"
required: false
OPENVM_REV:
description: "Optional ref for openvm (defaults to main head)"
required: false
run_benchmark:
description: "Run reth benchmark after patching"
type: boolean
required: false
default: false
benchmark_mode:
description: "Benchmark mode (if running benchmark)"
type: choice
required: false
options:
- execute
- prove
- prove-e2e
default: prove-e2e
schedule:
- cron: "0 */12 * * *" # Run every 12 hours
jobs:
update-config:
name: "Update .cargo/config.toml and open a pull request"
runs-on:
["runs-on", "runner=2cpu-linux-arm64", "run-id=${{ github.run_id }}"]
outputs:
branch_name: ${{ steps.create-branch.outputs.branch_name }}
pr_number: ${{ steps.create-pr.outputs.pr_number }}
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Get default STARK_BACKEND_REV from main (if none provided)
id: get-stark-backend-rev
uses: actions/github-script@v6
with:
script: |
if ("${{ github.event.inputs.STARK_BACKEND_REV }}" !== "") {
// If provided by user, simply return it
return "${{ github.event.inputs.STARK_BACKEND_REV }}";
} else {
// Otherwise fetch latest commit of main
const { data } = await github.rest.repos.getCommit({
owner: 'openvm-org',
repo: 'stark-backend',
ref: 'main'
});
return data.sha;
}
- name: Get default OPENVM_REV from main (if none provided)
id: get-openvm-rev
uses: actions/github-script@v6
with:
script: |
if ("${{ github.event.inputs.OPENVM_REV }}" !== "") {
// If provided by user, simply return it
return "${{ github.event.inputs.OPENVM_REV }}";
} else {
// Otherwise fetch latest commit of main
const { data } = await github.rest.repos.getCommit({
owner: 'openvm-org',
repo: 'openvm',
ref: 'main'
});
return data.sha;
}
- name: Replace placeholders in configuration
run: |
STARK_BACKEND_REV="${{ steps.get-stark-backend-rev.outputs.result }}"
OPENVM_REV="${{ steps.get-openvm-rev.outputs.result }}"
echo "Using STARK_BACKEND_REV=$STARK_BACKEND_REV"
echo "Using OPENVM_REV=$OPENVM_REV"
# Replace placeholders in template
sed "s|\$STARK_BACKEND_REV|${STARK_BACKEND_REV}|g" .cargo/config.template.toml > .cargo/config.tmp.toml
sed "s|\$OPENVM_REV|${OPENVM_REV}|g" .cargo/config.tmp.toml > .cargo/config.toml
rm .cargo/config.tmp.toml
- name: Configure git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Create or update branch
id: create-branch
run: |
if [ "${{ github.event_name == 'schedule' }}" = "true" ]; then
BRANCH_NAME="nightly"
else
BRANCH_NAME="patch-openvm-$(date +%Y%m%d%H%M%S)"
fi
# Delete local branch if it exists
git branch -D "$BRANCH_NAME" 2>/dev/null || true
# Create new branch
git checkout -b "$BRANCH_NAME"
git add -f .cargo/config.toml
git commit -m "Patch openvm commits in .cargo/config.toml"
git push -f origin "$BRANCH_NAME"
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- name: Create pull request
uses: repo-sync/pull-request@v2
id: create-pr
with:
source_branch: ${{ steps.create-branch.outputs.branch_name }}
destination_branch: ${{ github.ref_name }}
pr_title: "Patch openvm commits"
pr_body: |
This pull request updates .cargo/config.toml using:
- STARK_BACKEND_REV = ${{ steps.get-stark-backend-rev.outputs.result }}
- OPENVM_REV = ${{ steps.get-openvm-rev.outputs.result }}
github_token: ${{ secrets.GITHUB_TOKEN }}
run-benchmark:
needs: update-config
if: ${{ github.event.inputs.run_benchmark == 'true' || github.event_name == 'schedule' }}
uses: ./.github/workflows/reth-benchmark.yml
with:
mode: ${{ github.event.inputs.benchmark_mode || 'prove-e2e' }}
ref: ${{ needs.update-config.outputs.branch_name }}
secrets:
GH_ACTIONS_DEPLOY_PRIVATE_KEY: ${{ secrets.GH_ACTIONS_DEPLOY_PRIVATE_KEY }}
RPC_URL_1: ${{ secrets.RPC_URL_1 }}
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
close-pr:
needs: [update-config, run-benchmark]
if: ${{ github.event.inputs.run_benchmark == 'true' || github.event_name == 'schedule' }}
runs-on: ubuntu-latest
steps:
- name: Close PR
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{ needs.update-config.outputs.pr_number }},
state: 'closed'
});