-
Notifications
You must be signed in to change notification settings - Fork 478
Introduce github action to run CI on new snarkVM revs #1097
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
base: mainnet
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,136 @@ | ||||
name: Update snarkVM dependency | ||||
|
||||
on: | ||||
schedule: | ||||
# Run every hour to check for new commits in snarkVM staging | ||||
- cron: '0 * * * *' | ||||
push: | ||||
branches: | ||||
- 'ci/snarkvm-update' | ||||
|
||||
env: | ||||
RUST_BACKTRACE: 1 | ||||
|
||||
jobs: | ||||
update-snarkvm-staging: | ||||
name: Update snarkVM to latest staging | ||||
runs-on: ubuntu-22.04 | ||||
permissions: | ||||
contents: write | ||||
pull-requests: write | ||||
steps: | ||||
- name: Checkout SDK | ||||
uses: actions/checkout@v5 | ||||
with: | ||||
ref: mainnet | ||||
token: ${{ secrets.GITHUB_TOKEN }} | ||||
|
||||
- name: Get latest snarkVM staging commit | ||||
id: snarkvm-commit | ||||
uses: actions/github-script@v7 | ||||
with: | ||||
script: | | ||||
// Get the latest commit hash from snarkVM staging branch | ||||
const { data: branch } = await github.rest.repos.getBranch({ | ||||
owner: 'ProvableHQ', | ||||
repo: 'snarkVM', | ||||
branch: 'staging' | ||||
}); | ||||
|
||||
const latestCommit = branch.commit.sha; | ||||
console.log('Latest snarkVM staging commit:', latestCommit); | ||||
core.setOutput('latest_commit', latestCommit); | ||||
core.setOutput('update_needed', 'true'); | ||||
|
||||
- name: Setup Git | ||||
if: steps.snarkvm-commit.outputs.update_needed == 'true' | ||||
run: | | ||||
git config --global user.name "github-actions[bot]" | ||||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||||
|
||||
- name: Create new update-snarkvm-staging branch from staging | ||||
if: steps.snarkvm-commit.outputs.update_needed == 'true' | ||||
run: | | ||||
# Always create a fresh branch from staging | ||||
echo "Creating new update-snarkvm-staging branch from staging" | ||||
git checkout -B update-snarkvm-staging staging | ||||
echo "Created fresh update-snarkvm-staging branch from staging" | ||||
|
||||
- name: Update snarkVM dependency | ||||
if: steps.snarkvm-commit.outputs.update_needed == 'true' | ||||
run: | | ||||
# Validate the commit hash format (should be 40 chars hex or 7+ chars) | ||||
LATEST_COMMIT="${{ steps.snarkvm-commit.outputs.latest_commit }}" | ||||
if [[ ! "$LATEST_COMMIT" =~ ^[a-f0-9]{7,40}$ ]]; then | ||||
echo "Error: Invalid commit hash format: $LATEST_COMMIT" | ||||
exit 1 | ||||
fi | ||||
|
||||
# First, update the rev in Cargo.toml to point to the new commit | ||||
cd wasm | ||||
cargo add snarkvm-algorithms --git https://github.com/ProvableHQ/snarkVM --rev $LATEST_COMMIT | ||||
cargo add snarkvm-circuit-network --git https://github.com/ProvableHQ/snarkVM --rev $LATEST_COMMIT | ||||
cargo add snarkvm-console --git https://github.com/ProvableHQ/snarkVM --rev $LATEST_COMMIT | ||||
cargo add snarkvm-ledger-block --git https://github.com/ProvableHQ/snarkVM --rev $LATEST_COMMIT | ||||
cargo add snarkvm-ledger-query --git https://github.com/ProvableHQ/snarkVM --rev $LATEST_COMMIT | ||||
cargo add snarkvm-ledger-store --git https://github.com/ProvableHQ/snarkVM --rev $LATEST_COMMIT | ||||
cargo add snarkvm-parameters --git https://github.com/ProvableHQ/snarkVM --rev $LATEST_COMMIT | ||||
cargo add snarkvm-synthesizer-program --git https://github.com/ProvableHQ/snarkVM --rev $LATEST_COMMIT | ||||
cargo add snarkvm-synthesizer --git https://github.com/ProvableHQ/snarkVM --rev $LATEST_COMMIT | ||||
cargo add snarkvm-wasm --git https://github.com/ProvableHQ/snarkVM --rev $LATEST_COMMIT | ||||
|
||||
echo "✅ Successfully updated snarkVM dependency to $LATEST_COMMIT" | ||||
|
||||
- name: Commit and push changes | ||||
if: steps.snarkvm-commit.outputs.update_needed == 'true' | ||||
run: | | ||||
git add wasm/Cargo.toml wasm/Cargo.lock | ||||
git commit --no-verify -m "Update snarkVM to latest staging commit ${{ steps.snarkvm-commit.outputs.latest_commit }} | ||||
|
||||
Previous commit: ${{ steps.snarkvm-commit.outputs.current_commit }} | ||||
Latest commit: ${{ steps.snarkvm-commit.outputs.latest_commit }} | ||||
|
||||
This update was performed automatically by the snarkVM update workflow." | ||||
Comment on lines
+88
to
+93
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The commit message references Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||
git push --force-with-lease origin update-snarkvm-staging | ||||
|
||||
- name: Create or update PR | ||||
if: steps.snarkvm-commit.outputs.update_needed == 'true' | ||||
uses: actions/github-script@v7 | ||||
with: | ||||
script: | | ||||
// Check if a PR already exists from update-snarkvm-staging to staging | ||||
const { data: prs } = await github.rest.pulls.list({ | ||||
owner: 'ProvableHQ', | ||||
repo: 'sdk', | ||||
head: 'ProvableHQ:update-snarkvm-staging', | ||||
base: 'staging', | ||||
state: 'open' | ||||
}); | ||||
|
||||
if (prs.length === 0) { | ||||
// No PR exists, create one | ||||
const { data: pr } = await github.rest.pulls.create({ | ||||
owner: 'ProvableHQ', | ||||
repo: 'sdk', | ||||
title: 'Update snarkVM to latest staging commit', | ||||
head: 'update-snarkvm-staging', | ||||
base: 'staging', | ||||
body: 'This PR updates the snarkVM dependency to track the latest staging commit.\n\nLatest commit: ${{ steps.snarkvm-commit.outputs.latest_commit }}\nPrevious commit: ${{ steps.snarkvm-commit.outputs.current_commit }}\n\nThis PR was created automatically by the snarkVM update workflow.' | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The PR body references Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||
}); | ||||
console.log(`Created PR #${pr.number}: ${pr.html_url}`); | ||||
} else { | ||||
console.log(`PR already exists: ${prs[0].html_url}`); | ||||
} | ||||
|
||||
- name: Summary | ||||
if: always() | ||||
run: | | ||||
echo "## Workflow Summary (staging)" >> $GITHUB_STEP_SUMMARY | ||||
echo "- Current snarkVM commit: ${{ steps.snarkvm-commit.outputs.current_commit }}" >> $GITHUB_STEP_SUMMARY | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The summary step references
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||
echo "- Latest snarkVM commit: ${{ steps.snarkvm-commit.outputs.latest_commit }}" >> $GITHUB_STEP_SUMMARY | ||||
echo "- Update needed: ${{ steps.snarkvm-commit.outputs.update_needed }}" >> $GITHUB_STEP_SUMMARY | ||||
if [ "${{ steps.snarkvm-commit.outputs.update_needed }}" = "true" ]; then | ||||
echo "- ✅ snarkVM dependency updated successfully" >> $GITHUB_STEP_SUMMARY | ||||
else | ||||
echo "- ℹ️ No update required" >> $GITHUB_STEP_SUMMARY | ||||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
update_needed
output is hardcoded to 'true', which means the workflow will always attempt to update regardless of whether there are actual changes. Consider implementing logic to compare the current commit with the latest commit to determine if an update is actually needed.Copilot uses AI. Check for mistakes.