Skip to content

Check NVBit Updates #115

Check NVBit Updates

Check NVBit Updates #115

name: Check NVBit Updates
on:
schedule:
# Run daily at UTC 09:00 (Beijing 17:00, PST 01:00/02:00)
- cron: '0 9 * * *'
workflow_dispatch:
inputs:
force:
description: 'Force create PR even if version is same'
type: boolean
default: false
dry_run:
description: 'Dry run - only check versions, do not create PR'
type: boolean
default: false
permissions:
contents: write
pull-requests: write
actions: write
jobs:
check-and-update:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Get current NVBit version
id: current
run: |
CURRENT=$(grep -oP 'NVBIT_VERSION:-\K[0-9.]+' install_third_party.sh | head -1)
echo "version=$CURRENT" >> $GITHUB_OUTPUT
echo "📦 Current NVBit version: $CURRENT"
- name: Get latest NVBit release
id: latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
MAX_RETRIES=3
RETRY_DELAY=10
RESPONSE=""
SUCCESS=false
for i in $(seq 1 $MAX_RETRIES); do
echo "🔄 Attempt $i/$MAX_RETRIES: Fetching latest NVBit release..."
RESPONSE=$(curl -s -H "Authorization: Bearer $GH_TOKEN" \
https://api.github.com/repos/NVlabs/NVBit/releases/latest)
CURL_EXIT=$?
if [ $CURL_EXIT -ne 0 ]; then
echo "⚠️ curl failed with exit code $CURL_EXIT"
elif echo "$RESPONSE" | jq -e '.message' > /dev/null 2>&1; then
echo "⚠️ API returned error: $(echo "$RESPONSE" | jq -r '.message')"
else
echo "✅ API request succeeded on attempt $i"
SUCCESS=true
break
fi
if [ $i -lt $MAX_RETRIES ]; then
echo "⏳ Waiting ${RETRY_DELAY}s before retry..."
sleep $RETRY_DELAY
RETRY_DELAY=$((RETRY_DELAY * 2))
fi
done
LATEST=$(echo "$RESPONSE" | jq -r '.tag_name // empty' | sed 's/^v//')
PUBLISHED=$(echo "$RESPONSE" | jq -r '.published_at // empty')
if [ "$SUCCESS" = true ] && [ -n "$LATEST" ] && [ "$LATEST" != "null" ]; then
echo "valid=true" >> $GITHUB_OUTPUT
echo "version=$LATEST" >> $GITHUB_OUTPUT
echo "published=$PUBLISHED" >> $GITHUB_OUTPUT
echo "🆕 Latest NVBit version: $LATEST (published: $PUBLISHED)"
else
echo "❌ Failed to get valid version after $MAX_RETRIES attempts"
echo "valid=false" >> $GITHUB_OUTPUT
echo "version=" >> $GITHUB_OUTPUT
echo "published=" >> $GITHUB_OUTPUT
fi
- name: Check if update needed
id: check
run: |
VALID="${{ steps.latest.outputs.valid }}"
CURRENT="${{ steps.current.outputs.version }}"
LATEST="${{ steps.latest.outputs.version }}"
if [ "$VALID" != "true" ]; then
echo "update_needed=false" >> $GITHUB_OUTPUT
echo "⚠️ Skipping update: could not retrieve valid latest version"
elif [ "$CURRENT" != "$LATEST" ]; then
echo "update_needed=true" >> $GITHUB_OUTPUT
echo "✅ Update available: $CURRENT → $LATEST"
else
echo "update_needed=false" >> $GITHUB_OUTPUT
echo "ℹ️ Already up to date: $CURRENT"
fi
- name: Update version in script
if: |
(steps.check.outputs.update_needed == 'true' || inputs.force == true)
&& inputs.dry_run != true
run: |
sed -i 's/NVBIT_VERSION:-[0-9.]*/NVBIT_VERSION:-${{ steps.latest.outputs.version }}/' \
install_third_party.sh
echo "📝 Updated install_third_party.sh"
git diff install_third_party.sh
- name: Create Pull Request
id: create-pr
if: |
(steps.check.outputs.update_needed == 'true' || inputs.force == true)
&& inputs.dry_run != true
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "[deps] Update NVBit to ${{ steps.latest.outputs.version }}"
title: "[deps] Update NVBit ${{ steps.current.outputs.version }} → ${{ steps.latest.outputs.version }}"
body: |
## 🔄 Automated Dependency Update
| Package | Current | New | Published |
|---------|---------|-----|-----------|
| NVBit | `${{ steps.current.outputs.version }}` | `${{ steps.latest.outputs.version }}` | ${{ steps.latest.outputs.published }} |
### 📝 Release Notes
https://github.com/NVlabs/NVBit/releases/tag/v${{ steps.latest.outputs.version }}
### ✅ Testing
> ⚠️ Due to GitHub token limitations, tests are triggered separately via `workflow_dispatch`
> and will **NOT** appear in the PR Checks tab.
>
> 👉 **[View test results on Actions page](https://github.com/facebookexperimental/CUTracer/actions/workflows/test.yml)**
Please verify test results on the Actions page before merging.
---
*Auto-generated by dependency update workflow*
branch: dependabot/nvbit/${{ steps.latest.outputs.version }}
labels: |
dependencies
automated
delete-branch: true
- name: Trigger test workflow on PR branch
if: steps.create-pr.outputs.pull-request-number
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sleep 5
echo "🚀 Triggering test workflow on branch dependabot/nvbit/${{ steps.latest.outputs.version }}"
gh workflow run test.yml \
--repo ${{ github.repository }} \
--ref "dependabot/nvbit/${{ steps.latest.outputs.version }}" \
-f test-type=all \
-f debug=false
echo "✅ Test workflow triggered. View results at:"
echo " https://github.com/${{ github.repository }}/actions/workflows/test.yml"
- name: Summary
run: |
echo "## NVBit Version Check Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Item | Value |" >> $GITHUB_STEP_SUMMARY
echo "|------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| Current Version | ${{ steps.current.outputs.version }} |" >> $GITHUB_STEP_SUMMARY
echo "| Latest Version | ${{ steps.latest.outputs.version }} |" >> $GITHUB_STEP_SUMMARY
echo "| Update Needed | ${{ steps.check.outputs.update_needed }} |" >> $GITHUB_STEP_SUMMARY
echo "| Dry Run | ${{ inputs.dry_run || 'false' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Force | ${{ inputs.force || 'false' }} |" >> $GITHUB_STEP_SUMMARY