Debian Codegraph @

crt/s2n/.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.10
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 merge_group:
13 types: [checks_requested]
14 branches: [main]
15
16 # USAGE
17 #
18 # If you need to use different versions for tools like CBMC, modify this file:
19 # .github/workflows/proof_ci_resources/config.yaml
20 #
21 # If you want the CI to use a different GitHub-hosted runner (which must still
22 # be running Ubuntu 24.04), modify the value of this key:
23 # jobs.run_cbmc_proofs.runs-on
24
25 jobs:
26 run_cbmc_proofs:
27 runs-on: cbmc_ubuntu-latest_64-core
28 name: run_cbmc_proofs
29 # The default timeout is 360 minutes
30 timeout-minutes: 60
31 permissions:
32 contents: read
33 id-token: write
34 pull-requests: read
35 steps:
36 - name: Check out repository and submodules recursively
37 uses: actions/checkout@v7
38 with:
39 submodules: 'recursive'
40 - name: Parse config file
41 run: |
42 CONFIG_FILE='.github/workflows/proof_ci_resources/config.yaml'
43 for setting in cadical-tag cbmc-version cbmc-viewer-version kissat-tag litani-version z3-version bitwuzla-version proofs-dir run-cbmc-proofs-command; do
44 VAR=$(echo $setting | tr "[:lower:]" "[:upper:]" | tr - _)
45 echo "${VAR}"=$(yq .$setting $CONFIG_FILE) >> $GITHUB_ENV
46 done
47 - name: Ensure CBMC, CBMC viewer, Litani, Z3, Bitwuzla versions have been specified
48 shell: bash
49 run: |
50 should_exit=false
51 if [ "${{ env.CBMC_VERSION }}" == "" ]; then
52 echo "You must specify a CBMC version (e.g. 'latest' or '5.70.0')"
53 should_exit=true
54 fi
55 if [ "${{ env.CBMC_VIEWER_VERSION }}" == "" ]; then
56 echo "You must specify a CBMC viewer version (e.g. 'latest' or '3.6')"
57 should_exit=true
58 fi
59 if [ "${{ env.LITANI_VERSION }}" == "" ]; then
60 echo "You must specify a Litani version (e.g. 'latest' or '1.27.0')"
61 should_exit=true
62 fi
63 if [ "${{ env.Z3_VERSION }}" == "" ]; then
64 echo "You must specify a Z3 version (e.g. '4.13.0')"
65 should_exit=true
66 fi
67 if [ "${{ env.Z3_VERSION }}" == "latest" ]; then
68 echo "Z3 latest not supported at this time. You must specify an exact Z3 version (e.g. '4.13.0')"
69 should_exit=true
70 fi
71 if [ "${{ env.BITWUZLA_VERSION }}" == "" ]; then
72 echo "You must specify a Bitwuzla version (e.g. '0.5.0')"
73 should_exit=true
74 fi
75 if [ "${{ env.BITWUZLA_VERSION }}" == "latest" ]; then
76 echo "Bitwuzla latest not supported at this time. You must specify an exact version (e.g. '0.5.0')"
77 should_exit=true
78 fi
79 if [[ "$should_exit" == true ]]; then exit 1; fi
80 - name: Install latest CBMC
81 if: ${{ env.CBMC_VERSION == 'latest' }}
82 shell: bash
83 run: |
84 # Search within 5 most recent releases for latest available package
85 CBMC_REL="https://api.github.com/repos/diffblue/cbmc/releases?page=1&per_page=5"
86 CBMC_DEB=$(curl -s $CBMC_REL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq -r '.[]|select(.prerelease|not).assets[].browser_download_url' | grep -e 'ubuntu-24.04-cbmc' | head -n 1)
87 CBMC_ARTIFACT_NAME=$(basename $CBMC_DEB)
88 curl -o $CBMC_ARTIFACT_NAME -L $CBMC_DEB
89 sudo dpkg -i $CBMC_ARTIFACT_NAME
90 rm ./$CBMC_ARTIFACT_NAME
91 - name: Install CBMC ${{ env.CBMC_VERSION }}
92 if: ${{ env.CBMC_VERSION != 'latest' }}
93 shell: bash
94 run: |
95 curl -o cbmc.deb -L \
96 https://github.com/diffblue/cbmc/releases/download/cbmc-${{ env.CBMC_VERSION }}/ubuntu-24.04-cbmc-${{ env.CBMC_VERSION }}-Linux.deb
97 sudo dpkg -i ./cbmc.deb
98 rm ./cbmc.deb
99 - name: Install latest CBMC viewer
100 if: ${{ env.CBMC_VIEWER_VERSION == 'latest' }}
101 shell: bash
102 run: |
103 CBMC_VIEWER_REL="https://api.github.com/repos/model-checking/cbmc-viewer/releases/latest"
104 CBMC_VIEWER_VERSION=$(curl -s $CBMC_VIEWER_REL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq -r .name | sed 's/viewer-//')
105 sudo pip3 install cbmc-viewer==$CBMC_VIEWER_VERSION
106 - name: Install CBMC viewer ${{ env.CBMC_VIEWER_VERSION }}
107 if: ${{ env.CBMC_VIEWER_VERSION != 'latest' }}
108 shell: bash
109 run: |
110 sudo apt-get update
111 sudo apt-get install --no-install-recommends --yes \
112 build-essential universal-ctags
113 sudo pip3 install cbmc-viewer==${{ env.CBMC_VIEWER_VERSION }}
114 - name: Install latest Litani
115 if: ${{ env.LITANI_VERSION == 'latest' }}
116 shell: bash
117 run: |
118 # Search within 5 most recent releases for latest available package
119 LITANI_REL="https://api.github.com/repos/awslabs/aws-build-accumulator/releases?page=1&per_page=5"
120 LITANI_DEB=$(curl -s $LITANI_REL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq -r '.[]|select(.prerelease|not).assets[0].browser_download_url' | head -n 1)
121 DBN_PKG_FILENAME=$(basename $LITANI_DEB)
122 curl -L $LITANI_DEB -o $DBN_PKG_FILENAME
123 sudo apt-get update
124 sudo apt-get install --no-install-recommends --yes ./$DBN_PKG_FILENAME
125 rm ./$DBN_PKG_FILENAME
126 - name: Install Litani ${{ env.LITANI_VERSION }}
127 if: ${{ env.LITANI_VERSION != 'latest' }}
128 shell: bash
129 run: |
130 curl -o litani.deb -L \
131 https://github.com/awslabs/aws-build-accumulator/releases/download/${{ env.LITANI_VERSION }}/litani-${{ env.LITANI_VERSION }}.deb
132 sudo apt-get update
133 sudo apt-get install --no-install-recommends --yes ./litani.deb
134 rm ./litani.deb
135 - name: Install Z3 ${{ env.Z3_VERSION }}
136 if: ${{ env.Z3_VERSION != 'latest' }}
137 shell: bash
138 run: |
139 curl -o z3.zip -L \
140 https://github.com/Z3Prover/z3/releases/download/z3-${{ env.Z3_VERSION }}/z3-${{ env.Z3_VERSION }}-x64-glibc-2.31.zip
141 sudo apt-get install --no-install-recommends --yes unzip
142 unzip z3.zip
143 cd z3-${{ env.Z3_VERSION }}-x64-glibc-2.31/bin \
144 && echo "Adding $(pwd) to PATH for Z3" \
145 && echo "$(pwd)" >> $GITHUB_PATH
146 rm ../../z3.zip
147 - name: Build and Install Bitwuzla ${{ env.BITWUZLA_VERSION }}
148 if: ${{ env.BITWUZLA_VERSION != 'latest' }}
149 shell: bash
150 run: |
151 echo "Installing Bitwuzla dependencies"
152 sudo apt-get update
153 sudo apt-get install --no-install-recommends --yes libgmp-dev cmake
154 sudo pip3 install meson
155 echo "Building Bitwuzla"
156 BITWUZLA_TAG_NAME=${{ env.BITWUZLA_VERSION }}
157 git clone https://github.com/bitwuzla/bitwuzla.git \
158 && cd bitwuzla \
159 && git checkout $BITWUZLA_TAG_NAME \
160 && ./configure.py \
161 && cd build \
162 && ninja;
163 cd src/main \
164 && echo "Adding $(pwd) to PATH for Bitwuzla" \
165 && echo "$(pwd)" >> $GITHUB_PATH
166 - name: Install ${{ env.KISSAT_TAG }} kissat
167 if: ${{ env.KISSAT_TAG != '' }}
168 shell: bash
169 run: |
170 if ${{ env.KISSAT_TAG == 'latest' }}
171 then
172 KISSAT_REL="https://api.github.com/repos/arminbiere/kissat/releases/latest"
173 KISSAT_TAG_NAME=$(curl -s $KISSAT_REL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq -r '.tag_name')
174 else
175 KISSAT_TAG_NAME=${{ env.KISSAT_TAG }}
176 fi
177 echo "Installing kissat $KISSAT_TAG_NAME"
178 git clone https://github.com/arminbiere/kissat.git \
179 && cd kissat \
180 && git checkout $KISSAT_TAG_NAME \
181 && ./configure \
182 && cd build \
183 && make -j;
184 echo "$(pwd)" >> $GITHUB_PATH
185 - name: Install ${{ env.CADICAL_TAG }} cadical
186 if: ${{ env.CADICAL_TAG != '' }}
187 shell: bash
188 run: |
189 if ${{ env.CADICAL_TAG == 'latest' }}
190 then
191 CADICAL_REL="https://api.github.com/repos/arminbiere/cadical/releases/latest"
192 CADICAL_TAG_NAME=$(curl -s $CADICAL_REL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq -r '.tag_name')
193 else
194 CADICAL_TAG_NAME=${{ env.CADICAL_TAG }}
195 fi
196 echo "Installing cadical $CADICAL_TAG_NAME"
197 git clone https://github.com/arminbiere/cadical.git \
198 && cd cadical \
199 && git checkout $CADICAL_TAG_NAME \
200 && ./configure \
201 && cd build \
202 && make -j;
203 echo "$(pwd)" >> $GITHUB_PATH
204 - name: Run CBMC proofs
205 shell: bash
206 env:
207 EXTERNAL_SAT_SOLVER: kissat
208 working-directory: ${{ env.PROOFS_DIR }}
209 run: ${{ env.RUN_CBMC_PROOFS_COMMAND }}
210 - name: Check repository visibility
211 shell: bash
212 run: |
213 VIZ="${{ fromJson(toJson(github.event.repository)).visibility }}";
214 echo "REPO_VISIBILITY=${VIZ}" | tee -a "${GITHUB_ENV}";
215 - name: Set name for zip artifact with CBMC proof results
216 id: artifact
217 if: ${{ env.REPO_VISIBILITY == 'public' }}
218 run: |
219 echo "name=cbmc_proof_results_${{ fromJson(toJson(github.event.repository)).name }}_$(date +%Y_%m_%d_%H_%M_%S)" >> $GITHUB_OUTPUT
220 - name: Create zip artifact with CBMC proof results
221 if: ${{ env.REPO_VISIBILITY == 'public' }}
222 shell: bash
223 run: |
224 FINAL_REPORT_DIR=$PROOFS_DIR/output/latest/html
225 pushd $FINAL_REPORT_DIR \
226 && zip -r ${{ steps.artifact.outputs.name }}.zip . \
227 && popd \
228 && mv $FINAL_REPORT_DIR/${{ steps.artifact.outputs.name }}.zip .
229 - name: Upload zip artifact of CBMC proof results to GitHub Actions
230 if: ${{ env.REPO_VISIBILITY == 'public' }}
231 uses: actions/upload-artifact@v7
232 with:
233 name: ${{ steps.artifact.outputs.name }}
234 path: ${{ steps.artifact.outputs.name }}.zip
235 - name: CBMC proof results
236 shell: bash
237 run: |
238 python3 ${{ env.PROOFS_DIR }}/lib/summarize.py \
239 --run-file ${{ env.PROOFS_DIR }}/output/latest/html/run.json