-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: compare benchmarks against common-ancestor (#22355)
- Loading branch information
1 parent
d011460
commit d1ac42c
Showing
11 changed files
with
225 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,8 @@ set -euo pipefail | |
export BUILDKITE_REPO_REF="${BUILDKITE_REPO_REF:-origin}" | ||
export BUILDKITE_PULL_REQUEST_BASE_BRANCH="${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-main}" | ||
|
||
configure_git_user() { | ||
if [[ "$BUILDKITE" == "true" ]]; then | ||
configure_git_user_if_in_buildkite() { | ||
if [[ "${BUILDKITE:-}" == "true" ]]; then | ||
ci_collapsed_heading "Configure git" | ||
run git config --global user.email "[email protected]" | ||
run git config --global user.name "Buildkite" | ||
|
@@ -30,7 +30,7 @@ fetch_pr_target_branch() { | |
} | ||
|
||
merge_pr_target_branch() { | ||
configure_git_user | ||
configure_git_user_if_in_buildkite | ||
|
||
ci_collapsed_heading "Merge target branch" | ||
run git merge "$BUILDKITE_REPO_REF"/"$BUILDKITE_PULL_REQUEST_BASE_BRANCH" --message "Merge" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright Materialize, Inc. and contributors. All rights reserved. | ||
# | ||
# Use of this software is governed by the Business Source License | ||
# included in the LICENSE file at the root of this repository. | ||
# | ||
# As of the Change Date specified in that file, in accordance with | ||
# the Business Source License, use of this software will be governed | ||
# by the Apache License, Version 2.0. | ||
|
||
"""Benchmark utilities.""" | ||
|
||
from materialize import buildkite | ||
|
||
|
||
def resolve_tag_of_common_ancestor(tag_when_on_default_branch: str = "latest") -> str: | ||
if buildkite.is_on_default_branch(): | ||
print(f"On default branch, using {tag_when_on_default_branch} as tag") | ||
return tag_when_on_default_branch | ||
else: | ||
commit_hash = buildkite.get_merge_base() | ||
tag = f"unstable-{commit_hash}" | ||
print(f"Resolved common-ancestor to {tag} (commit: {commit_hash})") | ||
return tag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright Materialize, Inc. and contributors. All rights reserved. | ||
# | ||
# Use of this software is governed by the Business Source License | ||
# included in the LICENSE file at the root of this repository. | ||
# | ||
# As of the Change Date specified in that file, in accordance with | ||
# the Business Source License, use of this software will be governed | ||
# by the Apache License, Version 2.0. | ||
|
||
"""Buildkite utilities.""" | ||
|
||
import os | ||
|
||
from materialize import git | ||
|
||
|
||
def is_in_buildkite() -> bool: | ||
return os.getenv("BUILDKITE", "false") == "true" | ||
|
||
|
||
def is_in_pull_request() -> bool: | ||
""" | ||
Note that this does not work in (manually triggered) nightly builds because they don't carry this information! | ||
Consider using #is_on_default_branch() instead. | ||
""" | ||
return os.getenv("BUILDKITE_PULL_REQUEST", "false") != "false" | ||
|
||
|
||
def is_on_default_branch() -> bool: | ||
current_branch = os.getenv("BUILDKITE_BRANCH", "unknown") | ||
default_branch = os.getenv("BUILDKITE_PIPELINE_DEFAULT_BRANCH", "main") | ||
return current_branch == default_branch | ||
|
||
|
||
def get_pull_request_base_branch(fallback: str = "main"): | ||
return os.getenv("BUILDKITE_PULL_REQUEST_BASE_BRANCH", fallback) | ||
|
||
|
||
def get_pipeline_default_branch(fallback: str = "main"): | ||
return os.getenv("BUILDKITE_PIPELINE_DEFAULT_BRANCH", fallback) | ||
|
||
|
||
def get_merge_base(remote="origin") -> str: | ||
base_branch = get_pull_request_base_branch() or get_pipeline_default_branch() | ||
merge_base = git.get_common_ancestor_commit( | ||
remote, branch=base_branch, fetch_branch=True | ||
) | ||
return merge_base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.