|
14 | 14 | # See https://buildkite.com/docs/agent/v3/cli-pipeline#pipeline-format.
|
15 | 15 | #
|
16 | 16 |
|
17 |
| -if ! git diff --name-only HEAD~1 | grep -q -E "^libcxx/|^libcxxabi/|^libunwind/|^runtimes/|^cmake/|^clang/"; then |
18 |
| - # libcxx/, libcxxabi/, libunwind/, runtimes/, cmake/ or clang/ are not affected |
19 |
| - exit 0 |
20 |
| -fi |
21 |
| - |
22 | 17 | reviewID="$(git log --format=%B -n 1 | sed -nE 's/^Review-ID:[[:space:]]*(.+)$/\1/p')"
|
23 | 18 | if [[ "${reviewID}" != "" ]]; then
|
24 | 19 | buildMessage="https://llvm.org/${reviewID}"
|
@@ -51,3 +46,213 @@ if git diff --name-only HEAD~1 | grep -q -E "^clang/"; then
|
51 | 46 | branch: "${BUILDKITE_BRANCH}"
|
52 | 47 | EOF
|
53 | 48 | fi
|
| 49 | + |
| 50 | +# |
| 51 | +# If we're not running a more specific pipeline, generate a legacy monolithic pipeline |
| 52 | +# based on which subdirectories have been modified. We have some heuristics for this |
| 53 | +# to be reasonable. |
| 54 | +# |
| 55 | +# Individual projects should instead define the pre-commit CI tests that suits their |
| 56 | +# needs while letting them run on the infrastructure provided by LLVM. |
| 57 | +# |
| 58 | +function compute-projects-to-test() { |
| 59 | + projects=${@} |
| 60 | + for project in ${projects}; do |
| 61 | + echo "${project}" |
| 62 | + case ${project} in |
| 63 | + lld) |
| 64 | + for p in bolt cross-project-tests; do |
| 65 | + echo $p |
| 66 | + done |
| 67 | + ;; |
| 68 | + llvm) |
| 69 | + for p in bolt clang clang-tools-extra flang lld lldb mlir polly; do |
| 70 | + echo $p |
| 71 | + done |
| 72 | + ;; |
| 73 | + clang) |
| 74 | + for p in clang-tools-extra compiler-rt flang libc lldb openmp cross-project-tests; do |
| 75 | + echo $p |
| 76 | + done |
| 77 | + ;; |
| 78 | + clang-tools-extra) |
| 79 | + echo libc |
| 80 | + ;; |
| 81 | + mlir) |
| 82 | + echo flang |
| 83 | + ;; |
| 84 | + *) |
| 85 | + # Nothing to do |
| 86 | + ;; |
| 87 | + esac |
| 88 | + done |
| 89 | +} |
| 90 | + |
| 91 | +function add-dependencies() { |
| 92 | + projects=${@} |
| 93 | + for project in ${projects}; do |
| 94 | + echo "${project}" |
| 95 | + case ${project} in |
| 96 | + bolt) |
| 97 | + for p in lld llvm; do |
| 98 | + echo $p |
| 99 | + done |
| 100 | + ;; |
| 101 | + cross-project-tests) |
| 102 | + for p in lld clang; do |
| 103 | + echo $p |
| 104 | + done |
| 105 | + ;; |
| 106 | + clang-tools-extra) |
| 107 | + for p in llvm clang; do |
| 108 | + echo $p |
| 109 | + done |
| 110 | + ;; |
| 111 | + compiler-rt|libc|openmp) |
| 112 | + echo clang |
| 113 | + ;; |
| 114 | + flang|lldb) |
| 115 | + for p in llvm clang; do |
| 116 | + echo $p |
| 117 | + done |
| 118 | + ;; |
| 119 | + lld|mlir|polly) |
| 120 | + echo llvm |
| 121 | + ;; |
| 122 | + *) |
| 123 | + # Nothing to do |
| 124 | + ;; |
| 125 | + esac |
| 126 | + done |
| 127 | +} |
| 128 | + |
| 129 | +function exclude-linux() { |
| 130 | + projects=${@} |
| 131 | + for project in ${projects}; do |
| 132 | + case ${project} in |
| 133 | + cross-project-tests) ;; # tests failing |
| 134 | + lldb) ;; # tests failing |
| 135 | + openmp) ;; # https://github.com/google/llvm-premerge-checks/issues/410 |
| 136 | + *) |
| 137 | + echo "${project}" |
| 138 | + ;; |
| 139 | + esac |
| 140 | + done |
| 141 | +} |
| 142 | + |
| 143 | +function exclude-windows() { |
| 144 | + projects=${@} |
| 145 | + for project in ${projects}; do |
| 146 | + case ${project} in |
| 147 | + cross-project-tests) ;; # tests failing |
| 148 | + compiler-rt) ;; # tests taking too long |
| 149 | + openmp) ;; # TODO: having trouble with the Perl installation |
| 150 | + libc) ;; # no Windows support |
| 151 | + lldb) ;; # tests failing |
| 152 | + bolt) ;; # tests are not supported yet |
| 153 | + *) |
| 154 | + echo "${project}" |
| 155 | + ;; |
| 156 | + esac |
| 157 | + done |
| 158 | +} |
| 159 | + |
| 160 | +function keep-modified-projects() { |
| 161 | + projects=${@} |
| 162 | + git_diff="$(git diff --name-only HEAD~1)" |
| 163 | + for project in ${projects}; do |
| 164 | + if echo "${git_diff}" | grep -q -E "^${project}/"; then |
| 165 | + echo "${project}" |
| 166 | + fi |
| 167 | + done |
| 168 | +} |
| 169 | + |
| 170 | +function check-targets() { |
| 171 | + projects=${@} |
| 172 | + for project in ${projects}; do |
| 173 | + case ${project} in |
| 174 | + clang-tools-extra) |
| 175 | + echo "check-clang-tools" |
| 176 | + ;; |
| 177 | + compiler-rt) |
| 178 | + echo "check-all" |
| 179 | + ;; |
| 180 | + cross-project-tests) |
| 181 | + echo "check-cross-project" |
| 182 | + ;; |
| 183 | + lldb) |
| 184 | + echo "check-all" # TODO: check-lldb may not include all the LLDB tests? |
| 185 | + ;; |
| 186 | + pstl) |
| 187 | + echo "check-all" |
| 188 | + ;; |
| 189 | + libclc) |
| 190 | + echo "check-all" |
| 191 | + ;; |
| 192 | + *) |
| 193 | + echo "check-${project}" |
| 194 | + ;; |
| 195 | + esac |
| 196 | + done |
| 197 | +} |
| 198 | + |
| 199 | +# Figure out which projects need to be built on each platform |
| 200 | +all_projects="bolt clang-tools-extra compiler-rt cross-project-tests flang libc libclc lld lldb llvm mlir openmp polly pstl" |
| 201 | +modified_projects="$(keep-modified-projects ${all_projects})" |
| 202 | + |
| 203 | +linux_projects_to_test=$(exclude-linux $(compute-projects-to-test ${modified_projects})) |
| 204 | +linux_check_targets=$(check-targets ${linux_projects_to_test} | sort | uniq) |
| 205 | +linux_projects=$(add-dependencies ${linux_projects_to_test} | sort | uniq) |
| 206 | + |
| 207 | +windows_projects_to_test=$(exclude-windows $(compute-projects-to-test ${modified_projects})) |
| 208 | +windows_check_targets=$(check-targets ${windows_projects_to_test} | sort | uniq) |
| 209 | +windows_projects=$(add-dependencies ${windows_projects_to_test} | sort | uniq) |
| 210 | + |
| 211 | +# Generate the appropriate pipeline |
| 212 | +if [[ "${linux_projects}" != "" ]]; then |
| 213 | + cat <<EOF |
| 214 | +- label: ':linux: x64 Debian' |
| 215 | + artifact_paths: |
| 216 | + - '*_result.json' |
| 217 | + - 'build/monolithic-linux/test-results.xml' |
| 218 | + agents: |
| 219 | + queue: 'linux' |
| 220 | + retry: |
| 221 | + automatic: |
| 222 | + - exit_status: -1 # Agent was lost |
| 223 | + limit: 2 |
| 224 | + - exit_status: 255 |
| 225 | + limit: 2 # Forced agent shutdown |
| 226 | + timeout_in_minutes: 120 |
| 227 | + env: |
| 228 | + CC: 'clang' |
| 229 | + CXX: 'clang++' |
| 230 | + commands: |
| 231 | + - './.ci/monolithic-linux.sh "$(echo ${linux_projects} | tr ' ' ';')" "$(echo ${linux_check_targets})"' |
| 232 | +EOF |
| 233 | +fi |
| 234 | + |
| 235 | +if [[ "${windows_projects}" != "" ]]; then |
| 236 | + cat <<EOF |
| 237 | +- label: ':windows: x64 Windows' |
| 238 | + artifact_paths: |
| 239 | + - '*_result.json' |
| 240 | + - 'build/monolithic-windows/test-results.xml' |
| 241 | + agents: |
| 242 | + queue: 'windows' |
| 243 | + retry: |
| 244 | + automatic: |
| 245 | + - exit_status: -1 # Agent was lost |
| 246 | + limit: 2 |
| 247 | + - exit_status: 255 |
| 248 | + limit: 2 # Forced agent shutdown |
| 249 | + timeout_in_minutes: 150 |
| 250 | + env: |
| 251 | + CC: 'cl' |
| 252 | + CXX: 'cl' |
| 253 | + LD: 'link' |
| 254 | + commands: |
| 255 | + - 'C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat -arch=amd64 -host_arch=amd64' |
| 256 | + - 'bash .ci/monolithic-windows.sh "$(echo ${windows_projects} | tr ' ' ';')" "$(echo ${windows_check_targets})"' |
| 257 | +EOF |
| 258 | +fi |
0 commit comments