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:
25 # Fetch origin/main to have an up to date merge base for main...HEAD diff.
26 git fetch origin main
:main
27 # List of files affected by this commit
28 : ${MODIFIED_FILES:=$(git diff --name-only main...HEAD)}
29 # Filter rules for generic windows tests
30 : ${WINDOWS_AGENTS:='{"queue": "windows"}'}
31 # Filter rules for generic linux tests
32 : ${LINUX_AGENTS:='{"queue": "linux"}'}
33 # Service agents, for interacting with Phabricator.
34 : ${SERVICE_AGENTS:='{"queue": "service"}'}
36 : ${BUILDKITE_COMMIT:=}
37 : ${BUILDKITE_BRANCH:=}
39 reviewID="$(git log --format=%B -n 1 | sed -nE 's
/^Review-ID
:[[:space
:]]*(.
+)$
/\
1/p
')"
40 if [[ "${reviewID}" != "" ]]; then
41 buildMessage="https://llvm.org/${reviewID}"
43 buildMessage="Push to branch ${BUILDKITE_BRANCH}"
50 echo "Files modified:" >&2
51 echo "$MODIFIED_FILES" >&2
52 modified_dirs=$(echo "$MODIFIED_FILES" | cut -d'/' -f1 | sort -u)
53 echo "Directories modified:" >&2
54 echo "$modified_dirs" >&2
56 function compute-projects-to-test() {
58 for project in ${projects}; do
62 for p in bolt cross-project-tests; do
67 for p in bolt clang clang-tools-extra flang lld lldb mlir polly; do
72 for p in clang-tools-extra compiler-rt flang libc lldb openmp cross-project-tests; do
89 function add-dependencies() {
91 for project in ${projects}; do
100 for p in lld clang; do
105 for p in llvm clang; do
109 compiler-rt|libc|openmp)
113 for p in llvm clang; do
127 function exclude-linux() {
129 for project in ${projects}; do
131 cross-project-tests) ;; # tests failing
132 lldb) ;; # tests failing
133 openmp) ;; # https://github.com/google/llvm-premerge-checks/issues/410
141 function exclude-windows() {
143 for project in ${projects}; do
145 cross-project-tests) ;; # tests failing
146 compiler-rt) ;; # tests taking too long
147 openmp) ;; # TODO: having trouble with the Perl installation
148 libc) ;; # no Windows support
149 lldb) ;; # tests failing
150 bolt) ;; # tests are not supported yet
158 # Prints only projects that are both present in $modified_dirs and the passed
160 function keep-modified-projects() {
162 for project in ${projects}; do
163 if echo "$modified_dirs" | grep -q -E "^${project}$"; then
169 function check-targets() {
171 for project in ${projects}; do
174 echo "check-clang-tools"
180 echo "check-cross-project"
183 echo "check-all" # TODO: check-lldb may not include all the LLDB tests?
192 echo "check-${project}"
198 # Project specific pipelines.
200 # If libc++ or one of the runtimes directories changed.
201 if echo "$modified_dirs" | grep -q -E "^(libcxx|libcxxabi|libunwind|runtimes|cmake)$"; then
203 - trigger: "libcxx-ci"
205 message: "${buildMessage}"
206 commit: "${BUILDKITE_COMMIT}"
207 branch: "${BUILDKITE_BRANCH}"
212 if echo "$modified_dirs" | grep -q -E "^(clang)$"; then
214 - trigger: "clang-ci"
216 message: "${buildMessage}"
217 commit: "${BUILDKITE_COMMIT}"
218 branch: "${BUILDKITE_BRANCH}"
222 # Generic pipeline for projects that have not defined custom steps.
224 # Individual projects should instead define the pre-commit CI tests that suits their
225 # needs while letting them run on the infrastructure provided by LLVM.
227 # Figure out which projects need to be built on each platform
228 all_projects="bolt clang-tools-extra compiler-rt cross-project-tests flang libc libclc lld lldb llvm mlir openmp polly pstl"
229 modified_projects="$(keep-modified-projects ${all_projects})"
231 linux_projects_to_test=$(exclude-linux $(compute-projects-to-test ${modified_projects}))
232 linux_check_targets=$(check-targets ${linux_projects_to_test} | sort | uniq)
233 linux_projects=$(add-dependencies ${linux_projects_to_test} | sort | uniq)
235 windows_projects_to_test=$(exclude-windows $(compute-projects-to-test ${modified_projects}))
236 windows_check_targets=$(check-targets ${windows_projects_to_test} | sort | uniq)
237 windows_projects=$(add-dependencies ${windows_projects_to_test} | sort | uniq)
239 # Generate the appropriate pipeline
240 if [[ "${linux_projects}" != "" ]]; then
242 - label: ':linux
: Linux x64
'
246 - 'build
/test-results.xml
'
247 agents: ${LINUX_AGENTS}
250 - exit_status: -1 # Agent was lost
252 - exit_status: 255 # Forced agent shutdown
254 timeout_in_minutes: 120
259 - '.
/.ci
/monolithic-linux.sh
"$(echo ${linux_projects} | tr ' ' ';')" "$(echo ${linux_check_targets})"'
263 if [[ "${windows_projects}" != "" ]]; then
265 - label: ':windows
: Windows x64
'
269 - 'build
/test-results.xml
'
270 agents: ${WINDOWS_AGENTS}
273 - exit_status: -1 # Agent was lost
275 - exit_status: 255 # Forced agent shutdown
277 timeout_in_minutes: 150
283 - 'C
:\\BuildTools
\\Common7
\\Tools
\\VsDevCmd.bat
-arch=amd64
-host_arch=amd64
'
284 - 'bash .ci
/monolithic-windows.sh
"$(echo ${windows_projects} | tr ' ' ';')" "$(echo ${windows_check_targets})"'
288 # If build was triggered from a Phabricator review - send an update back.
289 if [[ -n "${ph_target_phid:-}" ]]; then
291 - continue_on_failure: true
293 - label: ':phabricator
: update build status on Phabricator
'
294 agents: ${SERVICE_AGENTS}
298 - export SRC=\$\${BUILDKITE_BUILD_PATH}/llvm-premerge-checks
300 - git clone --depth 1 https://github.com/google/llvm-premerge-checks.git "\$\${SRC}"
302 - git fetch origin "main":x
304 - echo "llvm-premerge-checks commit"
306 - pip install -q -r \$\${SRC}/scripts/requirements.txt
307 - cd "\$\$BUILDKITE_BUILD_CHECKOUT_PATH"
308 - \$\${SRC}/scripts/summary.py
309 timeout_in_minutes: 10