firecracker
136 строк · 3.3 Кб
1#!/usr/bin/env python3
2# Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3# SPDX-License-Identifier: Apache-2.0
4
5"""Generate Buildkite pipelines dynamically"""
6
7from common import (8COMMON_PARSER,9devtool_test,10get_changed_files,11group,12overlay_dict,13pipeline_to_json,14run_all_tests,15)
16
17# Buildkite default job priority is 0. Setting this to 1 prioritizes PRs over
18# scheduled jobs and other batch jobs.
19DEFAULT_PRIORITY = 120
21
22args = COMMON_PARSER.parse_args()23
24step_style = {25"command": "./tools/devtool -y test -- ../tests/integration_tests/style/",26"label": "🪶 Style",27"priority": DEFAULT_PRIORITY,28}
29
30defaults = {31"instances": args.instances,32"platforms": args.platforms,33# buildkite step parameters34"priority": DEFAULT_PRIORITY,35"timeout_in_minutes": 45,36"artifacts": ["./test_results/**/*"],37}
38defaults = overlay_dict(defaults, args.step_param)39
40defaults_once_per_architecture = defaults.copy()41defaults_once_per_architecture["instances"] = ["m6i.metal", "m7g.metal"]42defaults_once_per_architecture["platforms"] = [("al2", "linux_5.10")]43
44
45devctr_grp = group(46"🐋 Dev Container Sanity Build",47"./tools/devtool -y build_devctr",48**defaults_once_per_architecture,49)
50
51release_grp = group(52"📦 Release Sanity Build",53"./tools/devtool -y make_release",54**defaults_once_per_architecture,55)
56
57build_grp = group(58"📦 Build",59"./tools/devtool -y test -- ../tests/integration_tests/build/",60**defaults,61)
62
63functional_grp = group(64"⚙ Functional and security 🔒",65devtool_test(66pytest_opts="-n 8 --dist worksteal integration_tests/{{functional,security}}",67binary_dir=args.binary_dir,68),69**defaults,70)
71
72defaults_for_performance = overlay_dict(73defaults,74{75# We specify higher priority so the ag=1 jobs get picked up before the ag=n76# jobs in ag=1 agents77"priority": DEFAULT_PRIORITY + 1,78"agents": {"ag": 1},79},80)
81
82performance_grp = group(83"⏱ Performance",84devtool_test(85devtool_opts="--performance -c 1-10 -m 0",86pytest_opts="../tests/integration_tests/performance/",87binary_dir=args.binary_dir,88),89**defaults_for_performance,90)
91
92defaults_for_kani = overlay_dict(93defaults_for_performance,94{95# Kani runs fastest on m6i.metal96"instances": ["m6a.metal"],97"platforms": [("al2", "linux_5.10")],98"timeout_in_minutes": 300,99},100)
101
102kani_grp = group(103"🔍 Kani",104"./tools/devtool -y test -- ../tests/integration_tests/test_kani.py -n auto",105**defaults_for_kani,106)
107for step in kani_grp["steps"]:108step["label"] = "🔍 Kani"109
110steps = [step_style]111changed_files = get_changed_files("main")112
113# run sanity build of devtool if Dockerfile is changed
114if any(x.name == "Dockerfile" for x in changed_files):115steps.append(devctr_grp)116
117if any(118x.parent.name == "tools" and ("release" in x.name or x.name == "devtool")119for x in changed_files120):121steps.append(release_grp)122
123if not changed_files or any(124x.suffix in [".rs", ".toml", ".lock"] for x in changed_files125):126steps.append(kani_grp)127
128if run_all_tests(changed_files):129steps += [130build_grp,131functional_grp,132performance_grp,133]134
135pipeline = {"steps": steps}136print(pipeline_to_json(pipeline))137