diff --git a/.ci/generate-buildkite-pipeline-premerge b/.ci/generate-buildkite-pipeline-premerge --- a/.ci/generate-buildkite-pipeline-premerge +++ b/.ci/generate-buildkite-pipeline-premerge @@ -14,11 +14,6 @@ # See https://buildkite.com/docs/agent/v3/cli-pipeline#pipeline-format. # -if ! git diff --name-only HEAD~1 | grep -q -E "^libcxx/|^libcxxabi/|^libunwind/|^runtimes/|^cmake/|^clang/"; then - # libcxx/, libcxxabi/, libunwind/, runtimes/, cmake/ or clang/ are not affected - exit 0 -fi - reviewID="$(git log --format=%B -n 1 | sed -nE 's/^Review-ID:[[:space:]]*(.+)$/\1/p')" if [[ "${reviewID}" != "" ]]; then buildMessage="https://llvm.org/${reviewID}" @@ -51,3 +46,213 @@ branch: "${BUILDKITE_BRANCH}" EOF fi + +# +# If we're not running a more specific pipeline, generate a legacy monolithic pipeline +# based on which subdirectories have been modified. We have some heuristics for this +# to be reasonable. +# +# Individual projects should instead define the pre-commit CI tests that suits their +# needs while letting them run on the infrastructure provided by LLVM. +# +function compute-projects-to-test() { + projects=${@} + for project in ${projects}; do + echo "${project}" + case ${project} in + lld) + for p in bolt cross-project-tests; do + echo $p + done + ;; + llvm) + for p in bolt clang clang-tools-extra flang lld lldb mlir polly; do + echo $p + done + ;; + clang) + for p in clang-tools-extra compiler-rt flang libc lldb openmp cross-project-tests; do + echo $p + done + ;; + clang-tools-extra) + echo libc + ;; + mlir) + echo flang + ;; + *) + # Nothing to do + ;; + esac + done +} + +function add-dependencies() { + projects=${@} + for project in ${projects}; do + echo "${project}" + case ${project} in + bolt) + for p in lld llvm; do + echo $p + done + ;; + cross-project-tests) + for p in lld clang; do + echo $p + done + ;; + clang-tools-extra) + for p in llvm clang; do + echo $p + done + ;; + compiler-rt|libc|openmp) + echo clang + ;; + flang|lldb) + for p in llvm clang; do + echo $p + done + ;; + lld|mlir|polly) + echo llvm + ;; + *) + # Nothing to do + ;; + esac + done +} + +function exclude-linux() { + projects=${@} + for project in ${projects}; do + case ${project} in + cross-project-tests) ;; # tests failing + lldb) ;; # tests failing + openmp) ;; # https://github.com/google/llvm-premerge-checks/issues/410 + *) + echo "${project}" + ;; + esac + done +} + +function exclude-windows() { + projects=${@} + for project in ${projects}; do + case ${project} in + cross-project-tests) ;; # tests failing + compiler-rt) ;; # tests taking too long + openmp) ;; # TODO: having trouble with the Perl installation + libc) ;; # no Windows support + lldb) ;; # tests failing + bolt) ;; # tests are not supported yet + *) + echo "${project}" + ;; + esac + done +} + +function keep-modified-projects() { + projects=${@} + git_diff="$(git diff --name-only HEAD~1)" + for project in ${projects}; do + if echo "${git_diff}" | grep -q -E "^${project}/"; then + echo "${project}" + fi + done +} + +function check-targets() { + projects=${@} + for project in ${projects}; do + case ${project} in + clang-tools-extra) + echo "check-clang-tools" + ;; + compiler-rt) + echo "check-all" + ;; + cross-project-tests) + echo "check-cross-project" + ;; + lldb) + echo "check-all" # TODO: check-lldb may not include all the LLDB tests? + ;; + pstl) + echo "check-all" + ;; + libclc) + echo "check-all" + ;; + *) + echo "check-${project}" + ;; + esac + done +} + +# Figure out which projects need to be built on each platform +all_projects="bolt clang-tools-extra compiler-rt cross-project-tests flang libc libclc lld lldb llvm mlir openmp polly pstl" +modified_projects="$(keep-modified-projects ${all_projects})" + +linux_projects_to_test=$(exclude-linux $(compute-projects-to-test ${modified_projects})) +linux_check_targets=$(check-targets ${linux_projects_to_test} | sort | uniq) +linux_projects=$(add-dependencies ${linux_projects_to_test} | sort | uniq) + +windows_projects_to_test=$(exclude-windows $(compute-projects-to-test ${modified_projects})) +windows_check_targets=$(check-targets ${windows_projects_to_test} | sort | uniq) +windows_projects=$(add-dependencies ${windows_projects_to_test} | sort | uniq) + +# Generate the appropriate pipeline +if [[ "${linux_projects}" != "" ]]; then + cat <