2020-12-09 17:23:01 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# Copyright 2020 Google LLC
|
|
|
|
#
|
|
|
|
# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# https://llvm.org/LICENSE.txt
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2021-08-11 16:20:03 +02:00
|
|
|
# Script runs in checked out llvm-project directory.
|
|
|
|
|
2020-12-09 17:23:01 +01:00
|
|
|
import os
|
2021-10-04 16:07:06 +02:00
|
|
|
from typing import Dict
|
2021-09-03 15:15:11 +02:00
|
|
|
from steps import generic_linux, generic_windows, from_shell_output, extend_steps_env, bazel
|
2021-08-11 16:20:03 +02:00
|
|
|
from sync_fork import sync_fork
|
|
|
|
import git
|
2020-12-09 17:23:01 +01:00
|
|
|
import yaml
|
2021-10-04 16:07:06 +02:00
|
|
|
from choose_projects import ChooseProjects
|
2020-12-09 17:23:01 +01:00
|
|
|
|
|
|
|
steps_generators = [
|
2020-12-15 09:24:49 +01:00
|
|
|
'${BUILDKITE_BUILD_CHECKOUT_PATH}/libcxx/utils/ci/buildkite-pipeline-snapshot.sh',
|
2020-12-09 17:23:01 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
scripts_refspec = os.getenv("ph_scripts_refspec", "main")
|
|
|
|
no_cache = os.getenv('ph_no_cache') is not None
|
|
|
|
log_level = os.getenv('ph_log_level', 'WARNING')
|
|
|
|
notify_emails = list(filter(None, os.getenv('ph_notify_emails', '').split(',')))
|
2021-10-04 16:07:06 +02:00
|
|
|
# Syncing LLVM fork so any pipelines started from upstream llvm-project
|
2021-08-11 16:20:03 +02:00
|
|
|
# but then triggered a build on fork will observe the commit.
|
2021-10-04 16:07:06 +02:00
|
|
|
sync_fork(os.path.join(os.getenv('BUILDKITE_BUILD_PATH', ''), 'llvm-project-fork'), [os.getenv('BUILDKITE_BRANCH'), 'main'])
|
2020-12-09 17:23:01 +01:00
|
|
|
steps = []
|
2021-08-11 16:20:03 +02:00
|
|
|
|
2021-10-04 16:07:06 +02:00
|
|
|
env: Dict[str, str] = {}
|
2021-08-11 16:20:03 +02:00
|
|
|
for e in os.environ:
|
|
|
|
if e.startswith('ph_'):
|
2021-10-04 16:07:06 +02:00
|
|
|
env[e] = os.getenv(e, '')
|
2021-08-11 16:20:03 +02:00
|
|
|
repo = git.Repo('.')
|
2020-12-09 17:23:01 +01:00
|
|
|
|
2021-10-04 16:07:06 +02:00
|
|
|
cp = ChooseProjects(None)
|
2021-10-04 16:15:16 +02:00
|
|
|
linux_projects = cp.get_all_enabled_projects('linux')
|
2021-10-04 16:07:06 +02:00
|
|
|
steps.extend(generic_linux(os.getenv('ph_projects', ';'.join(linux_projects)), check_diff=False))
|
2021-10-04 16:15:16 +02:00
|
|
|
windows_projects = cp.get_all_enabled_projects('windows')
|
2021-10-04 16:07:06 +02:00
|
|
|
steps.extend(generic_windows(os.getenv('ph_projects', ';'.join(windows_projects))))
|
2021-09-03 15:15:11 +02:00
|
|
|
steps.extend(bazel([], force=True))
|
2021-03-19 09:22:21 +01:00
|
|
|
if os.getenv('ph_skip_generated') is None:
|
2021-08-11 16:20:03 +02:00
|
|
|
# BUILDKITE_COMMIT might be an alias, e.g. "HEAD". Resolve it to make the build hermetic.
|
2021-10-04 16:58:52 +02:00
|
|
|
if os.getenv('BUILDKITE_COMMIT', 'HEAD') == "HEAD":
|
2021-08-30 16:40:18 +02:00
|
|
|
env['BUILDKITE_COMMIT'] = repo.head.commit.hexsha
|
2021-03-19 09:22:21 +01:00
|
|
|
for gen in steps_generators:
|
2021-10-04 16:58:52 +02:00
|
|
|
steps.extend(from_shell_output(gen, env=env))
|
2020-12-09 17:23:01 +01:00
|
|
|
|
|
|
|
notify = []
|
|
|
|
for e in notify_emails:
|
|
|
|
notify.append({'email': e})
|
2021-08-11 16:20:03 +02:00
|
|
|
extend_steps_env(steps, env)
|
2020-12-09 17:23:01 +01:00
|
|
|
print(yaml.dump({'steps': steps, 'notify': notify}))
|