2022-11-28 11:31:43 +01:00
|
|
|
import os
|
|
|
|
import json
|
|
|
|
import argparse
|
|
|
|
import requests
|
2023-07-17 13:19:09 +02:00
|
|
|
import time
|
2022-11-28 11:31:43 +01:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2022-12-02 11:53:36 +01:00
|
|
|
parser = argparse.ArgumentParser(description='Run sample build on buildkite.')
|
2022-11-28 11:31:43 +01:00
|
|
|
parser.add_argument('--dryrun', action='store_true')
|
2023-07-17 13:19:09 +02:00
|
|
|
parser.add_argument('--commit')
|
2023-07-17 15:38:21 +02:00
|
|
|
parser.add_argument('--pipeline', default='llvm-main')
|
|
|
|
|
2022-11-28 11:31:43 +01:00
|
|
|
args = parser.parse_args()
|
2023-07-17 15:38:21 +02:00
|
|
|
|
|
|
|
pipeline=args.pipeline
|
2023-07-17 13:19:09 +02:00
|
|
|
time.sleep(2)
|
2022-11-28 11:31:43 +01:00
|
|
|
d = json.dumps({
|
|
|
|
'branch': 'main',
|
2023-07-17 13:19:09 +02:00
|
|
|
'commit': args.commit,
|
2023-04-21 10:15:01 +02:00
|
|
|
'env': {
|
2022-11-28 11:31:43 +01:00
|
|
|
'ph_log_level': 'DEBUG',
|
2022-12-25 14:57:47 +01:00
|
|
|
#'ph_skip_linux': 'skip',
|
2023-07-17 15:38:21 +02:00
|
|
|
'ph_linux_agents': '{"queue": "linux-test-google"}',
|
2023-04-21 10:15:01 +02:00
|
|
|
#'ph_linux_agents': '{"queue": "linux-test"}',
|
2022-12-25 14:57:47 +01:00
|
|
|
# 'ph_linux_agents': '{"queue": "linux-clang15-test"}',
|
2023-04-21 10:15:01 +02:00
|
|
|
'ph_skip_windows': 'skip',
|
2023-03-07 16:16:13 +01:00
|
|
|
#'ph_windows_agents': f'{{"name": "win-dev", "queue": "windows-test"}}',
|
2023-04-21 10:15:01 +02:00
|
|
|
# 'ph_windows_agents': '{"queue": "windows-test"}',
|
2022-12-09 11:01:16 +01:00
|
|
|
# 'ph_scripts_refspec': 'windows-vscmd',
|
2023-03-15 10:55:11 +01:00
|
|
|
# 'ph_projects': 'all',
|
|
|
|
'ph_skip_generated': 'skip',
|
2022-12-25 14:57:47 +01:00
|
|
|
# 'ph_windows_agents': f'{{"name": "", "queue": "{queue}"}}',
|
2022-11-28 11:31:43 +01:00
|
|
|
}})
|
|
|
|
print(d)
|
|
|
|
if (args.dryrun):
|
|
|
|
exit(0)
|
|
|
|
token = os.getenv('BUILDKITE_API_TOKEN')
|
|
|
|
if token is None:
|
|
|
|
print("'BUILDKITE_API_TOKEN' environment variable is not set")
|
|
|
|
exit(1)
|
2023-07-17 13:19:09 +02:00
|
|
|
re = requests.post(f'https://api.buildkite.com/v2/organizations/llvm-project/pipelines/{pipeline}/builds',
|
2022-11-28 11:31:43 +01:00
|
|
|
data=d,
|
|
|
|
headers={'Authorization': f'Bearer {token}'})
|
|
|
|
print(re.status_code)
|
2022-12-09 11:01:16 +01:00
|
|
|
j = re.json()
|
|
|
|
print(j['web_url'])
|