2 #===----------------------------------------------------------------------===##
4 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 # See https://llvm.org/LICENSE.txt for license information.
6 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 #===----------------------------------------------------------------------===##
11 # This file generates a Buildkite pipeline that triggers the various CI jobs for
12 # the LLVM project during pre-commit CI.
14 # See https://buildkite.com/docs/agent/v3/cli-pipeline#pipeline-format.
16 # As this outputs a yaml file, it's possible to log messages to stderr or
23 # Environment variables script works with:
26 : ${BUILDKITE_PULL_REQUEST_BASE_BRANCH:=}
27 : ${BUILDKITE_COMMIT:=}
28 : ${BUILDKITE_BRANCH:=}
29 # Fetch origin to have an up to date merge base for the diff.
31 # List of files affected by this commit
32 : ${MODIFIED_FILES:=$(git diff --name-only origin/${BUILDKITE_PULL_REQUEST_BASE_BRANCH}...HEAD)}
33 # Filter rules for generic windows tests
34 : ${WINDOWS_AGENTS:='{"queue": "windows"}'}
35 # Filter rules for generic linux tests
36 : ${LINUX_AGENTS:='{"queue": "linux"}'}
38 reviewID
="$(git log --format=%B -n 1 | sed -nE 's/^Review-ID:[[:space:]]*(.+)$/\1/p')"
39 if [[ "${reviewID}" != "" ]]; then
40 buildMessage
="https://llvm.org/${reviewID}"
42 buildMessage
="Push to branch ${BUILDKITE_BRANCH}"
49 echo "Files modified:" >&2
50 echo "$MODIFIED_FILES" >&2
51 modified_dirs
=$
(echo "$MODIFIED_FILES" | cut
-d'/' -f1 |
sort -u)
52 echo "Directories modified:" >&2
53 echo "$modified_dirs" >&2
55 function compute-projects-to-test
() {
59 for project
in ${projects}; do
63 for p
in bolt cross-project-tests
; do
68 for p
in bolt clang clang-tools-extra lld lldb mlir polly
; do
71 # Flang is not stable in Windows CI at the moment
72 if [[ $isForWindows == 0 ]]; then
77 # lldb is temporarily removed to alleviate Linux pre-commit CI waiting times
78 for p
in clang-tools-extra compiler-rt cross-project-tests
; do
86 # Flang is not stable in Windows CI at the moment
87 if [[ $isForWindows == 0 ]]; then
98 function compute-runtimes-to-test
() {
100 for project
in ${projects}; do
103 for p
in libcxx libcxxabi libunwind
; do
114 function add-dependencies
() {
116 for project
in ${projects}; do
120 for p
in clang lld llvm
; do
125 for p
in lld clang
; do
130 for p
in llvm clang
; do
134 compiler-rt|libc|openmp
)
138 for p
in llvm clang
; do
152 function exclude-linux
() {
154 for project
in ${projects}; do
156 cross-project-tests
) ;; # tests failing
157 openmp
) ;; # https://github.com/google/llvm-premerge-checks/issues/410
165 function exclude-windows
() {
167 for project
in ${projects}; do
169 cross-project-tests
) ;; # tests failing
170 compiler-rt
) ;; # tests taking too long
171 openmp
) ;; # TODO: having trouble with the Perl installation
172 libc
) ;; # no Windows support
173 lldb
) ;; # custom environment requirements (https://github.com/llvm/llvm-project/pull/94208#issuecomment-2146256857)
174 bolt
) ;; # tests are not supported yet
182 # Prints only projects that are both present in $modified_dirs and the passed
184 function keep-modified-projects
() {
186 for project
in ${projects}; do
187 if echo "$modified_dirs" |
grep -q -E "^${project}$"; then
193 function check-targets
() {
194 # Do not use "check-all" here because if there is "check-all" plus a
195 # project specific target like "check-clang", that project's tests
198 for project
in ${projects}; do
201 echo "check-clang-tools"
204 echo "check-compiler-rt"
207 echo "check-cross-project"
222 # Currently we do not run pstl tests in CI.
225 # Currently there is no testing for libclc.
228 echo "check-${project}"
234 # Project specific pipelines.
236 # If libc++ or one of the runtimes directories changed.
237 if echo "$modified_dirs" |
grep -q -E "^(libcxx|libcxxabi|libunwind|runtimes|cmake)$"; then
239 - trigger: "libcxx-ci"
241 message: "${buildMessage}"
242 commit: "${BUILDKITE_COMMIT}"
243 branch: "${BUILDKITE_BRANCH}"
247 # Generic pipeline for projects that have not defined custom steps.
249 # Individual projects should instead define the pre-commit CI tests that suits their
250 # needs while letting them run on the infrastructure provided by LLVM.
252 # Figure out which projects need to be built on each platform
253 all_projects
="bolt clang clang-tools-extra compiler-rt cross-project-tests flang libc libclc lld lldb llvm mlir openmp polly pstl"
254 modified_projects
="$(keep-modified-projects ${all_projects})"
256 linux_projects_to_test
=$
(exclude-linux $
(compute-projects-to-test
0 ${modified_projects}))
257 linux_check_targets
=$
(check-targets
${linux_projects_to_test} |
sort |
uniq)
258 linux_projects
=$
(add-dependencies
${linux_projects_to_test} |
sort |
uniq)
260 linux_runtimes_to_test
=$
(compute-runtimes-to-test
${linux_projects_to_test})
261 linux_runtime_check_targets
=$
(check-targets
${linux_runtimes_to_test} |
sort |
uniq)
262 linux_runtimes
=$
(echo ${linux_runtimes_to_test} |
sort |
uniq)
264 windows_projects_to_test
=$
(exclude-windows $
(compute-projects-to-test
1 ${modified_projects}))
265 windows_check_targets
=$
(check-targets
${windows_projects_to_test} |
sort |
uniq)
266 windows_projects
=$
(add-dependencies
${windows_projects_to_test} |
sort |
uniq)
268 # Generate the appropriate pipeline
269 if [[ "${linux_projects}" != "" ]]; then
271 - label: ':linux: Linux x64'
275 - 'build/test-results.*.xml'
276 agents: ${LINUX_AGENTS}
279 - exit_status: -1 # Agent was lost
281 - exit_status: 255 # Forced agent shutdown
283 timeout_in_minutes: 120
288 - './.ci/monolithic-linux.sh "$(echo ${linux_projects} | tr ' ' ';')" "$(echo ${linux_check_targets})" "$(echo ${linux_runtimes} | tr ' ' ';')" "$(echo ${linux_runtime_check_targets})"'
292 if [[ "${windows_projects}" != "" ]]; then
294 - label: ':windows: Windows x64'
298 - 'build/test-results.*.xml'
299 agents: ${WINDOWS_AGENTS}
302 - exit_status: -1 # Agent was lost
304 - exit_status: 255 # Forced agent shutdown
306 timeout_in_minutes: 150
312 - 'C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat -arch=amd64 -host_arch=amd64'
313 - 'bash .ci/monolithic-windows.sh "$(echo ${windows_projects} | tr ' ' ';')" "$(echo ${windows_check_targets})"'