[IRBuilder] Refactor FMF interface (#121657)
[llvm-project.git] / .github / workflows / libclang-abi-tests.yml
blob9e839ff49e28357f02722877a4a56d52033115a4
1 name: libclang ABI Tests
3 permissions:
4   contents: read
6 on:
7   workflow_dispatch:
8   push:
9     branches:
10       - 'release/**'
11     paths:
12       - 'clang/**'
13       - '.github/workflows/libclang-abi-tests.yml'
14   pull_request:
15     branches:
16       - 'release/**'
17     paths:
18       - 'clang/**'
19       - '.github/workflows/libclang-abi-tests.yml'
21 concurrency:
22   # Skip intermediate builds: always.
23   # Cancel intermediate builds: only if it is a pull request build.
24   group: ${{ github.workflow }}-${{ github.ref }}
25   cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
27 jobs:
28   abi-dump-setup:
29     if: github.repository_owner == 'llvm'
30     runs-on: ubuntu-latest
31     outputs:
32       BASELINE_REF: ${{ steps.vars.outputs.BASELINE_REF }}
33       ABI_HEADERS: ${{ steps.vars.outputs.ABI_HEADERS }}
34       ABI_LIBS: ${{ steps.vars.outputs.ABI_LIBS }}
35       BASELINE_VERSION_MAJOR: ${{ steps.vars.outputs.BASELINE_VERSION_MAJOR }}
36       LLVM_VERSION_MAJOR: ${{ steps.version.outputs.major }}
37       LLVM_VERSION_MINOR: ${{ steps.version.outputs.minor }}
38       LLVM_VERSION_PATCH: ${{ steps.version.outputs.patch }}
39     steps:
40       - name: Checkout source
41         uses: actions/checkout@v4
42         with:
43           fetch-depth: 250
45       - name: Get LLVM version
46         id: version
47         uses: ./.github/workflows/get-llvm-version
49       - name: Setup Variables
50         id: vars
51         run: |
52           remote_repo='https://github.com/llvm/llvm-project'
53           if [ ${{ steps.version.outputs.patch }} -eq 0 ]; then
54             major_version=$(( ${{ steps.version.outputs.major }} - 1))
55             baseline_ref="llvmorg-$major_version.1.0"
57             # If there is a minor release, we want to use that as the base line.
58             minor_ref=$(git ls-remote --refs -t "$remote_repo" llvmorg-"$major_version".[1-9].[0-9] | tail -n1 | grep -o 'llvmorg-.\+' || true)
59             if [ -n "$minor_ref" ]; then
60                baseline_ref="$minor_ref"
61             else
62               # Check if we have a release candidate
63               rc_ref=$(git ls-remote --refs -t "$remote_repo" llvmorg-"$major_version".[1-9].[0-9]-rc* | tail -n1 | grep -o 'llvmorg-.\+' || true)
64               if [ -n "$rc_ref" ]; then
65                 baseline_ref="$rc_ref"
66               fi
67             fi
68             {
69               echo "BASELINE_VERSION_MAJOR=$major_version"
70               echo "BASELINE_REF=$baseline_ref"
71               echo "ABI_HEADERS=clang-c"
72               echo "ABI_LIBS=libclang.so"
73             } >> "$GITHUB_OUTPUT"
74           else
75             {
76               echo "BASELINE_VERSION_MAJOR=${{ steps.version.outputs.major }}"
77               echo "BASELINE_REF=llvmorg-${{ steps.version.outputs.major }}.1.0"
78               echo "ABI_HEADERS=."
79               echo "ABI_LIBS=libclang.so libclang-cpp.so"
80             } >> "$GITHUB_OUTPUT"
81           fi
83   abi-dump:
84     if: github.repository_owner == 'llvm'
85     needs: abi-dump-setup
86     runs-on: ubuntu-latest
87     strategy:
88       matrix:
89         name:
90           - build-baseline
91           - build-latest
92         include:
93           - name: build-baseline
94             llvm_version_major: ${{ needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}
95             ref: ${{ needs.abi-dump-setup.outputs.BASELINE_REF }}
96             repo: llvm/llvm-project
97           - name: build-latest
98             llvm_version_major: ${{ needs.abi-dump-setup.outputs.LLVM_VERSION_MAJOR }}
99             ref: ${{ github.sha }}
100             repo: ${{ github.repository }}
101     steps:
102       - name: Install Ninja
103         uses: llvm/actions/install-ninja@main
104       - name: Install abi-compliance-checker
105         run: |
106           sudo apt-get install abi-dumper autoconf pkg-config
107       - name: Install universal-ctags
108         run: |
109           git clone https://github.com/universal-ctags/ctags.git
110           cd ctags
111           ./autogen.sh
112           ./configure
113           sudo make install
114       - name: Download source code
115         uses: llvm/actions/get-llvm-project-src@main
116         with:
117           ref: ${{ matrix.ref }}
118           repo: ${{ matrix.repo }}
119       - name: Configure
120         run: |
121           mkdir install
122           cmake -B build -S llvm -G Ninja -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Debug -DLLVM_TARGETS_TO_BUILD="" -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_C_FLAGS_DEBUG="-g1 -Og" -DCMAKE_CXX_FLAGS_DEBUG="-g1 -Og" -DCMAKE_INSTALL_PREFIX="$(pwd)"/install llvm
123       - name: Build
124         run: ninja -C build/ ${{ needs.abi-dump-setup.outputs.ABI_LIBS }} install-clang-headers
125       - name: Dump ABI
126         run: |
127           parallel abi-dumper -lver ${{ matrix.ref }} -skip-cxx -public-headers ./install/include/${{ needs.abi-dump-setup.outputs.ABI_HEADERS }} -o {}-${{ matrix.ref }}.abi ./build/lib/{} ::: ${{ needs.abi-dump-setup.outputs.ABI_LIBS }}
128           for lib in ${{ needs.abi-dump-setup.outputs.ABI_LIBS }}; do
129             # Remove symbol versioning from dumps, so we can compare across major versions.
130             sed -i 's/LLVM_[0-9]\+/LLVM_NOVERSION/' $lib-${{ matrix.ref }}.abi
131           done
132       - name: Upload ABI file
133         uses: actions/upload-artifact@v3
134         with:
135           name: ${{ matrix.name }}
136           path: '*${{ matrix.ref }}.abi'
138   abi-compare:
139     if: github.repository_owner == 'llvm'
140     runs-on: ubuntu-latest
141     needs:
142       - abi-dump-setup
143       - abi-dump
144     steps:
145       - name: Download baseline
146         uses: actions/download-artifact@v3
147         with:
148           name: build-baseline
149           path: build-baseline
150       - name: Download latest
151         uses: actions/download-artifact@v3
152         with:
153           name: build-latest
154           path: build-latest
156       - name: Install abi-compliance-checker
157         run: sudo apt-get install abi-compliance-checker
158       - name: Compare ABI
159         run: |
160           for lib in ${{ needs.abi-dump-setup.outputs.ABI_LIBS }}; do
161             abi-compliance-checker -lib $lib -old build-baseline/$lib*.abi -new build-latest/$lib*.abi
162           done
163       - name: Upload ABI Comparison
164         if: always()
165         uses: actions/upload-artifact@v3
166         with:
167           name: compat-report-${{ github.sha }}
168           path: compat_reports/