Debian Codegraph @

crt/aws-c-common/.github/workflows/proof_ci.yaml

raw symbols SCIP
1 # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 # SPDX-License-Identifier: MIT-0
3 # CBMC starter kit 2.9
4 name: Run CBMC proofs
5 on:
6 push:
7 branches-ignore:
8 - gh-pages
9 pull_request:
10 branches-ignore:
11 - gh-pages
12 workflow_dispatch:
13
14 # USAGE
15 #
16 # If you need to use different versions for tools like CBMC, modify this file:
17 # .github/workflows/proof_ci_resources/config.yaml
18 #
19 # If you want the CI to use a different GitHub-hosted runner (which must still
20 # be running Ubuntu 20.04), modify the value of this key:
21 # jobs.run_cbmc_proofs.runs-on
22
23 jobs:
24 run_cbmc_proofs:
25 runs-on: cbmc_ubuntu-latest_64-core
26 name: run_cbmc_proofs
27 permissions:
28 contents: read
29 id-token: write
30 pull-requests: read
31 steps:
32 - name: Check out repository and submodules recursively
33 uses: actions/checkout@v3
34 with:
35 submodules: 'recursive'
36 - name: Parse config file
37 run: |
38 CONFIG_FILE='.github/workflows/proof_ci_resources/config.yaml'
39 for setting in cadical-tag cbmc-version cbmc-viewer-version kissat-tag litani-version proofs-dir run-cbmc-proofs-command; do
40 VAR=$(echo $setting | tr "[:lower:]" "[:upper:]" | tr - _)
41 echo "${VAR}"=$(yq .$setting $CONFIG_FILE) >> $GITHUB_ENV
42 done
43 - name: Ensure CBMC, CBMC viewer, Litani versions have been specified
44 shell: bash
45 run: |
46 should_exit=false
47 if [ "${{ env.CBMC_VERSION }}" == "" ]; then
48 echo "You must specify a CBMC version (e.g. 'latest' or '5.70.0')"
49 should_exit=true
50 fi
51 if [ "${{ env.CBMC_VIEWER_VERSION }}" == "" ]; then
52 echo "You must specify a CBMC viewer version (e.g. 'latest' or '3.6')"
53 should_exit=true
54 fi
55 if [ "${{ env.LITANI_VERSION }}" == "" ]; then
56 echo "You must specify a Litani version (e.g. 'latest' or '1.27.0')"
57 should_exit=true
58 fi
59 if [[ "$should_exit" == true ]]; then exit 1; fi
60 - name: Install latest CBMC
61 if: ${{ env.CBMC_VERSION == 'latest' }}
62 shell: bash
63 run: |
64 # Search within 5 most recent releases for latest available package
65 CBMC_REL="https://api.github.com/repos/diffblue/cbmc/releases?page=1&per_page=5"
66 CBMC_DEB=$(curl -s $CBMC_REL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq -r '.[].assets[].browser_download_url' | grep -e 'ubuntu-20.04' | head -n 1)
67 CBMC_ARTIFACT_NAME=$(basename $CBMC_DEB)
68 curl -o $CBMC_ARTIFACT_NAME -L $CBMC_DEB
69 sudo dpkg -i $CBMC_ARTIFACT_NAME
70 rm ./$CBMC_ARTIFACT_NAME
71 - name: Install CBMC ${{ env.CBMC_VERSION }}
72 if: ${{ env.CBMC_VERSION != 'latest' }}
73 shell: bash
74 run: |
75 curl -o cbmc.deb -L \
76 https://github.com/diffblue/cbmc/releases/download/cbmc-${{ env.CBMC_VERSION }}/ubuntu-20.04-cbmc-${{ env.CBMC_VERSION }}-Linux.deb
77 sudo dpkg -i ./cbmc.deb
78 rm ./cbmc.deb
79 - name: Install latest CBMC viewer
80 if: ${{ env.CBMC_VIEWER_VERSION == 'latest' }}
81 shell: bash
82 run: |
83 CBMC_VIEWER_REL="https://api.github.com/repos/model-checking/cbmc-viewer/releases/latest"
84 CBMC_VIEWER_VERSION=$(curl -s $CBMC_VIEWER_REL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq -r .name | sed 's/viewer-//')
85 pip3 install cbmc-viewer==$CBMC_VIEWER_VERSION
86 - name: Install CBMC viewer ${{ env.CBMC_VIEWER_VERSION }}
87 if: ${{ env.CBMC_VIEWER_VERSION != 'latest' }}
88 shell: bash
89 run: |
90 sudo apt-get update
91 sudo apt-get install --no-install-recommends --yes \
92 build-essential universal-ctags
93 pip3 install cbmc-viewer==${{ env.CBMC_VIEWER_VERSION }}
94 - name: Install latest Litani
95 if: ${{ env.LITANI_VERSION == 'latest' }}
96 shell: bash
97 run: |
98 # Search within 5 most recent releases for latest available package
99 LITANI_REL="https://api.github.com/repos/awslabs/aws-build-accumulator/releases?page=1&per_page=5"
100 LITANI_DEB=$(curl -s $LITANI_REL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq -r '.[].assets[0].browser_download_url' | head -n 1)
101 DBN_PKG_FILENAME=$(basename $LITANI_DEB)
102 curl -L $LITANI_DEB -o $DBN_PKG_FILENAME
103 sudo apt-get update
104 sudo apt-get install --no-install-recommends --yes ./$DBN_PKG_FILENAME
105 rm ./$DBN_PKG_FILENAME
106 - name: Install Litani ${{ env.LITANI_VERSION }}
107 if: ${{ env.LITANI_VERSION != 'latest' }}
108 shell: bash
109 run: |
110 curl -o litani.deb -L \
111 https://github.com/awslabs/aws-build-accumulator/releases/download/${{ env.LITANI_VERSION }}/litani-${{ env.LITANI_VERSION }}.deb
112 sudo apt-get update
113 sudo apt-get install --no-install-recommends --yes ./litani.deb
114 rm ./litani.deb
115 - name: Install ${{ env.KISSAT_TAG }} kissat
116 if: ${{ env.KISSAT_TAG != '' }}
117 shell: bash
118 run: |
119 if ${{ env.KISSAT_TAG == 'latest' }}
120 then
121 KISSAT_REL="https://api.github.com/repos/arminbiere/kissat/releases/latest"
122 KISSAT_TAG_NAME=$(curl -s $KISSAT_REL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq -r '.tag_name')
123 else
124 KISSAT_TAG_NAME=${{ env.KISSAT_TAG }}
125 fi
126 echo "Installing kissat $KISSAT_TAG_NAME"
127 git clone https://github.com/arminbiere/kissat.git \
128 && cd kissat \
129 && git checkout $KISSAT_TAG_NAME \
130 && ./configure \
131 && cd build \
132 && make -j;
133 echo "$(pwd)" >> $GITHUB_PATH
134 - name: Install ${{ env.CADICAL_TAG }} cadical
135 if: ${{ env.CADICAL_TAG != '' }}
136 shell: bash
137 run: |
138 if ${{ env.CADICAL_TAG == 'latest' }}
139 then
140 CADICAL_REL="https://api.github.com/repos/arminbiere/cadical/releases/latest"
141 CADICAL_TAG_NAME=$(curl -s $CADICAL_REL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq -r '.tag_name')
142 else
143 CADICAL_TAG_NAME=${{ env.CADICAL_TAG }}
144 fi
145 echo "Installing cadical $CADICAL_TAG_NAME"
146 git clone https://github.com/arminbiere/cadical.git \
147 && cd cadical \
148 && git checkout $CADICAL_TAG_NAME \
149 && ./configure \
150 && cd build \
151 && make -j;
152 echo "$(pwd)" >> $GITHUB_PATH
153 - name: Run CBMC proofs
154 shell: bash
155 env:
156 EXTERNAL_SAT_SOLVER: kissat
157 working-directory: ${{ env.PROOFS_DIR }}
158 run: ${{ env.RUN_CBMC_PROOFS_COMMAND }}
159 - name: Check repository visibility
160 shell: bash
161 run: |
162 VIZ="${{ fromJson(toJson(github.event.repository)).visibility }}";
163 echo "REPO_VISIBILITY=${VIZ}" | tee -a "${GITHUB_ENV}";
164 - name: Set name for zip artifact with CBMC proof results
165 id: artifact
166 if: ${{ env.REPO_VISIBILITY == 'public' }}
167 run: |
168 echo "name=cbmc_proof_results_${{ fromJson(toJson(github.event.repository)).name }}_$(date +%Y_%m_%d_%H_%M_%S)" >> $GITHUB_OUTPUT
169 - name: Create zip artifact with CBMC proof results
170 if: ${{ env.REPO_VISIBILITY == 'public' }}
171 shell: bash
172 run: |
173 FINAL_REPORT_DIR=$PROOFS_DIR/output/latest/html
174 pushd $FINAL_REPORT_DIR \
175 && zip -r ${{ steps.artifact.outputs.name }}.zip . \
176 && popd \
177 && mv $FINAL_REPORT_DIR/${{ steps.artifact.outputs.name }}.zip .
178 - name: Upload zip artifact of CBMC proof results to GitHub Actions
179 if: ${{ env.REPO_VISIBILITY == 'public' }}
180 uses: actions/upload-artifact@v4
181 with:
182 name: ${{ steps.artifact.outputs.name }}
183 path: ${{ steps.artifact.outputs.name }}.zip
184 - name: CBMC proof results
185 shell: bash
186 run: |
187 python3 ${{ env.PROOFS_DIR }}/lib/summarize.py \
188 --run-file ${{ env.PROOFS_DIR }}/output/latest/html/run.json