Debian Codegraph @

.github/workflows/abi-compliance-check.yml

raw
1 name: ABI Compliance Check
2
3 on:
4 pull_request:
5 branches:
6 - amd-staging
7 - release/rocm-rel-*
8 paths:
9 - 'include/amd_smi/amdsmi.h'
10 push:
11 branches:
12 - amd-staging
13 - release/rocm-rel-*
14 paths:
15 - 'include/amd_smi/amdsmi.h'
16 workflow_dispatch:
17
18 permissions:
19 contents: read
20 pull-requests: write
21
22 jobs:
23 major_abi_check:
24 name: Major ABI Compliance Check
25 runs-on: AMD-ROCm-Internal-dev1
26 steps:
27 - name: Setup Environment
28 run: |
29 sudo rm -rf $GITHUB_WORKSPACE/* || true
30 sudo rm -rf $GITHUB_WORKSPACE/.[!.]* || true
31 sudo apt-get update -qq
32 sudo apt-get install -y -qq perl build-essential git universal-ctags
33 git clone https://github.com/lvc/abi-compliance-checker.git
34 cd abi-compliance-checker
35 sudo make install
36 abi-compliance-checker --version
37
38 - name: Checkout current code (new version)
39 uses: actions/checkout@v4
40 with:
41 fetch-depth: 0
42 ref: ${{ github.event.pull_request.head.sha || github.sha }}
43
44 - name: Fetch base branch for PR
45 if: github.event_name == 'pull_request'
46 run: |
47 echo "Fetching base branch: ${{ github.base_ref }}"
48 git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
49 git branch -a
50
51 - name: Prepare amdsmi.h files for comparison
52 id: prepare_files
53 run: |
54 echo "Preparing amdsmi.h files..."
55 echo "abi_exit_code=1" > $GITHUB_WORKSPACE/major_abi_status.txt
56
57 if [ -f include/amd_smi/amdsmi.h ]; then
58 cp include/amd_smi/amdsmi.h amdsmi_new.h
59 echo "Copied current amdsmi.h to amdsmi_new.h"
60 else
61 echo "::error::New amdsmi.h (include/amd_smi/amdsmi.h) not found in current checkout."
62 touch amdsmi_new.h
63 exit 0
64 fi
65
66 OLD_VERSION_REF=""
67 V1_NAME_SUFFIX=""
68 if [[ "${{ github.event_name }}" == "pull_request" ]]; then
69 OLD_VERSION_REF="${{ github.base_ref }}"
70 V1_NAME_SUFFIX="base_${{ github.base_ref }}"
71 echo "Event is Pull Request. Old version source is base branch: ${OLD_VERSION_REF}"
72 elif [[ "${{ github.event_name }}" == "push" ]]; then
73 if [[ "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]]; then
74 OLD_VERSION_REF="${{ github.event.before }}"
75 V1_NAME_SUFFIX="before_$(echo ${{ github.event.before }} | cut -c1-7)"
76 echo "Event is Push. Old version source is commit before push: ${OLD_VERSION_REF}"
77 else
78 echo "Push event is for a new branch or forced push. Cannot determine 'old' version."
79 touch amdsmi_old.h
80 echo "Created dummy amdsmi_old.h. Assuming no ABI breakage as no baseline."
81 echo "abi_exit_code=0" > $GITHUB_WORKSPACE/major_abi_status.txt
82 echo "skip_check=true" >> $GITHUB_OUTPUT
83 exit 0
84 fi
85 else
86 echo "::warning::Unsupported event type: ${{ github.event_name }}. Cannot determine old version."
87 touch amdsmi_old.h
88 echo "abi_exit_code=0" > $GITHUB_WORKSPACE/major_abi_status.txt
89 echo "skip_check=true" >> $GITHUB_OUTPUT
90 exit 0
91 fi
92
93 echo "Fetching amdsmi.h from ref: $OLD_VERSION_REF (as amdsmi_old.h)"
94 git show $OLD_VERSION_REF:include/amd_smi/amdsmi.h > amdsmi_old.h 2>/dev/null
95 if [ $? -ne 0 ] || [ ! -s amdsmi_old.h ]; then
96 echo "::warning::Failed to fetch 'include/amd_smi/amdsmi.h' from ref '$OLD_VERSION_REF' or file is empty/missing."
97 echo "Proceeding with an empty amdsmi_old.h. This may result in all symbols reported as 'added'."
98 echo -n "" > amdsmi_old.h
99 if [ ! -s amdsmi_new.h ]; then
100 echo "abi_exit_code=0" > $GITHUB_WORKSPACE/major_abi_status.txt
101 fi
102 else
103 echo "Successfully fetched amdsmi.h from $OLD_VERSION_REF to amdsmi_old.h"
104 fi
105 echo "v1_name_suffix=${V1_NAME_SUFFIX}" >> $GITHUB_OUTPUT
106 echo "skip_check=false" >> $GITHUB_OUTPUT
107
108 - name: Run Major ABI Compliance Check
109 if: steps.prepare_files.outputs.skip_check == 'false'
110 run: |
111 V1_NAME_SUFFIX_CLEAN=$(echo "${{ steps.prepare_files.outputs.v1_name_suffix }}" | tr '/' '-')
112 V2_NAME_CLEAN=$(echo "${{ github.ref_name || github.head_ref }}" | tr '/' '-')
113
114 echo "Comparing $V1_NAME_SUFFIX_CLEAN (old) with $V2_NAME_CLEAN (new) for Major ABI Check"
115 abi-compliance-checker -lib amdsmi -old amdsmi_old.h -new amdsmi_new.h -v1 "$V1_NAME_SUFFIX_CLEAN" -v2 "$V2_NAME_CLEAN" -report-path major-abi-report.html && echo "abi_exit_code=0" > $GITHUB_WORKSPACE/major_abi_status.txt
116 continue-on-error: true
117
118 - name: Display ABI Check Logs (Major)
119 if: always() && steps.prepare_files.outputs.skip_check == 'false'
120 run: |
121 echo "Displaying Major ABI compliance check logs (if any)"
122 find logs -type f -name "*.txt" -exec echo "--- {} ---" \; -exec cat {} \; || echo "No .txt logs found in logs/ directory."
123
124 - name: Label PR on Major ABI Breakage
125 if: always() && github.event_name == 'pull_request'
126 run: |
127 source $GITHUB_WORKSPACE/major_abi_status.txt
128 if [ "$abi_exit_code" -ne 0 ]; then
129 echo "Major ABI check failed, adding 'MAJOR ABI BREAKAGE' label to PR #${{ github.event.pull_request.number }}"
130 gh pr edit ${{ github.event.pull_request.number }} --add-label "MAJOR ABI BREAKAGE"
131 fi
132 env:
133 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
134
135 - name: Upload Major ABI Report
136 if: always()
137 uses: actions/upload-artifact@v4
138 with:
139 name: major-abi-report
140 path: major-abi-report.html
141 if-no-files-found: ignore
142
143 - name: Report Major ABI Check Results
144 if: always()
145 run: |
146 echo "Checking Major ABI check exit code..."
147 source $GITHUB_WORKSPACE/major_abi_status.txt
148 echo "Major ABI check exit code: $abi_exit_code"
149 if [ "$abi_exit_code" -ne 0 ]; then
150 echo "::warning::⚠️ MAJOR ABI BREAKAGE FOUND ⚠️ CHECK \"Run Major ABI Compliance Check\" LOGS OR THE major-abi-report ARTIFACT FOR DETAILS."
151 else
152 echo "✅ Major ABI check succeeded."
153 fi
154
155 minor_abi_check:
156 name: Minor ABI Compliance Check
157 runs-on: AMD-ROCm-Internal-dev1
158 steps:
159 - name: Setup Environment
160 run: |
161 sudo rm -rf $GITHUB_WORKSPACE/* || true
162 sudo rm -rf $GITHUB_WORKSPACE/.[!.]* || true
163 sudo apt-get update -qq
164 sudo apt-get install -y -qq perl build-essential git universal-ctags
165 git clone https://github.com/lvc/abi-compliance-checker.git
166 cd abi-compliance-checker
167 sudo make install
168 abi-compliance-checker --version
169
170 - name: Checkout current code (new version)
171 uses: actions/checkout@v4
172 with:
173 fetch-depth: 0
174 ref: ${{ github.event.pull_request.head.sha || github.sha }}
175
176 - name: Fetch base branch for PR
177 if: github.event_name == 'pull_request'
178 run: |
179 echo "Fetching base branch: ${{ github.base_ref }}"
180 git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
181 git branch -a
182
183 - name: Prepare amdsmi.h files for comparison
184 id: prepare_files_minor
185 run: |
186 echo "Preparing amdsmi.h files for Minor check..."
187 echo "abi_exit_code=1" > $GITHUB_WORKSPACE/minor_abi_status.txt
188
189 if [ -f include/amd_smi/amdsmi.h ]; then
190 cp include/amd_smi/amdsmi.h amdsmi_new.h
191 echo "Copied current amdsmi.h to amdsmi_new.h for Minor check"
192 else
193 echo "::error::New amdsmi.h (include/amd_smi/amdsmi.h) not found in current checkout for Minor check."
194 touch amdsmi_new.h
195 exit 0
196 fi
197
198 OLD_VERSION_REF_MINOR=""
199 V1_NAME_SUFFIX_MINOR=""
200 if [[ "${{ github.event_name }}" == "pull_request" ]]; then
201 OLD_VERSION_REF_MINOR="${{ github.base_ref }}"
202 V1_NAME_SUFFIX_MINOR="base_${{ github.base_ref }}"
203 elif [[ "${{ github.event_name }}" == "push" ]]; then
204 if [[ "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]]; then
205 OLD_VERSION_REF_MINOR="${{ github.event.before }}"
206 V1_NAME_SUFFIX_MINOR="before_$(echo ${{ github.event.before }} | cut -c1-7)"
207 else
208 echo "Push event is for a new branch (Minor check). Assuming no ABI changes as no baseline."
209 touch amdsmi_old.h
210 echo "abi_exit_code=0" > $GITHUB_WORKSPACE/minor_abi_status.txt
211 echo "skip_check_minor=true" >> $GITHUB_OUTPUT
212 exit 0
213 fi
214 else
215 echo "::warning::Unsupported event type for Minor ABI check: ${{ github.event_name }}."
216 touch amdsmi_old.h
217 echo "abi_exit_code=0" > $GITHUB_WORKSPACE/minor_abi_status.txt
218 echo "skip_check_minor=true" >> $GITHUB_OUTPUT
219 exit 0
220 fi
221
222 echo "Fetching amdsmi.h from ref: $OLD_VERSION_REF_MINOR (as amdsmi_old.h) for Minor check"
223 git show $OLD_VERSION_REF_MINOR:include/amd_smi/amdsmi.h > amdsmi_old.h 2>/dev/null
224 if [ $? -ne 0 ] || [ ! -s amdsmi_old.h ]; then
225 echo "::warning::Failed to fetch 'include/amd_smi/amdsmi.h' from ref '$OLD_VERSION_REF_MINOR' or file is empty/missing for Minor check."
226 echo "Proceeding with an empty amdsmi_old.h for Minor check."
227 echo -n "" > amdsmi_old.h
228 if [ ! -s amdsmi_new.h ]; then
229 echo "abi_exit_code=0" > $GITHUB_WORKSPACE/minor_abi_status.txt
230 fi
231 else
232 echo "Successfully fetched amdsmi.h from $OLD_VERSION_REF_MINOR to amdsmi_old.h for Minor check"
233 fi
234 echo "v1_name_suffix_minor=${V1_NAME_SUFFIX_MINOR}" >> $GITHUB_OUTPUT
235 echo "skip_check_minor=false" >> $GITHUB_OUTPUT
236
237 - name: Run Minor ABI Compliance Check (Strict)
238 if: steps.prepare_files_minor.outputs.skip_check_minor == 'false'
239 run: |
240 V1_NAME_SUFFIX_CLEAN=$(echo "${{ steps.prepare_files_minor.outputs.v1_name_suffix_minor }}" | tr '/' '-')
241 V2_NAME_CLEAN=$(echo "${{ github.ref_name || github.head_ref }}" | tr '/' '-')
242 COMPARE_MSG="$V1_NAME_SUFFIX_CLEAN vs $V2_NAME_CLEAN"
243
244 echo "Comparing $COMPARE_MSG for Minor ABI Check (Strict)"
245
246 abi-compliance-checker -lib amdsmi -old amdsmi_old.h -new amdsmi_new.h -v1 "$V1_NAME_SUFFIX_CLEAN" -v2 "$V2_NAME_CLEAN" -report-path minor-abi-report.html -strict || {
247 ACC_EXIT_CODE=$?
248 echo "abi-compliance-checker -strict failed with exit code $ACC_EXIT_CODE."
249 echo "abi_exit_code=$ACC_EXIT_CODE" > $GITHUB_WORKSPACE/minor_abi_status.txt
250 }
251
252 current_abi_status=$(cat $GITHUB_WORKSPACE/minor_abi_status.txt)
253 current_exit_code=${current_abi_status#*=}
254
255 if [ "$current_exit_code" -eq 0 ] && [ -f minor-abi-report.html ]; then
256 echo "ACC strict check passed. Parsing HTML report for any changes..."
257 CHANGED=0
258 if grep -q "Added Symbols.*[1-9]" minor-abi-report.html; then CHANGED=1; echo "::warning::STRICT ABI: Found added symbols"; fi
259 if grep -q "Removed Symbols.*[1-9]" minor-abi-report.html; then CHANGED=1; echo "::warning::STRICT ABI: Found removed symbols"; fi
260 if grep -q "Problems with.*Data Types.*[1-9]" minor-abi-report.html; then CHANGED=1; echo "::warning::STRICT ABI: Found problems with data types"; fi
261 if grep -q "Problems with.*Symbols.*[1-9]" minor-abi-report.html; then CHANGED=1; echo "::warning::STRICT ABI: Found problems with symbols"; fi
262 if grep -q "Problems with.*Constants.*[1-9]" minor-abi-report.html; then CHANGED=1; echo "::warning::STRICT ABI: Found problems with constants"; fi
263
264 if [ "$CHANGED" -eq 1 ]; then
265 echo "::error::STRICT ABI CHECK FAILED: Found changes in ABI report comparing $COMPARE_MSG"
266 echo "abi_exit_code=1" > $GITHUB_WORKSPACE/minor_abi_status.txt
267 else
268 echo "No strict ABI changes found in HTML report."
269 echo "abi_exit_code=0" > $GITHUB_WORKSPACE/minor_abi_status.txt
270 fi
271 elif [ ! -f minor-abi-report.html ] && [ "$current_exit_code" -eq 0 ]; then
272 echo "::warning::Minor ABI report (minor-abi-report.html) not found, but ACC reported success. Assuming no changes."
273 echo "abi_exit_code=0" > $GITHUB_WORKSPACE/minor_abi_status.txt
274 elif [ "$current_exit_code" -ne 0 ]; then
275 echo "ACC strict check already indicated failure (exit code $current_exit_code). HTML parsing for further changes skipped or confirmed failure."
276 fi
277 continue-on-error: true
278
279 - name: Display ABI Check Logs (Minor)
280 if: always() && steps.prepare_files_minor.outputs.skip_check_minor == 'false'
281 run: |
282 echo "Displaying Minor ABI compliance check logs (if any)"
283 find logs -type f -name "*.txt" -exec echo "--- {} ---" \; -exec cat {} \; || echo "No .txt logs found in logs/ directory."
284
285 - name: Label PR on Minor ABI Breakage
286 if: always() && github.event_name == 'pull_request'
287 run: |
288 source $GITHUB_WORKSPACE/minor_abi_status.txt
289 if [ "$abi_exit_code" -ne 0 ]; then
290 echo "Minor ABI check failed, adding 'MINOR ABI BREAKAGE' label to PR #${{ github.event.pull_request.number }}"
291 gh pr edit ${{ github.event.pull_request.number }} --add-label "MINOR ABI BREAKAGE"
292 fi
293 env:
294 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
295
296 - name: Upload Minor ABI Report
297 if: always()
298 uses: actions/upload-artifact@v4
299 with:
300 name: minor-abi-report
301 path: minor-abi-report.html
302 if-no-files-found: ignore
303
304 - name: Report Minor ABI Check Results
305 if: always()
306 run: |
307 echo "Checking Minor ABI check exit code..."
308 source $GITHUB_WORKSPACE/minor_abi_status.txt
309 echo "Minor ABI check exit code: $abi_exit_code"
310 if [ "$abi_exit_code" -ne 0 ]; then
311 echo "::warning::⚠️ MINOR ABI CHANGES FOUND (STRICT CHECK) ⚠️ CHECK \"Run Minor ABI Compliance Check (Strict)\" LOGS OR THE minor-abi-report ARTIFACT FOR DETAILS."
312 else
313 echo "✅ Minor ABI check (Strict) succeeded or found no changes."
314 fi