-
Notifications
You must be signed in to change notification settings - Fork 92
85 lines (76 loc) · 3.22 KB
/
cbmc-update.yml
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
# Copyright Kani Contributors
# SPDX-License-Identifier: Apache-2.0 OR MIT
name: Attempt CBMC update
on:
schedule:
- cron: "30 4 * * Mon" # Run this every Monday at 04:30 UTC
workflow_dispatch: # Allow manual dispatching for a custom branch / tag.
permissions:
checks: write
contents: write
issues: write
pull-requests: write
jobs:
create-cargo-update-pr:
runs-on: ubuntu-22.04
steps:
- name: Checkout Kani
uses: actions/checkout@v4
- name: Setup Kani Dependencies
uses: ./.github/actions/setup
with:
os: ubuntu-22.04
- name: Compare CBMC versions and determine next step
env:
GH_TOKEN: ${{ github.token }}
run: |
grep ^CBMC_VERSION kani-dependencies >> $GITHUB_ENV
CBMC_LATEST=$(gh -R diffblue/cbmc release list | grep Latest | awk '{print $1}' | cut -f2 -d-)
echo "CBMC_LATEST=$CBMC_LATEST" >> $GITHUB_ENV
# check whether the version has changed at all
if [ x$CBMC_LATEST = x$CBMC_VERSION ] ; then
echo "next_step=none" >> $GITHUB_ENV
# check whether we already have an existing issue for a failing
# upgrade
elif gh issue list -S \
"CBMC upgrade to $CBMC_LATEST failed" \
--json number,title | grep title ; then
echo "next_step=none" >> $GITHUB_ENV
# check whether we already have a branch (and thus: a PR) for a
# successful upgrade
elif ! git ls-remote --exit-code origin cbmc-$CBMC_LATEST ; then
CBMC_LATEST_MAJOR=$(echo $CBMC_LATEST | cut -f1 -d.)
CBMC_LATEST_MINOR=$(echo $CBMC_LATEST | cut -f2 -d.)
sed -i "s/^CBMC_MAJOR=.*/CBMC_MAJOR=\"$CBMC_MAJOR\"/" kani-dependencies
sed -i "s/^CBMC_MINOR=.*/CBMC_MINOR=\"$CBMC_MINOR\"/" kani-dependencies
sed -i "s/^CBMC_VERSION=.*/CBMC_VERSION=\"$CBMC_LATEST\"/" kani-dependencies
git diff
if ! ./scripts/kani-regression.sh ; then
echo "next_step=create_issue" >> $GITHUB_ENV
else
echo "next_step=create_pr" >> $GITHUB_ENV
fi
# we already have a PR, nothing to be done
else
echo "next_step=none" >> $GITHUB_ENV
fi
- name: Create Pull Request
if: ${{ env.next_step == 'create_pr' }}
uses: peter-evans/create-pull-request@v5
with:
commit-message: Upgrade CBMC from ${{ env.CBMC_VERSION }} to ${{ env.CBMC_LATEST }}
branch: cbmc-${{ env.CBMC_LATEST }}
delete-branch: true
title: 'Automatic upgrade of CBMC from ${{ env.CBMC_VERSION }} to ${{ env.CBMC_LATEST }}'
body: >
Upgrade CBMC to its latest release.
- name: Create Issue
if: ${{ env.next_step == 'create_issue' }}
uses: dacbd/create-issue-action@main
with:
token: ${{ github.token }}
title: 'CBMC upgrade to ${{ env.CBMC_LATEST }} failed'
body: >
Updating CBMC from ${{ evn.CBMC_VERSION }} to ${{ env.CBMC_LATEST }} failed.
The failed automated run
[can be found here.](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})