forked from verus-lang/verus
-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (127 loc) · 5.2 KB
/
Copy pathupstream-sync.yml
File metadata and controls
151 lines (127 loc) · 5.2 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
name: Sync Upstream Verus & Dispatch
on:
workflow_dispatch:
schedule:
- cron: "0 23 * * *"
jobs:
check-version:
runs-on: ubuntu-latest
outputs:
continue: ${{ steps.version-check.outputs.continue }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Fetch upstream
run: |
git remote add upstream https://github.com/verus-lang/verus.git || true
git fetch upstream main
- name: Read versions
id: version-check
run: |
# upstream version
UPSTREAM_VERSION=$(git show upstream/main:rust-toolchain.toml | grep '^channel' | awk -F'"' '{print $2}')
echo "Upstream version: $UPSTREAM_VERSION"
echo "UPSTREAM_VERSION=$UPSTREAM_VERSION" >> $GITHUB_OUTPUT
# local fork version
VERUS_VERSION=$(grep '^channel' rust-toolchain.toml | awk -F'"' '{print $2}')
echo "Local VERUS_VERSION: $VERUS_VERSION"
echo "VERUS_VERSION=$VERUS_VERSION" >> $GITHUB_OUTPUT
if [ "$UPSTREAM_VERSION" != "$VERUS_VERSION" ]; then
echo "Version changed! Fail workflow and create issue."
echo "continue=false" >> $GITHUB_OUTPUT
exit 1
else
echo "Version unchanged."
echo "continue=true" >> $GITHUB_OUTPUT
fi
- name: Create issue if version changed
if: failure()
uses: actions/github-script@v9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const upstream_version = '${{ steps.version-check.outputs.UPSTREAM_VERSION }}';
const local_version = '${{ steps.version-check.outputs.VERUS_VERSION }}';
const upstream_commit = await exec.getExecOutput('git', ['rev-parse', 'upstream/main']);
const title = 'Detected upstream Verus rust-toolchain version change';
const body = `Detected upstream Verus rust-toolchain version change.
The [upstream repo](https://github.com/verus-lang/verus) has updated its rust-toolchain channel version.
Automation is halted.
Old version: ${local_version || 'unknown'}
New version: ${upstream_version || 'unknown'}
Upstream commit: ${upstream_commit.stdout.trim()}
Please manually update local code before re-running this workflow.`;
// Check if there's already an open issue with this title
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'automation'
});
const existingIssue = issues.data.find(issue => issue.title === title);
if (existingIssue) {
// Update existing issue
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existingIssue.number,
body: `Updated detection:\n\n${body}`
});
console.log(`Updated existing issue #${existingIssue.number}`);
} else {
// Create new issue
const issue = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
labels: ['automation'],
});
console.log(`Created new issue #${issue.data.number}`);
}
update-test:
needs: check-version
if: needs.check-version.outputs.continue == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Configure Git for CI
run: |
git config user.name "Verus CI Bot"
git config user.email "ci@asterinas.verus"
- name: Fetch upstream & origin
run: |
git remote add upstream https://github.com/verus-lang/verus.git || true
git fetch upstream main
git fetch origin update-test
- name: Switch to update-test
run: git checkout update-test
- name: Reset update-test to upstream/main
run: git reset --hard upstream/main
# - name: Merge Pending Upstream PRs
# run: |
# git fetch upstream pull/2217/head:pr-2217
# git merge pr-2217 --no-edit
# - name: Cherry-pick "Fix for asterinas" commit
# run: |
# COMMIT_SHA=$(git log main --grep="Fix for asterinas" --pretty=format:"%H" -n 1)
# if [ -z "$COMMIT_SHA" ]; then
# echo "No commit with message 'Fix for asterinas' found on main. Aborting."
# exit 1
# else
# git cherry-pick $COMMIT_SHA
# fi
- name: Push update-test to origin
run: git push origin update-test --force
- name: Repository dispatch to vostd
uses: peter-evans/repository-dispatch@v4
with:
token: ${{ secrets.VERUS_TEST_TOKEN }}
repository: asterinas/vostd
event-type: verus-update-test
client-payload: '{"branch":"main"}'