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 (each time a Phabricator diff is uploaded).
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"}'}
37 # Service agents, for interacting with Phabricator.
38 : ${SERVICE_AGENTS:='{"queue": "service"}'}
40 reviewID="$(git log --format=%B -n 1 | sed -nE 's
/^Review-ID
:[[:space
:]]*(.
+)$
/\
1/p
')"
41 if [[ "${reviewID}" != "" ]]; then
42 buildMessage="https://llvm.org/${reviewID}"
44 buildMessage="Push to branch ${BUILDKITE_BRANCH}"
51 echo "Files modified:" >&2
52 echo "$MODIFIED_FILES" >&2
53 modified_dirs=$(echo "$MODIFIED_FILES" | cut -d'/' -f1 | sort -u)
54 echo "Directories modified:" >&2
55 echo "$modified_dirs" >&2
57 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 flang lld lldb mlir polly; do
73 for p in clang-tools-extra compiler-rt flang libc lldb openmp cross-project-tests; do
90 function add-dependencies() {
92 for project in ${projects}; do
101 for p in lld clang; do
106 for p in llvm clang; do
110 compiler-rt|libc|openmp)
114 for p in llvm clang; do
128 function exclude-linux() {
130 for project in ${projects}; do
132 cross-project-tests) ;; # tests failing
133 lldb) ;; # tests failing
134 openmp) ;; # https://github.com/google/llvm-premerge-checks/issues/410
142 function exclude-windows() {
144 for project in ${projects}; do
146 cross-project-tests) ;; # tests failing
147 compiler-rt) ;; # tests taking too long
148 openmp) ;; # TODO: having trouble with the Perl installation
149 libc) ;; # no Windows support
150 lldb) ;; # tests failing
151 bolt) ;; # tests are not supported yet
159 # Prints only projects that are both present in $modified_dirs and the passed
161 function keep-modified-projects() {
163 for project in ${projects}; do
164 if echo "$modified_dirs" | grep -q -E "^${project}$"; then
170 function check-targets() {
172 for project in ${projects}; do
175 echo "check-clang-tools"
181 echo "check-cross-project"
184 echo "check-all" # TODO: check-lldb may not include all the LLDB tests?
193 echo "check-${project}"
199 # Project specific pipelines.
201 # If libc++ or one of the runtimes directories changed.
202 if echo "$modified_dirs" | grep -q -E "^(libcxx|libcxxabi|libunwind|runtimes|cmake)$"; then
204 - trigger: "libcxx-ci"
206 message: "${buildMessage}"
207 commit: "${BUILDKITE_COMMIT}"
208 branch: "${BUILDKITE_BRANCH}"
213 if echo "$modified_dirs" | grep -q -E "^(clang)$"; then
215 - trigger: "clang-ci"
217 message: "${buildMessage}"
218 commit: "${BUILDKITE_COMMIT}"
219 branch: "${BUILDKITE_BRANCH}"
223 # Generic pipeline for projects that have not defined custom steps.
225 # Individual projects should instead define the pre-commit CI tests that suits their
226 # needs while letting them run on the infrastructure provided by LLVM.
228 # Figure out which projects need to be built on each platform
229 all_projects="bolt clang-tools-extra compiler-rt cross-project-tests flang libc libclc lld lldb llvm mlir openmp polly pstl"
230 modified_projects="$(keep-modified-projects ${all_projects})"
232 linux_projects_to_test=$(exclude-linux $(compute-projects-to-test ${modified_projects}))
233 linux_check_targets=$(check-targets ${linux_projects_to_test} | sort | uniq)
234 linux_projects=$(add-dependencies ${linux_projects_to_test} | sort | uniq)
236 windows_projects_to_test=$(exclude-windows $(compute-projects-to-test ${modified_projects}))
237 windows_check_targets=$(check-targets ${windows_projects_to_test} | sort | uniq)
238 windows_projects=$(add-dependencies ${windows_projects_to_test} | sort | uniq)
240 # Generate the appropriate pipeline
241 if [[ "${linux_projects}" != "" ]]; then
243 - label: ':linux
: Linux x64
'
247 - 'build
/test-results.xml
'
248 agents: ${LINUX_AGENTS}
251 - exit_status: -1 # Agent was lost
253 - exit_status: 255 # Forced agent shutdown
255 timeout_in_minutes: 120
260 - '.
/.ci
/monolithic-linux.sh
"$(echo ${linux_projects} | tr ' ' ';')" "$(echo ${linux_check_targets})"'
264 if [[ "${windows_projects}" != "" ]]; then
266 - label: ':windows
: Windows x64
'
270 - 'build
/test-results.xml
'
271 agents: ${WINDOWS_AGENTS}
274 - exit_status: -1 # Agent was lost
276 - exit_status: 255 # Forced agent shutdown
278 timeout_in_minutes: 150
284 - 'C
:\\BuildTools
\\Common7
\\Tools
\\VsDevCmd.bat
-arch=amd64
-host_arch=amd64
'
285 - 'bash .ci
/monolithic-windows.sh
"$(echo ${windows_projects} | tr ' ' ';')" "$(echo ${windows_check_targets})"'
289 # If build was triggered from a Phabricator review - send an update back.
290 if [[ -n "${ph_target_phid:-}" ]]; then
292 - continue_on_failure: true
294 - label: ':phabricator
: update build status on Phabricator
'
295 agents: ${SERVICE_AGENTS}
299 - export SRC=\$\${BUILDKITE_BUILD_PATH}/llvm-premerge-checks
301 - git clone --depth 1 https://github.com/google/llvm-premerge-checks.git "\$\${SRC}"
303 - git fetch origin "main":x
305 - echo "llvm-premerge-checks commit"
307 - pip install -q -r \$\${SRC}/scripts/requirements.txt
308 - cd "\$\$BUILDKITE_BUILD_CHECKOUT_PATH"
309 - \$\${SRC}/scripts/summary.py
310 timeout_in_minutes: 10