|
| 1 | +# Copyright Kani Contributors |
| 2 | +# SPDX-License-Identifier: Apache-2.0 OR MIT |
| 3 | + |
| 4 | +name: Attempt CBMC update |
| 5 | + |
| 6 | +on: |
| 7 | + schedule: |
| 8 | + - cron: "30 4 * * Mon" # Run this every Monday at 04:30 UTC |
| 9 | + workflow_dispatch: # Allow manual dispatching for a custom branch / tag. |
| 10 | + |
| 11 | +permissions: |
| 12 | + checks: write |
| 13 | + contents: write |
| 14 | + issues: write |
| 15 | + pull-requests: write |
| 16 | + |
| 17 | +jobs: |
| 18 | + create-cargo-update-pr: |
| 19 | + runs-on: ubuntu-22.04 |
| 20 | + steps: |
| 21 | + - name: Checkout Kani |
| 22 | + uses: actions/checkout@v3 |
| 23 | + |
| 24 | + - name: Setup Kani Dependencies |
| 25 | + uses: ./.github/actions/setup |
| 26 | + with: |
| 27 | + os: ubuntu-22.04 |
| 28 | + |
| 29 | + - name: Compare CBMC versions and determine next step |
| 30 | + env: |
| 31 | + GH_TOKEN: ${{ github.token }} |
| 32 | + run: | |
| 33 | + grep ^CBMC_VERSION kani-dependencies >> $GITHUB_ENV |
| 34 | + CBMC_LATEST=$(gh -R diffblue/cbmc release list | grep Latest | awk '{print $1}' | cut -f2 -d-) |
| 35 | + echo "CBMC_LATEST=$CBMC_LATEST" >> $GITHUB_ENV |
| 36 | + # check whether the version has changed at all |
| 37 | + if [ x$CBMC_LATEST = x$CBMC_VERSION ] ; then |
| 38 | + echo "next_step=none" >> $GITHUB_ENV |
| 39 | + # check whether we already have an existing issue for a failing |
| 40 | + # upgrade |
| 41 | + elif gh issue list -S \ |
| 42 | + "CBMC upgrade to $CBMC_LATEST failed" \ |
| 43 | + --json number,title | grep title ; then |
| 44 | + echo "next_step=none" >> $GITHUB_ENV |
| 45 | + # check whether we already have a branch (and thus: a PR) for a |
| 46 | + # successful upgrade |
| 47 | + elif ! git ls-remote --exit-code origin cbmc-$CBMC_LATEST ; then |
| 48 | + CBMC_LATEST_MAJOR=$(echo $CBMC_LATEST | cut -f1 -d.) |
| 49 | + CBMC_LATEST_MINOR=$(echo $CBMC_LATEST | cut -f2 -d.) |
| 50 | + sed -i "s/^CBMC_MAJOR=.*/CBMC_MAJOR=\"$CBMC_MAJOR\"/" kani-dependencies |
| 51 | + sed -i "s/^CBMC_MINOR=.*/CBMC_MINOR=\"$CBMC_MINOR\"/" kani-dependencies |
| 52 | + sed -i "s/^CBMC_VERSION=.*/CBMC_VERSION=\"$CBMC_LATEST\"/" kani-dependencies |
| 53 | + git diff |
| 54 | + if ! ./scripts/kani-regression.sh ; then |
| 55 | + echo "next_step=create_issue" >> $GITHUB_ENV |
| 56 | + else |
| 57 | + echo "next_step=create_pr" >> $GITHUB_ENV |
| 58 | + fi |
| 59 | + # we already have a PR, nothing to be done |
| 60 | + else |
| 61 | + echo "next_step=none" >> $GITHUB_ENV |
| 62 | + fi |
| 63 | +
|
| 64 | + - name: Create Pull Request |
| 65 | + if: ${{ env.next_step == 'create_pr' }} |
| 66 | + uses: peter-evans/create-pull-request@v5 |
| 67 | + with: |
| 68 | + commit-message: Upgrade CBMC from ${{ env.CBMC_VERSION }} to ${{ env.CBMC_LATEST }} |
| 69 | + branch: cbmc-${{ env.CBMC_LATEST }} |
| 70 | + delete-branch: true |
| 71 | + title: 'Automatic upgrade of CBMC from ${{ env.CBMC_VERSION }} to ${{ env.CBMC_LATEST }}' |
| 72 | + body: > |
| 73 | + Upgrade CBMC to its latest release. |
| 74 | +
|
| 75 | + - name: Create Issue |
| 76 | + if: ${{ env.next_step == 'create_issue' }} |
| 77 | + uses: dacbd/create-issue-action@main |
| 78 | + with: |
| 79 | + token: ${{ github.token }} |
| 80 | + title: 'CBMC upgrade to ${{ env.CBMC_LATEST }} failed' |
| 81 | + body: > |
| 82 | + Updating CBMC from ${{ evn.CBMC_VERSION }} to ${{ env.CBMC_LATEST }} failed. |
| 83 | +
|
| 84 | + The failed automated run |
| 85 | + [can be found here.](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) |
0 commit comments