|
28 | 28 | } |
29 | 29 | # Version to use for all the base Docker images, see |
30 | 30 | # https://github.com/DataDog/dd-trace-java-docker-build/pkgs/container/dd-trace-java-docker-build |
31 | | -DOCKER_IMAGE_VERSION="v24.01" |
| 31 | +DOCKER_IMAGE_VERSION = "v24.01" |
32 | 32 |
|
33 | 33 | # Get labels from pull requests to override some defaults for jobs to run. |
34 | 34 | # `run-tests: all` will run all tests. |
|
52 | 52 | ) |
53 | 53 | resp.raise_for_status() |
54 | 54 | except Exception as e: |
55 | | - print(f"Request filed: {e}") |
| 55 | + print(f"Request failed: {e}") |
56 | 56 | time.sleep(1) |
57 | 57 | continue |
58 | 58 | data = resp.json() |
|
63 | 63 | labels = { |
64 | 64 | l.replace("run-tests: ", "") for l in labels if l.startswith("run-tests: ") |
65 | 65 | } |
| 66 | + # get the base reference (e.g. `master`), commit hash is also available at the `sha` field. |
| 67 | + pr_base_ref = data.get("base", {}).get("ref") |
66 | 68 | else: |
67 | 69 | labels = set() |
68 | 70 |
|
69 | | - |
70 | 71 | branch = os.environ.get("CIRCLE_BRANCH", "") |
71 | | -if branch == "master" or branch.startswith("release/v") or "all" in labels: |
| 72 | +run_all = "all" in labels |
| 73 | +is_master_or_release = branch == "master" or branch.startswith("release/v") |
| 74 | + |
| 75 | +if is_master_or_release or run_all: |
72 | 76 | all_jdks = ALWAYS_ON_JDKS | MASTER_ONLY_JDKS |
73 | 77 | else: |
74 | 78 | all_jdks = ALWAYS_ON_JDKS | (MASTER_ONLY_JDKS & labels) |
|
83 | 87 | is_weekly = os.environ.get("CIRCLE_IS_WEEKLY", "false") == "true" |
84 | 88 | is_regular = not is_nightly and not is_weekly |
85 | 89 |
|
| 90 | +# Use git changes detection on PRs |
| 91 | +use_git_changes = not run_all and not is_master_or_release and is_regular |
| 92 | + |
86 | 93 | vars = { |
87 | 94 | "is_nightly": is_nightly, |
88 | 95 | "is_weekly": is_weekly, |
|
92 | 99 | "nocov_jdks": nocov_jdks, |
93 | 100 | "flaky": branch == "master" or "flaky" in labels or "all" in labels, |
94 | 101 | "docker_image_prefix": "" if is_nightly else f"{DOCKER_IMAGE_VERSION}-", |
| 102 | + "use_git_changes": use_git_changes, |
| 103 | + "pr_base_ref": pr_base_ref, |
95 | 104 | } |
96 | 105 |
|
97 | 106 | print(f"Variables for this build: {vars}") |
98 | 107 |
|
99 | 108 | loader = jinja2.FileSystemLoader(searchpath=SCRIPT_DIR) |
100 | | -env = jinja2.Environment(loader=loader) |
| 109 | +env = jinja2.Environment(loader=loader, trim_blocks=True) |
101 | 110 | tpl = env.get_template(TPL_FILENAME) |
102 | 111 | out = tpl.render(**vars) |
103 | 112 |
|
|
0 commit comments