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 @@ -13,6 +13,25 @@ # # See https://buildkite.com/docs/agent/v3/cli-pipeline#pipeline-format. # +# As this outputs a yaml file, it's possible to log messages to stderr or +# prefix with "#". + + +set -eu +set -o pipefail + +# Environment variables script works with: +# List of files affected by this commit +: ${MODIFIED_FILES:=$(git diff --name-only HEAD~1)} +# Filter rules for generic windows tests +: ${WINDOWS_AGENTS:='{"queue": "windows"}'} +# Filter rules for generic linux tests +: ${LINUX_AGENTS:='{"queue": "linux"}'} +# Service agents, for interacting with Phabricator. +: ${SERVICE_AGENTS:='{"queue": "service"}'} +# Set by buildkite +: ${BUILDKITE_COMMIT:=} +: ${BUILDKITE_BRANCH:=} reviewID="$(git log --format=%B -n 1 | sed -nE 's/^Review-ID:[[:space:]]*(.+)$/\1/p')" if [[ "${reviewID}" != "" ]]; then @@ -25,36 +44,12 @@ steps: EOF -# If libc++ or one of the runtimes directories changed -if git diff --name-only HEAD~1 | grep -q -E "^libcxx/|^libcxxabi/|^libunwind/|^runtimes/|^cmake/"; then - cat <&2 +echo "$MODIFIED_FILES" >&2 +modified_dirs=$(echo "$MODIFIED_FILES" | cut -d'/' -f1 | sort -u) +echo "Directories modified:" >&2 +echo "$modified_dirs" >&2 -# -# 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 @@ -157,11 +152,12 @@ done } +# Prints only projects that are both present in $modified_dirs and the passed +# list. 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 + if echo "$modified_dirs" | grep -q -E "^${project}$"; then echo "${project}" fi done @@ -196,6 +192,35 @@ done } +# Project specific pipelines. + +# If libc++ or one of the runtimes directories changed. +if echo "$modified_dirs" | grep -q -E "^(libcxx|libcxxabi|libunwind|runtimes|cmake)$"; then + cat <