[NFC][Py Reformat] Reformat python files in llvm
[llvm-project.git] / .github / workflows / llvm-tests.yml
blobb59607647c8fec50397653ac677855bf76e81ad1
1 name: LLVM Tests
3 permissions:
4   contents: read
6 on:
7   workflow_dispatch:
8   push:
9     ignore-forks: true
10     branches:
11       - 'release/**'
12     paths:
13       - 'llvm/**'
14       - '.github/workflows/llvm-tests.yml'
15       - '.github/workflows/llvm-project-tests.yml'
16   pull_request:
17     ignore-forks: true
18     branches:
19       - 'release/**'
20     paths:
21       - 'llvm/**'
22       - '.github/workflows/llvm-tests.yml'
23       - '.github/workflows/llvm-project-tests.yml'
25 concurrency:
26   # Skip intermediate builds: always.
27   # Cancel intermediate builds: only if it is a pull request build.
28   group: ${{ github.workflow }}-${{ github.ref }}
29   cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
31 jobs:
32   check_all:
33     if: github.repository_owner == 'llvm'
34     name: Test llvm,clang,libclc
35     uses: ./.github/workflows/llvm-project-tests.yml
36     with:
37       build_target: check-all
38       projects: clang;libclc
40   # These need to be separate from the check_all job, becuase there is not enough disk
41   # space to build all these projects on Windows.
42   build_lldb:
43     if: github.repository_owner == 'llvm'
44     name: Build lldb
45     uses: ./.github/workflows/llvm-project-tests.yml
46     with:
47       build_target: ''
48       projects: clang;lldb
50   check_lld:
51     if: github.repository_owner == 'llvm'
52     name: Test lld
53     uses: ./.github/workflows/llvm-project-tests.yml
54     with:
55       build_target: check-lld
56       projects: lld
58   abi-dump-setup:
59     if: github.repository_owner == 'llvm'
60     runs-on: ubuntu-latest
61     outputs:
62       BASELINE_REF: ${{ steps.vars.outputs.BASELINE_REF }}
63       ABI_HEADERS: ${{ steps.vars.outputs.ABI_HEADERS }}
64       BASELINE_VERSION_MAJOR: ${{ steps.vars.outputs.BASELINE_VERSION_MAJOR }}
65       LLVM_VERSION_MAJOR: ${{ steps.version.outputs.LLVM_VERSION_MAJOR }}
66       LLVM_VERSION_MINOR: ${{ steps.version.outputs.LLVM_VERSION_MINOR }}
67       LLVM_VERSION_PATCH: ${{ steps.version.outputs.LLVM_VERSION_PATCH }}
68     steps:
69       - name: Checkout source
70         uses: actions/checkout@v3
71         with:
72           fetch-depth: 250
74       - name: Get LLVM version
75         id: version
76         uses: llvm/actions/get-llvm-version@main
78       - name: Setup Variables
79         id: vars
80         run: |
81           if [ ${{ steps.version.outputs.LLVM_VERSION_MINOR }} -ne 0 -o ${{ steps.version.outputs.LLVM_VERSION_PATCH }} -eq 0 ]; then
82             echo "BASELINE_VERSION_MAJOR=$(( ${{ steps.version.outputs.LLVM_VERSION_MAJOR }} - 1))" >> $GITHUB_OUTPUT
83             echo "ABI_HEADERS=llvm-c" >> $GITHUB_OUTPUT
84           else
85             echo "BASELINE_VERSION_MAJOR=${{ steps.version.outputs.LLVM_VERSION_MAJOR }}" >> $GITHUB_OUTPUT
86             echo "ABI_HEADERS=." >> $GITHUB_OUTPUT
87           fi
89   abi-dump:
90     if: github.repository_owner == 'llvm'
91     needs: abi-dump-setup
92     runs-on: ubuntu-latest
93     strategy:
94       matrix:
95         name:
96           - build-baseline
97           - build-latest
98         include:
99           - name: build-baseline
100             llvm_version_major: ${{ needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}
101             ref: llvmorg-${{ needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}.0.0
102             repo: llvm/llvm-project
103           - name: build-latest
104             llvm_version_major: ${{ needs.abi-dump-setup.outputs.LLVM_VERSION_MAJOR }}
105             ref: ${{ github.sha }}
106             repo: ${{ github.repository }}
107     steps:
108       - name: Install Ninja
109         uses: llvm/actions/install-ninja@main
110       - name: Install abi-compliance-checker
111         run: |
112           sudo apt-get install abi-dumper autoconf pkg-config
113       - name: Install universal-ctags
114         run: |
115           git clone https://github.com/universal-ctags/ctags.git
116           cd ctags
117           ./autogen.sh
118           ./configure
119           sudo make install
120       - name: Download source code
121         uses: llvm/actions/get-llvm-project-src@main
122         with:
123           ref: ${{ matrix.ref }}
124           repo: ${{ matrix.repo }}
125       - name: Configure
126         run: |
127           mkdir install
128           cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DLLVM_TARGETS_TO_BUILD="" -DLLVM_BUILD_LLVM_DYLIB=ON -DCMAKE_C_FLAGS_DEBUG="-g1 -Og" -DCMAKE_CXX_FLAGS_DEBUG="-g1 -Og" -DCMAKE_INSTALL_PREFIX=$(pwd)/install llvm
129       - name: Build
130         # Need to run install-LLVM twice to ensure the symlink is installed (this is a bug).
131         run: |
132           ninja -C build install-LLVM
133           ninja -C build install-LLVM
134           ninja -C build install-llvm-headers
135       - name: Dump ABI
136         run: |
137           if [ "${{ needs.abi-dump-setup.outputs.ABI_HEADERS }}" = "llvm-c" ]; then
138             nm ./install/lib/libLLVM.so | awk "/T _LLVM/ || /T LLVM/ { print $3 }" | sort -u | sed -e "s/^_//g" | cut -d ' ' -f 3 > llvm.symbols
139             # Even though the -symbols-list option doesn't seem to filter out the symbols, I believe it speeds up processing, so I'm leaving it in.
140             export EXTRA_ARGS="-symbols-list llvm.symbols"
141           else
142             touch llvm.symbols
143           fi
144           abi-dumper $EXTRA_ARGS -lver ${{ matrix.ref }} -skip-cxx -public-headers ./install/include/${{ needs.abi-dump-setup.outputs.ABI_HEADERS }} -o ${{ matrix.ref }}.abi ./install/lib/libLLVM.so
145           # Remove symbol versioning from dumps, so we can compare across major versions.
146           sed -i 's/LLVM_${{ matrix.llvm_version_major }}/LLVM_NOVERSION/' ${{ matrix.ref }}.abi
147       - name: Upload ABI file
148         uses: actions/upload-artifact@v3
149         with:
150           name: ${{ matrix.name }}
151           path: ${{ matrix.ref }}.abi
153       - name: Upload symbol list file
154         if: matrix.name == 'build-baseline'
155         uses: actions/upload-artifact@v3
156         with:
157           name: symbol-list
158           path: llvm.symbols
160   abi-compare:
161     if: github.repository_owner == 'llvm'
162     runs-on: ubuntu-latest
163     needs:
164       - abi-dump-setup
165       - abi-dump
166     steps:
167       - name: Download baseline
168         uses: actions/download-artifact@v3
169         with:
170           name: build-baseline
171       - name: Download latest
172         uses: actions/download-artifact@v3
173         with:
174           name: build-latest
175       - name: Download symbol list
176         uses: actions/download-artifact@v3
177         with:
178           name: symbol-list
180       - name: Install abi-compliance-checker
181         run: sudo apt-get install abi-compliance-checker
182       - name: Compare ABI
183         run: |
184           if [ -s symbol-list/llvm.symbols ]; then
185             # This option doesn't seem to work with the ABI dumper, so passing it here.
186             export EXTRA_ARGS="-symbols-list symbol-list/llvm.symbols"
187           fi
188           # FIXME: Reading of gzip'd abi files on the GitHub runners stop
189           # working some time in March of 2021, likely due to a change in the
190           # runner's environment.
191           abi-compliance-checker $EXTRA_ARGS -l libLLVM.so -old build-baseline/*.abi -new build-latest/*.abi || test "${{ needs.abi-dump-setup.outputs.ABI_HEADERS }}" = "llvm-c"
192       - name: Upload ABI Comparison
193         if: always()
194         uses: actions/upload-artifact@v3
195         with:
196           name: compat-report-${{ github.sha }}
197           path: compat_reports/