Skip to content

Commit 036eb88

Browse files
authored
Automate cargo update without dependabot (#2942)
Automatically create pull requests from the result of running `cargo update` every Monday morning. This should avoid the need for manual PRs to update Cargo.lock, which seemingly dependabot wouldn't take care of. We now only use dependabot to update github actions. This revives what I had initially proposed in #2895 in light of #2940.
1 parent 1e6213d commit 036eb88

File tree

2 files changed

+47
-10
lines changed

2 files changed

+47
-10
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,3 @@ updates:
99
directory: "/"
1010
schedule:
1111
interval: "weekly"
12-
13-
- package-ecosystem: "cargo"
14-
directory: "/"
15-
schedule:
16-
interval: "weekly"
17-
groups:
18-
cargo:
19-
update-types:
20-
- "minor"
21-
- "patch"

.github/workflows/cargo-update.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
name: Attempt cargo update
5+
6+
on:
7+
schedule:
8+
- cron: "30 3 * * Mon" # Run this every Monday at 03:30 UTC
9+
workflow_dispatch: # Allow manual dispatching for a custom branch / tag.
10+
11+
permissions:
12+
checks: write
13+
contents: write
14+
pull-requests: write
15+
16+
jobs:
17+
create-cargo-update-pr:
18+
runs-on: ubuntu-22.04
19+
steps:
20+
- name: Checkout Kani
21+
uses: actions/checkout@v3
22+
23+
- name: Setup Kani Dependencies
24+
uses: ./.github/actions/setup
25+
with:
26+
os: ubuntu-22.04
27+
28+
- name: Run cargo update
29+
env:
30+
GH_TOKEN: ${{ github.token }}
31+
run: |
32+
today=$(date +%Y-%m-%d)
33+
echo "today=$today" >> $GITHUB_ENV
34+
if ! git ls-remote --exit-code origin cargo-update-$today ; then
35+
cargo update
36+
cargo build-dev
37+
git diff
38+
fi
39+
- name: Create Pull Request
40+
uses: peter-evans/create-pull-request@v5
41+
with:
42+
commit-message: Upgrade cargo dependencies to ${{ env.today }}
43+
branch: cargo-update-${{ env.today }}
44+
delete-branch: true
45+
title: 'Automatic cargo update to ${{ env.today }}'
46+
body: >
47+
Dependency upgrade resulting from `cargo update`.

0 commit comments

Comments
 (0)