Skip to content

Commit

Permalink
Improve Buildkite test version specification API (#7699)
Browse files Browse the repository at this point in the history
  • Loading branch information
smackesey committed May 3, 2022
1 parent 2a579a6 commit 2f828aa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
8 changes: 8 additions & 0 deletions .buildkite/dagster-buildkite/dagster_buildkite/defines.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ class SupportedPython:
SupportedPython.V3_6: "py36",
}

VERSION_TEST_DIRECTIVES = {
"test-py36": [SupportedPython.V3_6],
"test-py37": [SupportedPython.V3_7],
"test-py38": [SupportedPython.V3_8],
"test-py39": [SupportedPython.V3_9],
"test-all": SupportedPythons,
}


# https://github.com/dagster-io/dagster/issues/1662
DO_COVERAGE = True
Expand Down
24 changes: 12 additions & 12 deletions .buildkite/dagster-buildkite/dagster_buildkite/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import yaml

from .defines import SupportedPython, SupportedPythons
from .defines import VERSION_TEST_DIRECTIVES, SupportedPython, SupportedPythons

DAGIT_PATH = "js_modules/dagit"

Expand Down Expand Up @@ -98,10 +98,6 @@ def is_release_branch(branch_name: str):
return branch_name.startswith("release-")


# To test the full suite of Python versions on a PR, include this string anywhere in the branch name
# or commit message.
FULL_BUILD_MARKER_STR = "fullbuild"

# To more specifically customize the tested Python versions for a branch, set environment variable
# $DEFAULT_PYTHON_VERSIONS to a comma-separated list of python version specifiers of the form VX_Y
# (i.e. attributes of `SupportedPython`).
Expand All @@ -111,19 +107,23 @@ def is_release_branch(branch_name: str):
# By default only one representative Python version is tested on PRs, and all versions are
# tested on master or release branches.
def get_python_versions_for_branch(pr_versions=None):
pr_versions = pr_versions if pr_versions != None else DEFAULT_PYTHON_VERSIONS

branch_name = os.getenv("BUILDKITE_BRANCH")
assert branch_name is not None, "$BUILDKITE_BRANCH env var must be set."
commit_message = os.getenv("BUILDKITE_MESSAGE")
assert commit_message is not None, "$BUILDKITE_MESSAGE env var must be set."

if (
branch_name == "master"
or is_release_branch(branch_name)
or FULL_BUILD_MARKER_STR in branch_name
or FULL_BUILD_MARKER_STR in commit_message
):
if branch_name == "master" or is_release_branch(branch_name):
return SupportedPythons
elif pr_versions is None:
specified_versions = []
for k, v in VERSION_TEST_DIRECTIVES.items():
if k in commit_message or k in branch_name:
specified_versions.extend(v)
return (
list(set(specified_versions))
if len(specified_versions) > 0
else DEFAULT_PYTHON_VERSIONS
)
else:
return pr_versions

0 comments on commit 2f828aa

Please sign in to comment.