llvm-project/.ci/generate-buildkite-pipeline-premerge

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

132 lines
4.0 KiB
Plaintext
Raw Permalink Normal View History

#!/usr/bin/env bash
#===----------------------------------------------------------------------===##
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===----------------------------------------------------------------------===##
#
# This file generates a Buildkite pipeline that triggers the various CI jobs for
# the LLVM project during pre-commit CI.
#
# 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:
# Set by buildkite
: ${BUILDKITE_PULL_REQUEST_BASE_BRANCH:=}
: ${BUILDKITE_COMMIT:=}
: ${BUILDKITE_BRANCH:=}
# Fetch origin to have an up to date merge base for the diff.
git fetch origin
# List of files affected by this commit
: ${MODIFIED_FILES:=$(git diff --name-only origin/${BUILDKITE_PULL_REQUEST_BASE_BRANCH}...HEAD)}
# Filter rules for generic windows tests
: ${WINDOWS_AGENTS:='{"queue": "windows"}'}
# Filter rules for generic linux tests
: ${LINUX_AGENTS:='{"queue": "linux"}'}
reviewID="$(git log --format=%B -n 1 | sed -nE 's/^Review-ID:[[:space:]]*(.+)$/\1/p')"
if [[ "${reviewID}" != "" ]]; then
buildMessage="https://llvm.org/${reviewID}"
else
buildMessage="Push to branch ${BUILDKITE_BRANCH}"
fi
cat <<EOF
steps:
EOF
echo "Files modified:" >&2
echo "$MODIFIED_FILES" >&2
modified_dirs=$(echo "$MODIFIED_FILES" | cut -d'/' -f1 | sort -u)
echo "Directories modified:" >&2
echo "$modified_dirs" >&2
Implement the monolithic CI pipeline in the monorepo This basically inlines the logic that was previously located in https://github.com/google/llvm-premerge-checks so it is part of the monorepo. This has the benefit of making it extremely easy for individual projects to understand and modify this logic for their own needs, unlike the current model where this logic lives in a separate non-LLVM repository. It also allows testing changes to the CI configuration using a simple Phabricator review, since the code that defines the CI pipeline is taken from the patch under review. This (or something equivalent) is necessary if we want to retain the current monolithic pre-commit CI throughout the GitHub PR transition. Since triggering the monolithic CI is currently attached to the system we use for triggering CI pipelines from Phabricator, we will lose that part of the CI when we move to GitHub PRs if we don't do anything. I've decided to rewrite the code as a shell script because the logic was fairly simple and it seemed a lot easier than figuring out how to pull only the relevant parts of llvm-premerge-checks into the monorepo. Furthermore, I think we should strive to move away from the monolithic CI altogether since sub-projects should understand, own and maintain the tests that are relevant for them to run in the CI (with LLVM providing the infrastructure). Hence, this is somewhat of a temporary solution until monolithic CI is removed entirely. Differential Revision: https://reviews.llvm.org/D158863
2023-06-12 14:45:48 -07:00
# 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 <<EOF
- trigger: "libcxx-ci"
build:
message: "${buildMessage}"
commit: "${BUILDKITE_COMMIT}"
branch: "${BUILDKITE_BRANCH}"
EOF
fi
# Generic pipeline for projects that have not defined custom steps.
#
# Individual projects should instead define the pre-commit CI tests that suits their
# needs while letting them run on the infrastructure provided by LLVM.
Implement the monolithic CI pipeline in the monorepo This basically inlines the logic that was previously located in https://github.com/google/llvm-premerge-checks so it is part of the monorepo. This has the benefit of making it extremely easy for individual projects to understand and modify this logic for their own needs, unlike the current model where this logic lives in a separate non-LLVM repository. It also allows testing changes to the CI configuration using a simple Phabricator review, since the code that defines the CI pipeline is taken from the patch under review. This (or something equivalent) is necessary if we want to retain the current monolithic pre-commit CI throughout the GitHub PR transition. Since triggering the monolithic CI is currently attached to the system we use for triggering CI pipelines from Phabricator, we will lose that part of the CI when we move to GitHub PRs if we don't do anything. I've decided to rewrite the code as a shell script because the logic was fairly simple and it seemed a lot easier than figuring out how to pull only the relevant parts of llvm-premerge-checks into the monorepo. Furthermore, I think we should strive to move away from the monolithic CI altogether since sub-projects should understand, own and maintain the tests that are relevant for them to run in the CI (with LLVM providing the infrastructure). Hence, this is somewhat of a temporary solution until monolithic CI is removed entirely. Differential Revision: https://reviews.llvm.org/D158863
2023-06-12 14:45:48 -07:00
# Figure out which projects need to be built on each platform
source <(git diff --name-only origin/${BUILDKITE_PULL_REQUEST_BASE_BRANCH}...HEAD | python3 .ci/compute_projects.py Linux)
linux_projects=${projects_to_build}
linux_check_targets=${project_check_targets}
linux_runtimes=${runtimes_to_build}
linux_runtime_check_targets=${runtimes_check_targets}
Implement the monolithic CI pipeline in the monorepo This basically inlines the logic that was previously located in https://github.com/google/llvm-premerge-checks so it is part of the monorepo. This has the benefit of making it extremely easy for individual projects to understand and modify this logic for their own needs, unlike the current model where this logic lives in a separate non-LLVM repository. It also allows testing changes to the CI configuration using a simple Phabricator review, since the code that defines the CI pipeline is taken from the patch under review. This (or something equivalent) is necessary if we want to retain the current monolithic pre-commit CI throughout the GitHub PR transition. Since triggering the monolithic CI is currently attached to the system we use for triggering CI pipelines from Phabricator, we will lose that part of the CI when we move to GitHub PRs if we don't do anything. I've decided to rewrite the code as a shell script because the logic was fairly simple and it seemed a lot easier than figuring out how to pull only the relevant parts of llvm-premerge-checks into the monorepo. Furthermore, I think we should strive to move away from the monolithic CI altogether since sub-projects should understand, own and maintain the tests that are relevant for them to run in the CI (with LLVM providing the infrastructure). Hence, this is somewhat of a temporary solution until monolithic CI is removed entirely. Differential Revision: https://reviews.llvm.org/D158863
2023-06-12 14:45:48 -07:00
source <(git diff --name-only origin/${BUILDKITE_PULL_REQUEST_BASE_BRANCH}...HEAD | python3 .ci/compute_projects.py Windows)
windows_projects=${projects_to_build}
windows_check_targets=${project_check_targets}
Implement the monolithic CI pipeline in the monorepo This basically inlines the logic that was previously located in https://github.com/google/llvm-premerge-checks so it is part of the monorepo. This has the benefit of making it extremely easy for individual projects to understand and modify this logic for their own needs, unlike the current model where this logic lives in a separate non-LLVM repository. It also allows testing changes to the CI configuration using a simple Phabricator review, since the code that defines the CI pipeline is taken from the patch under review. This (or something equivalent) is necessary if we want to retain the current monolithic pre-commit CI throughout the GitHub PR transition. Since triggering the monolithic CI is currently attached to the system we use for triggering CI pipelines from Phabricator, we will lose that part of the CI when we move to GitHub PRs if we don't do anything. I've decided to rewrite the code as a shell script because the logic was fairly simple and it seemed a lot easier than figuring out how to pull only the relevant parts of llvm-premerge-checks into the monorepo. Furthermore, I think we should strive to move away from the monolithic CI altogether since sub-projects should understand, own and maintain the tests that are relevant for them to run in the CI (with LLVM providing the infrastructure). Hence, this is somewhat of a temporary solution until monolithic CI is removed entirely. Differential Revision: https://reviews.llvm.org/D158863
2023-06-12 14:45:48 -07:00
# Generate the appropriate pipeline
if [[ "${linux_projects}" != "" ]]; then
cat <<EOF
- label: ':linux: Linux x64'
Implement the monolithic CI pipeline in the monorepo This basically inlines the logic that was previously located in https://github.com/google/llvm-premerge-checks so it is part of the monorepo. This has the benefit of making it extremely easy for individual projects to understand and modify this logic for their own needs, unlike the current model where this logic lives in a separate non-LLVM repository. It also allows testing changes to the CI configuration using a simple Phabricator review, since the code that defines the CI pipeline is taken from the patch under review. This (or something equivalent) is necessary if we want to retain the current monolithic pre-commit CI throughout the GitHub PR transition. Since triggering the monolithic CI is currently attached to the system we use for triggering CI pipelines from Phabricator, we will lose that part of the CI when we move to GitHub PRs if we don't do anything. I've decided to rewrite the code as a shell script because the logic was fairly simple and it seemed a lot easier than figuring out how to pull only the relevant parts of llvm-premerge-checks into the monorepo. Furthermore, I think we should strive to move away from the monolithic CI altogether since sub-projects should understand, own and maintain the tests that are relevant for them to run in the CI (with LLVM providing the infrastructure). Hence, this is somewhat of a temporary solution until monolithic CI is removed entirely. Differential Revision: https://reviews.llvm.org/D158863
2023-06-12 14:45:48 -07:00
artifact_paths:
- 'artifacts/**/*'
- '*_result.json'
[ci] Write test results to unique file names (#113160) In this patch I'm using a new lit option so that the pipeline writes many results files, one for each time lit is run: ``` --use-unique-output-file-name When enabled, lit will add a unique element to the output file name, before the extension. For example "results.xml" will become "results.<something>.xml". The "<something>" is not ordered in any way and is chosen so that existing files are not overwritten. [Default: Off] ``` (I added this to lit recently) Alternatives were considered: * mkfifo - does not work on bash for Windows. * tail -f - does not print full content on file truncation * lit wrapper script - more complication than using an option to lit itself * ninja/mv file/ninja/mv file etc - lots of changes needed to make the scripts build each target separately And after feedback I decided that using an option to lit itself is the cleanest way to go. It can be removed when we no longer need it. If I run the Linux build after this change: ``` $ bash ./.ci/monolithic-linux.sh "clang;lldb;lld" "check-lldb-shell check-lld" "libcxx;libcxxabi" "check-libcxx check-libcxxabi" ``` I get multiple test result files. In my case some tests fail so runtimes aren't checked, but all projects are so there is 1 file for lldb and one for lld: ``` $ ls build/*.xml build/test-results.klc82utf.xml build/test-results.majylh73.xml ``` This change just collects the XML files as artifacts. Once I know that's working, I can set up test reporting to make a summary of them.
2024-11-12 13:24:44 +00:00
- 'build/test-results.*.xml'
agents: ${LINUX_AGENTS}
Implement the monolithic CI pipeline in the monorepo This basically inlines the logic that was previously located in https://github.com/google/llvm-premerge-checks so it is part of the monorepo. This has the benefit of making it extremely easy for individual projects to understand and modify this logic for their own needs, unlike the current model where this logic lives in a separate non-LLVM repository. It also allows testing changes to the CI configuration using a simple Phabricator review, since the code that defines the CI pipeline is taken from the patch under review. This (or something equivalent) is necessary if we want to retain the current monolithic pre-commit CI throughout the GitHub PR transition. Since triggering the monolithic CI is currently attached to the system we use for triggering CI pipelines from Phabricator, we will lose that part of the CI when we move to GitHub PRs if we don't do anything. I've decided to rewrite the code as a shell script because the logic was fairly simple and it seemed a lot easier than figuring out how to pull only the relevant parts of llvm-premerge-checks into the monorepo. Furthermore, I think we should strive to move away from the monolithic CI altogether since sub-projects should understand, own and maintain the tests that are relevant for them to run in the CI (with LLVM providing the infrastructure). Hence, this is somewhat of a temporary solution until monolithic CI is removed entirely. Differential Revision: https://reviews.llvm.org/D158863
2023-06-12 14:45:48 -07:00
retry:
automatic:
- exit_status: -1 # Agent was lost
limit: 2
- exit_status: 255 # Forced agent shutdown
limit: 2
Implement the monolithic CI pipeline in the monorepo This basically inlines the logic that was previously located in https://github.com/google/llvm-premerge-checks so it is part of the monorepo. This has the benefit of making it extremely easy for individual projects to understand and modify this logic for their own needs, unlike the current model where this logic lives in a separate non-LLVM repository. It also allows testing changes to the CI configuration using a simple Phabricator review, since the code that defines the CI pipeline is taken from the patch under review. This (or something equivalent) is necessary if we want to retain the current monolithic pre-commit CI throughout the GitHub PR transition. Since triggering the monolithic CI is currently attached to the system we use for triggering CI pipelines from Phabricator, we will lose that part of the CI when we move to GitHub PRs if we don't do anything. I've decided to rewrite the code as a shell script because the logic was fairly simple and it seemed a lot easier than figuring out how to pull only the relevant parts of llvm-premerge-checks into the monorepo. Furthermore, I think we should strive to move away from the monolithic CI altogether since sub-projects should understand, own and maintain the tests that are relevant for them to run in the CI (with LLVM providing the infrastructure). Hence, this is somewhat of a temporary solution until monolithic CI is removed entirely. Differential Revision: https://reviews.llvm.org/D158863
2023-06-12 14:45:48 -07:00
timeout_in_minutes: 120
env:
CC: 'clang'
CXX: 'clang++'
commands:
- './.ci/monolithic-linux.sh "$(echo ${linux_projects} | tr ' ' ';')" "$(echo ${linux_check_targets})" "$(echo ${linux_runtimes} | tr ' ' ';')" "$(echo ${linux_runtime_check_targets})"'
Implement the monolithic CI pipeline in the monorepo This basically inlines the logic that was previously located in https://github.com/google/llvm-premerge-checks so it is part of the monorepo. This has the benefit of making it extremely easy for individual projects to understand and modify this logic for their own needs, unlike the current model where this logic lives in a separate non-LLVM repository. It also allows testing changes to the CI configuration using a simple Phabricator review, since the code that defines the CI pipeline is taken from the patch under review. This (or something equivalent) is necessary if we want to retain the current monolithic pre-commit CI throughout the GitHub PR transition. Since triggering the monolithic CI is currently attached to the system we use for triggering CI pipelines from Phabricator, we will lose that part of the CI when we move to GitHub PRs if we don't do anything. I've decided to rewrite the code as a shell script because the logic was fairly simple and it seemed a lot easier than figuring out how to pull only the relevant parts of llvm-premerge-checks into the monorepo. Furthermore, I think we should strive to move away from the monolithic CI altogether since sub-projects should understand, own and maintain the tests that are relevant for them to run in the CI (with LLVM providing the infrastructure). Hence, this is somewhat of a temporary solution until monolithic CI is removed entirely. Differential Revision: https://reviews.llvm.org/D158863
2023-06-12 14:45:48 -07:00
EOF
fi
if [[ "${windows_projects}" != "" ]]; then
cat <<EOF
- label: ':windows: Windows x64'
Implement the monolithic CI pipeline in the monorepo This basically inlines the logic that was previously located in https://github.com/google/llvm-premerge-checks so it is part of the monorepo. This has the benefit of making it extremely easy for individual projects to understand and modify this logic for their own needs, unlike the current model where this logic lives in a separate non-LLVM repository. It also allows testing changes to the CI configuration using a simple Phabricator review, since the code that defines the CI pipeline is taken from the patch under review. This (or something equivalent) is necessary if we want to retain the current monolithic pre-commit CI throughout the GitHub PR transition. Since triggering the monolithic CI is currently attached to the system we use for triggering CI pipelines from Phabricator, we will lose that part of the CI when we move to GitHub PRs if we don't do anything. I've decided to rewrite the code as a shell script because the logic was fairly simple and it seemed a lot easier than figuring out how to pull only the relevant parts of llvm-premerge-checks into the monorepo. Furthermore, I think we should strive to move away from the monolithic CI altogether since sub-projects should understand, own and maintain the tests that are relevant for them to run in the CI (with LLVM providing the infrastructure). Hence, this is somewhat of a temporary solution until monolithic CI is removed entirely. Differential Revision: https://reviews.llvm.org/D158863
2023-06-12 14:45:48 -07:00
artifact_paths:
- 'artifacts/**/*'
- '*_result.json'
[ci] Write test results to unique file names (#113160) In this patch I'm using a new lit option so that the pipeline writes many results files, one for each time lit is run: ``` --use-unique-output-file-name When enabled, lit will add a unique element to the output file name, before the extension. For example "results.xml" will become "results.<something>.xml". The "<something>" is not ordered in any way and is chosen so that existing files are not overwritten. [Default: Off] ``` (I added this to lit recently) Alternatives were considered: * mkfifo - does not work on bash for Windows. * tail -f - does not print full content on file truncation * lit wrapper script - more complication than using an option to lit itself * ninja/mv file/ninja/mv file etc - lots of changes needed to make the scripts build each target separately And after feedback I decided that using an option to lit itself is the cleanest way to go. It can be removed when we no longer need it. If I run the Linux build after this change: ``` $ bash ./.ci/monolithic-linux.sh "clang;lldb;lld" "check-lldb-shell check-lld" "libcxx;libcxxabi" "check-libcxx check-libcxxabi" ``` I get multiple test result files. In my case some tests fail so runtimes aren't checked, but all projects are so there is 1 file for lldb and one for lld: ``` $ ls build/*.xml build/test-results.klc82utf.xml build/test-results.majylh73.xml ``` This change just collects the XML files as artifacts. Once I know that's working, I can set up test reporting to make a summary of them.
2024-11-12 13:24:44 +00:00
- 'build/test-results.*.xml'
agents: ${WINDOWS_AGENTS}
Implement the monolithic CI pipeline in the monorepo This basically inlines the logic that was previously located in https://github.com/google/llvm-premerge-checks so it is part of the monorepo. This has the benefit of making it extremely easy for individual projects to understand and modify this logic for their own needs, unlike the current model where this logic lives in a separate non-LLVM repository. It also allows testing changes to the CI configuration using a simple Phabricator review, since the code that defines the CI pipeline is taken from the patch under review. This (or something equivalent) is necessary if we want to retain the current monolithic pre-commit CI throughout the GitHub PR transition. Since triggering the monolithic CI is currently attached to the system we use for triggering CI pipelines from Phabricator, we will lose that part of the CI when we move to GitHub PRs if we don't do anything. I've decided to rewrite the code as a shell script because the logic was fairly simple and it seemed a lot easier than figuring out how to pull only the relevant parts of llvm-premerge-checks into the monorepo. Furthermore, I think we should strive to move away from the monolithic CI altogether since sub-projects should understand, own and maintain the tests that are relevant for them to run in the CI (with LLVM providing the infrastructure). Hence, this is somewhat of a temporary solution until monolithic CI is removed entirely. Differential Revision: https://reviews.llvm.org/D158863
2023-06-12 14:45:48 -07:00
retry:
automatic:
- exit_status: -1 # Agent was lost
limit: 2
- exit_status: 255 # Forced agent shutdown
limit: 2
Implement the monolithic CI pipeline in the monorepo This basically inlines the logic that was previously located in https://github.com/google/llvm-premerge-checks so it is part of the monorepo. This has the benefit of making it extremely easy for individual projects to understand and modify this logic for their own needs, unlike the current model where this logic lives in a separate non-LLVM repository. It also allows testing changes to the CI configuration using a simple Phabricator review, since the code that defines the CI pipeline is taken from the patch under review. This (or something equivalent) is necessary if we want to retain the current monolithic pre-commit CI throughout the GitHub PR transition. Since triggering the monolithic CI is currently attached to the system we use for triggering CI pipelines from Phabricator, we will lose that part of the CI when we move to GitHub PRs if we don't do anything. I've decided to rewrite the code as a shell script because the logic was fairly simple and it seemed a lot easier than figuring out how to pull only the relevant parts of llvm-premerge-checks into the monorepo. Furthermore, I think we should strive to move away from the monolithic CI altogether since sub-projects should understand, own and maintain the tests that are relevant for them to run in the CI (with LLVM providing the infrastructure). Hence, this is somewhat of a temporary solution until monolithic CI is removed entirely. Differential Revision: https://reviews.llvm.org/D158863
2023-06-12 14:45:48 -07:00
timeout_in_minutes: 150
env:
MAX_PARALLEL_COMPILE_JOBS: '16'
MAX_PARALLEL_LINK_JOBS: '4'
Implement the monolithic CI pipeline in the monorepo This basically inlines the logic that was previously located in https://github.com/google/llvm-premerge-checks so it is part of the monorepo. This has the benefit of making it extremely easy for individual projects to understand and modify this logic for their own needs, unlike the current model where this logic lives in a separate non-LLVM repository. It also allows testing changes to the CI configuration using a simple Phabricator review, since the code that defines the CI pipeline is taken from the patch under review. This (or something equivalent) is necessary if we want to retain the current monolithic pre-commit CI throughout the GitHub PR transition. Since triggering the monolithic CI is currently attached to the system we use for triggering CI pipelines from Phabricator, we will lose that part of the CI when we move to GitHub PRs if we don't do anything. I've decided to rewrite the code as a shell script because the logic was fairly simple and it seemed a lot easier than figuring out how to pull only the relevant parts of llvm-premerge-checks into the monorepo. Furthermore, I think we should strive to move away from the monolithic CI altogether since sub-projects should understand, own and maintain the tests that are relevant for them to run in the CI (with LLVM providing the infrastructure). Hence, this is somewhat of a temporary solution until monolithic CI is removed entirely. Differential Revision: https://reviews.llvm.org/D158863
2023-06-12 14:45:48 -07:00
commands:
- 'C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat -arch=amd64 -host_arch=amd64'
- 'bash .ci/monolithic-windows.sh "$(echo ${windows_projects} | tr ' ' ';')" "$(echo ${windows_check_targets})"'
EOF
fi