-
Notifications
You must be signed in to change notification settings - Fork 9
176 lines (153 loc) · 6.83 KB
/
Copy pathcheck-nvbit-update.yml
File metadata and controls
176 lines (153 loc) · 6.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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