From 8a32d843deb8e0eaf56b1153d97f607161a7a2ef Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Mon, 27 Nov 2023 13:00:55 +0000 Subject: [PATCH 1/7] Automate cargo update Automatically create pull requests from the result of running `cargo update` every Monday morning. --- .github/workflows/cargo-update.yml | 47 ++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/cargo-update.yml diff --git a/.github/workflows/cargo-update.yml b/.github/workflows/cargo-update.yml new file mode 100644 index 000000000000..ef2d8847d527 --- /dev/null +++ b/.github/workflows/cargo-update.yml @@ -0,0 +1,47 @@ +# Copyright Kani Contributors +# SPDX-License-Identifier: Apache-2.0 OR MIT + +name: Attempt cargo update + +on: + schedule: + - cron: "30 3 * * Mon" # Run this every Monday at 03:30 UTC + workflow_dispatch: # Allow manual dispatching for a custom branch / tag. + +permissions: + checks: write + contents: write + pull-requests: write + +jobs: + create-cargo-update-pr: + runs-on: ubuntu-22.04 + steps: + - name: Checkout Kani + uses: actions/checkout@v3 + + - name: Setup Kani Dependencies + uses: ./.github/actions/setup + with: + os: ubuntu-22.04 + + - name: Run cargo update + env: + GH_TOKEN: ${{ github.token }} + run: | + today=$(date +%Y-%m-%d) + echo "today=$today" >> $GITHUB_ENV + if ! git ls-remote --exit-code origin cargo-update-$today ; then + cargo update + cargo build-dev + git diff + fi + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + commit-message: Upgrade cargo dependencies to ${{ env.today }} + branch: cargo-update-${{ env.today }} + delete-branch: true + title: 'Automatic cargo update to ${{ env.today }}' + body: > + Dependency upgrade resulting from `cargo update`. From 081342fb18f90c23e17d35a8274cb98c90999b3e Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Mon, 27 Nov 2023 13:20:29 +0000 Subject: [PATCH 2/7] Automatically upgrade CBMC dependency --- .github/workflows/cbmc-update.yml | 48 +++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/cbmc-update.yml diff --git a/.github/workflows/cbmc-update.yml b/.github/workflows/cbmc-update.yml new file mode 100644 index 000000000000..ca0244e95902 --- /dev/null +++ b/.github/workflows/cbmc-update.yml @@ -0,0 +1,48 @@ +# 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 + pull-requests: write + +jobs: + create-cargo-update-pr: + runs-on: ubuntu-22.04 + steps: + - name: Checkout Kani + uses: actions/checkout@v3 + + - name: Compare CBMC versions + 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 + if [ x$CBMC_LATEST != x$CBMC_VERSION ] ; then + if ! 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 + fi + fi + - name: Create Pull Request + 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. From 43b8932b5ccc1d9c891ff1bc1747639563607b5f Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Tue, 28 Nov 2023 10:05:07 +0000 Subject: [PATCH 3/7] Revert "Automate cargo update" This reverts commit 8a32d843deb8e0eaf56b1153d97f607161a7a2ef. --- .github/workflows/cargo-update.yml | 47 ------------------------------ 1 file changed, 47 deletions(-) delete mode 100644 .github/workflows/cargo-update.yml diff --git a/.github/workflows/cargo-update.yml b/.github/workflows/cargo-update.yml deleted file mode 100644 index ef2d8847d527..000000000000 --- a/.github/workflows/cargo-update.yml +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright Kani Contributors -# SPDX-License-Identifier: Apache-2.0 OR MIT - -name: Attempt cargo update - -on: - schedule: - - cron: "30 3 * * Mon" # Run this every Monday at 03:30 UTC - workflow_dispatch: # Allow manual dispatching for a custom branch / tag. - -permissions: - checks: write - contents: write - pull-requests: write - -jobs: - create-cargo-update-pr: - runs-on: ubuntu-22.04 - steps: - - name: Checkout Kani - uses: actions/checkout@v3 - - - name: Setup Kani Dependencies - uses: ./.github/actions/setup - with: - os: ubuntu-22.04 - - - name: Run cargo update - env: - GH_TOKEN: ${{ github.token }} - run: | - today=$(date +%Y-%m-%d) - echo "today=$today" >> $GITHUB_ENV - if ! git ls-remote --exit-code origin cargo-update-$today ; then - cargo update - cargo build-dev - git diff - fi - - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 - with: - commit-message: Upgrade cargo dependencies to ${{ env.today }} - branch: cargo-update-${{ env.today }} - delete-branch: true - title: 'Automatic cargo update to ${{ env.today }}' - body: > - Dependency upgrade resulting from `cargo update`. From c49f775d14dfd3304149095175faecd8302881c2 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Tue, 28 Nov 2023 10:18:48 +0000 Subject: [PATCH 4/7] Run regression tests --- .github/workflows/cbmc-update.yml | 47 +++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cbmc-update.yml b/.github/workflows/cbmc-update.yml index ca0244e95902..619abe703c9e 100644 --- a/.github/workflows/cbmc-update.yml +++ b/.github/workflows/cbmc-update.yml @@ -11,6 +11,7 @@ on: permissions: checks: write contents: write + issues: write pull-requests: write jobs: @@ -20,6 +21,11 @@ jobs: - name: Checkout Kani uses: actions/checkout@v3 + - name: Setup Kani Dependencies + uses: ./.github/actions/setup + with: + os: ubuntu-22.04 + - name: Compare CBMC versions env: GH_TOKEN: ${{ github.token }} @@ -27,17 +33,31 @@ jobs: 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 - if [ x$CBMC_LATEST != x$CBMC_VERSION ] ; then - if ! 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 [ x$CBMC_LATEST = x$CBMC_VERSION ] ; then + echo "next_step=none" >> $GITHUB_ENV + elif gh issue list -S \ + "CBMC upgrade to $CBMC_LATEST failed" \ + --json number,title | grep title ; then + echo "next_step=none" >> $GITHUB_ENV + 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 ! cargo build-dev ; then + echo "next_step=create_issue" >> $GITHUB_ENV + elif ! ./scripts/kani-regression.sh ; then + echo "next_step=create_issue" >> $GITHUB_ENV + else + echo "next_step=create_pr" >> $GITHUB_ENV fi + 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 }} @@ -46,3 +66,14 @@ jobs: 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 }}) From 4161fe72802b7a490dea1ac46d227a92d3396d3a Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Tue, 28 Nov 2023 21:47:48 +0000 Subject: [PATCH 5/7] Respond to feedback --- .github/workflows/cbmc-update.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cbmc-update.yml b/.github/workflows/cbmc-update.yml index 619abe703c9e..422d42fedbb8 100644 --- a/.github/workflows/cbmc-update.yml +++ b/.github/workflows/cbmc-update.yml @@ -26,19 +26,24 @@ jobs: with: os: ubuntu-22.04 - - name: Compare CBMC versions + - 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.) @@ -46,13 +51,12 @@ jobs: 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 ! cargo build-dev ; then - echo "next_step=create_issue" >> $GITHUB_ENV - elif ! ./scripts/kani-regression.sh ; then + 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 From 2e1fc7099ff1926bdc53565c1fd767b28358e35f Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Tue, 28 Nov 2023 22:48:14 +0100 Subject: [PATCH 6/7] Update .github/workflows/cbmc-update.yml Co-authored-by: Adrian Palacios <73246657+adpaco-aws@users.noreply.github.com> --- .github/workflows/cbmc-update.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cbmc-update.yml b/.github/workflows/cbmc-update.yml index 422d42fedbb8..64b8e5ef677f 100644 --- a/.github/workflows/cbmc-update.yml +++ b/.github/workflows/cbmc-update.yml @@ -60,6 +60,7 @@ jobs: 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 From a49110e757a771a5f22d84982722efed7ae4929a Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Tue, 28 Nov 2023 22:48:20 +0100 Subject: [PATCH 7/7] Update .github/workflows/cbmc-update.yml Co-authored-by: Adrian Palacios <73246657+adpaco-aws@users.noreply.github.com> --- .github/workflows/cbmc-update.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cbmc-update.yml b/.github/workflows/cbmc-update.yml index 64b8e5ef677f..3b8d6cbcd37e 100644 --- a/.github/workflows/cbmc-update.yml +++ b/.github/workflows/cbmc-update.yml @@ -71,6 +71,7 @@ jobs: 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