diff --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml index 605f103a3d95..b536e5b6f793 100644 --- a/libcxx/utils/ci/buildkite-pipeline.yml +++ b/libcxx/utils/ci/buildkite-pipeline.yml @@ -1,81 +1,81 @@ #===----------------------------------------------------------------------===## # # 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 describes the various pre-commit CI bots used to test libc++. # # This file should never contain logic -- all the logic must be offloaded # into scripts. This is critical to being able to reproduce CI issues outside # of the CI environment, which is important for debugging. # steps: - label: "C++03" - command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-cxx03 | libcxx/utils/ci/phabricator-report" + command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-cxx03" agents: queue: "libcxx-builders" - label: "C++11" - command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-cxx11 | libcxx/utils/ci/phabricator-report" + command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-cxx11" agents: queue: "libcxx-builders" - label: "C++14" - command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-cxx14 | libcxx/utils/ci/phabricator-report" + command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-cxx14" agents: queue: "libcxx-builders" - label: "C++17" - command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-cxx17 | libcxx/utils/ci/phabricator-report" + command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-cxx17" agents: queue: "libcxx-builders" - label: "C++20" - command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-cxx2a | libcxx/utils/ci/phabricator-report" + command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-cxx2a" agents: queue: "libcxx-builders" - label: "-fno-exceptions" - command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-noexceptions | libcxx/utils/ci/phabricator-report" + command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-noexceptions" agents: queue: "libcxx-builders" - label: "32 bits" - command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-32bit | libcxx/utils/ci/phabricator-report" + command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-32bit" agents: queue: "libcxx-builders" - label: "GCC/C++20" - command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-gcc | libcxx/utils/ci/phabricator-report" + command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-gcc" agents: queue: "libcxx-builders" - label: "ASAN" - command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-asan | libcxx/utils/ci/phabricator-report" + command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-asan" agents: queue: "libcxx-builders" - label: "TSAN" - command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-tsan | libcxx/utils/ci/phabricator-report" + command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-tsan" agents: queue: "libcxx-builders" - label: "UBSAN" - command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-ubsan | libcxx/utils/ci/phabricator-report" + command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-ubsan" agents: queue: "libcxx-builders" - label: "With LLVM's libunwind" - command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-with_llvm_unwinder | libcxx/utils/ci/phabricator-report" + command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-with_llvm_unwinder" agents: queue: "libcxx-builders" - label: "Single-threaded" - command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-singlethreaded | libcxx/utils/ci/phabricator-report" + command: "set -o pipefail && libcxx/utils/ci/run-buildbot.sh x86_64-ubuntu-singlethreaded" agents: queue: "libcxx-builders" diff --git a/libcxx/utils/ci/phabricator-report b/libcxx/utils/ci/phabricator-report index 14eac69c4c80..dffe00ba0b7c 100755 --- a/libcxx/utils/ci/phabricator-report +++ b/libcxx/utils/ci/phabricator-report @@ -1,86 +1,84 @@ #!/usr/bin/env python3 #===----------------------------------------------------------------------===## # # 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 # #===----------------------------------------------------------------------===## import argparse import io import os import phabricator import re import subprocess import sys import time LLVM_REVIEWS_API = "https://reviews.llvm.org/api/" def main(argv): parser = argparse.ArgumentParser( description=""" This script gathers information about a Buildkite build and updates the Phabricator review associated to the HEAD commit with those results. The intended usage of this script is to pipe the output of a command defined in a Buildkite pipeline into it. The script will echo everything to stdout, like tee, but will also update the Phabricator review associated to HEAD with the results of the build. The script is assumed to be running inside a Buildkite agent, and as such, it assumes the existence of several environment variables that are specific to Buildkite. It also assumes that it is running in a context where the HEAD commit contains the Phabricator ID of the review to update. """) - parser.add_argument('--token', type=str, required=True, - help="The Conduit token to use to authenticate with {}.".format(LLVM_REVIEWS_API)) args = parser.parse_args(argv) for var in ('BUILDKITE_LABEL', 'BUILDKITE_JOB_ID', 'BUILDKITE_BUILD_URL', 'CONDUIT_TOKEN'): if var not in os.environ: raise RuntimeError( 'The {} environment variable must exist -- are you running ' 'this script from a Buildkite agent?'.format(var)) # First, read all the log input and write it line-by-line to stdout. # This is important so that we can follow progress in the Buildkite # console. Since we're being piped into in real time, it's also the # moment to time the duration of the job. start = time.time() log = io.StringIO() while True: line = sys.stdin.readline() if line == '': break sys.stdout.write(line) sys.stdout.flush() # flush every line to avoid buffering log.write(line) end = time.time() # Then, extract information from the environment and post-process the logs. log.seek(0) log = log.read() result = 'fail' if 'FAILED:' in log else 'pass' resultObject = { 'name': '{BUILDKITE_LABEL} ({BUILDKITE_BUILD_URL}#{BUILDKITE_JOB_ID})'.format(**os.environ), 'result': result, 'duration': end - start, 'details': log } commitMessage = subprocess.check_output(['git', 'log', '--format=%B' , '-n', '1']).decode() phabricatorID = re.search(r'^Phabricator-ID:\s+(.+)$', commitMessage, flags=re.MULTILINE) if not phabricatorID: raise RuntimeError('Could not find the Phabricator ID in the commit message. ' 'The commit message was:\n{}'.format(commitMessage)) else: phabricatorID = phabricatorID.group(1) token = os.environ['CONDUIT_TOKEN'] phab = phabricator.Phabricator(token=token, host=LLVM_REVIEWS_API) phab.harbormaster.sendmessage(buildTargetPHID=phabricatorID, type=result, unit=[resultObject]) if __name__ == '__main__': main(sys.argv[1:])