Skip to content

Commit 087a4ae

Browse files
committed
Add Verus update test workflow
1 parent 4b6e5e2 commit 087a4ae

File tree

2 files changed

+160
-0
lines changed

2 files changed

+160
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Promote Update-Test to Main & Version
2+
3+
on:
4+
repository_dispatch:
5+
types: [verus-update-test-success]
6+
7+
jobs:
8+
promote:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout update-test
12+
uses: actions/checkout@v3
13+
with:
14+
ref: ${{ github.event.client_payload.branch }}
15+
fetch-depth: 0
16+
17+
- name: Configure Git for CI
18+
run: |
19+
git config user.name "Verus CI Bot"
20+
git config user.email "[email protected]"
21+
22+
- name: Read version branch from rust-toolchain.toml
23+
id: read-version
24+
run: |
25+
VERUS_VERSION=$(grep '^channel' rust-toolchain.toml | awk -F'"' '{print $2}')
26+
echo "VERUS_VERSION=$VERUS_VERSION" >> $GITHUB_ENV
27+
echo "Using version branch: $VERUS_VERSION"
28+
29+
- name: Push to version branch
30+
run: git push origin HEAD:${{ env.VERUS_VERSION }} --force
31+
32+
- name: Fetch main and origin
33+
run: |
34+
git fetch origin main --tags
35+
git fetch --all
36+
37+
- name: Cherry-pick workflow commit from main
38+
run: |
39+
WORKFLOW_COMMIT=$(git log origin/main --grep="Add Verus update test workflow" --pretty=format:"%H" -n 1)
40+
if [ -z "$WORKFLOW_COMMIT" ]; then
41+
echo "No workflow commit found on main. Aborting."
42+
exit 1
43+
else
44+
git cherry-pick $WORKFLOW_COMMIT
45+
fi
46+
47+
- name: Push to main
48+
run: git push origin HEAD:main --force
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Sync Upstream Verus & Dispatch
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "0 23 * * *"
7+
8+
jobs:
9+
check-version:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
continue: ${{ steps.version-check.outputs.continue }}
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Fetch upstream
20+
run: |
21+
git remote add upstream https://github.com/verus-lang/verus.git || true
22+
git fetch upstream main
23+
24+
- name: Read versions
25+
id: version-check
26+
run: |
27+
# upstream version
28+
UPSTREAM_VERSION=$(git show upstream/main:rust-toolchain.toml | grep '^channel' | awk -F'"' '{print $2}')
29+
echo "Upstream version: $UPSTREAM_VERSION"
30+
31+
# local fork version
32+
VERUS_VERSION=$(grep '^channel' rust-toolchain.toml | awk -F'"' '{print $2}')
33+
echo "Local VERUS_VERSION: $VERUS_VERSION"
34+
35+
if [ "$UPSTREAM_VERSION" != "$VERUS_VERSION" ]; then
36+
echo "Version changed! Fail workflow and create issue."
37+
echo "continue=false" >> $GITHUB_OUTPUT
38+
exit 1
39+
else
40+
echo "Version unchanged."
41+
echo "continue=true" >> $GITHUB_OUTPUT
42+
fi
43+
44+
- name: Create issue if version changed
45+
if: failure()
46+
uses: peter-evans/create-issue-from-file@v6
47+
with:
48+
title: "Detected upstream Verus rust-toolchain version change"
49+
content: |
50+
Detected upstream Verus rust-toolchain version change.
51+
52+
The [upstream repo](https://github.com/verus-lang/verus) has updated its rust-toolchain channel version.
53+
54+
Automation is halted.
55+
56+
Old version: ${{ steps.version-check.outputs.VERUS_VERSION }}
57+
New version: ${{ steps.version-check.outputs.UPSTREAM_VERSION }}
58+
Upstream commit: $(git rev-parse upstream/main)
59+
60+
Please manually update local code before re-running this workflow.
61+
assignees: your-github-username
62+
labels: automation
63+
issue-reuse-message: "An open issue already exists for rust-toolchain version change."
64+
token: ${{ secrets.GITHUB_TOKEN }}
65+
66+
update-test:
67+
needs: check-version
68+
if: needs.check-version.outputs.continue == 'true'
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Checkout
72+
uses: actions/checkout@v3
73+
with:
74+
fetch-depth: 0
75+
76+
- name: Configure Git for CI
77+
run: |
78+
git config user.name "Verus CI Bot"
79+
git config user.email "[email protected]"
80+
81+
- name: Fetch upstream & origin
82+
run: |
83+
git remote add upstream https://github.com/verus-lang/verus.git || true
84+
git fetch upstream main
85+
git fetch origin update-test
86+
87+
- name: Switch to update-test
88+
run: git checkout update-test
89+
90+
- name: Reset update-test to upstream/main
91+
run: git reset --hard upstream/main
92+
93+
- name: Cherry-pick "Fix for asterinas" commit
94+
run: |
95+
COMMIT_SHA=$(git log main --grep="Fix for asterinas" --pretty=format:"%H" -n 1)
96+
if [ -z "$COMMIT_SHA" ]; then
97+
echo "No commit with message 'Fix for asterinas' found on main. Aborting."
98+
exit 1
99+
else
100+
git cherry-pick $COMMIT_SHA
101+
fi
102+
103+
- name: Push update-test to origin
104+
run: git push origin update-test --force
105+
106+
- name: Repository dispatch to vostd
107+
uses: peter-evans/repository-dispatch@v2
108+
with:
109+
token: ${{ secrets.VERUS_TEST_TOKEN }}
110+
repository: asterinas/vostd
111+
event-type: verus-update-test
112+
client-payload: '{"branch":"main"}'

0 commit comments

Comments
 (0)