Skip to content

Commit

Permalink
chore(buildkite): separate docs only changes (#8261)
Browse files Browse the repository at this point in the history
  • Loading branch information
rexledesma committed Jun 8, 2022
1 parent ca009fc commit 90fd674
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
import logging
import os
import subprocess
from typing import List
from typing import List, Tuple

from dagster_buildkite.defines import DO_COVERAGE
from dagster_buildkite.steps.coverage import build_coverage_step
from dagster_buildkite.steps.dagit_ui import build_dagit_ui_steps
from dagster_buildkite.steps.dagster import build_dagster_steps
from dagster_buildkite.steps.docs import build_docs_steps
from dagster_buildkite.steps.integration import build_integration_steps
from dagster_buildkite.steps.trigger import build_trigger_step
from dagster_buildkite.steps.wait import build_wait_step
from dagster_buildkite.utils import BuildkiteStep, is_feature_branch, safe_getenv

_DAGIT_PATHES = ("js_modules/dagit",)
_DOCS_PATHES = ("examples", "docs")

logging.basicConfig(
format="%(asctime)s %(levelname)-8s %(message)s",
level=os.getenv("LOGLEVEL", "INFO"),
datefmt="%Y-%m-%d %H:%M:%S",
)


def build_dagster_oss_main_steps() -> List[BuildkiteStep]:

Expand All @@ -19,7 +30,8 @@ def build_dagster_oss_main_steps() -> List[BuildkiteStep]:
build_creator_email = os.getenv("BUILDKITE_BUILD_CREATOR_EMAIL")
oss_contribution = os.getenv("OSS_CONTRIBUTION")
do_coverage = DO_COVERAGE
dagit_ui_only_diff = _is_dagit_ui_only_diff()
dagit_ui_only_diff = _is_path_only_diff(paths=_DAGIT_PATHES)
docs_only_diff = _is_path_only_diff(paths=_DOCS_PATHES)

steps: List[BuildkiteStep] = []

Expand Down Expand Up @@ -56,11 +68,17 @@ def build_dagster_oss_main_steps() -> List[BuildkiteStep]:
)

# Skip non-dagit-ui steps if we are on a feature branch with only dagit-ui (web app) changes.
logging.info(f"dagit_ui_only: {dagit_ui_only_diff}, docs_only: {docs_only_diff}")
if is_feature_branch(branch_name) and dagit_ui_only_diff:
steps += build_dagit_ui_steps()

# Skip non-docs steps if we are on a feature branch with only docs changes.
elif is_feature_branch(branch_name) and docs_only_diff:
steps += build_docs_steps()

# Full pipeline.
else:
steps += build_docs_steps()
steps += build_dagit_ui_steps()
steps += build_dagster_steps()
steps += build_integration_steps()
Expand All @@ -72,10 +90,7 @@ def build_dagster_oss_main_steps() -> List[BuildkiteStep]:
return steps


_DAGIT_PATH = "js_modules/dagit"


def _is_dagit_ui_only_diff() -> bool:
def _is_path_only_diff(paths: Tuple[str, ...]) -> bool:
base_branch = safe_getenv("BUILDKITE_PULL_REQUEST_BASE_BRANCH")

try:
Expand All @@ -87,7 +102,7 @@ def _is_dagit_ui_only_diff() -> bool:
.strip()
.split("\n")
)
return all(filepath.startswith(_DAGIT_PATH) for (filepath) in diff_files)
return all(filepath.startswith(paths) for (filepath) in diff_files)

except subprocess.CalledProcessError:
return False
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
from ..python_version import AvailablePythonVersion
from ..step_builder import CommandStepBuilder
from ..utils import BuildkiteStep, CommandStep, safe_getenv
from .docs import build_docs_steps
from .helm import build_helm_steps
from .packages import build_packages_steps
from .packages import build_library_packages_steps
from .test_images import build_test_image_steps

branch_name = safe_getenv("BUILDKITE_BRANCH")
Expand All @@ -24,15 +23,14 @@ def build_dagster_steps() -> List[BuildkiteStep]:
# "Package" used loosely here to mean roughly "a directory with some python modules". For
# instances, a directory of unrelated scripts counts as a package. All packages must have a
# toxfile that defines the tests for that package.
steps += build_packages_steps()
steps += build_library_packages_steps()

# Other linters are run in per-package environments because they rely on the dependencies of the
# target. `black`, `isort`, and `check-manifest` are run for the whole repo at once.
steps += build_repo_wide_isort_steps()
steps += build_repo_wide_black_steps()
steps += build_repo_wide_check_manifest_steps()

steps += build_docs_steps()
steps += build_helm_steps()
steps += build_sql_schema_check_steps()
steps += build_graphql_python_client_backcompat_steps()
Expand Down
16 changes: 11 additions & 5 deletions .buildkite/dagster-buildkite/dagster_buildkite/steps/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

from ..python_version import AvailablePythonVersion
from ..step_builder import CommandStepBuilder
from ..utils import BuildkiteLeafStep, GroupStep
from ..utils import BuildkiteLeafStep, BuildkiteStep, GroupStep
from .packages import build_example_packages_steps


def build_docs_steps() -> List[GroupStep]:
def build_docs_steps() -> List[BuildkiteStep]:
steps: List[BuildkiteStep] = []

steps: List[BuildkiteLeafStep] = [
docs_steps: List[BuildkiteLeafStep] = [
# Make sure snippets in built docs match source.
# If this test is failing, it's because you may have either:
# (1) Updated the code that is referenced by a literal include in the documentation
Expand Down Expand Up @@ -50,10 +52,14 @@ def build_docs_steps() -> List[GroupStep]:
# pylint for build scripts
build_tox_step("docs", "pylint", command_type="pylint"),
]
return [
steps += [
GroupStep(
group=":book: docs",
key="docs",
steps=steps,
steps=docs_steps,
)
]

steps += build_example_packages_steps()

return steps
44 changes: 31 additions & 13 deletions .buildkite/dagster-buildkite/dagster_buildkite/steps/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,45 @@
)


def build_packages_steps() -> List[BuildkiteStep]:
def build_example_packages_steps() -> List[BuildkiteStep]:
custom_example_pkg_roots = [pkg.directory for pkg in EXAMPLE_PACKAGES_WITH_CUSTOM_CONFIG]
example_packages_with_standard_config = [
PackageSpec(
pkg,
upload_coverage=False,
)
for pkg in _get_uncustomized_pkg_roots("examples", custom_example_pkg_roots)
]

return _build_steps_from_package_specs(
EXAMPLE_PACKAGES_WITH_CUSTOM_CONFIG + example_packages_with_standard_config
)

custom_pkg_roots = [pkg.directory for pkg in PACKAGES_WITH_CUSTOM_CONFIG]
packages_with_standard_config = [

def build_library_packages_steps() -> List[BuildkiteStep]:
custom_library_pkg_roots = [pkg.directory for pkg in LIBRARY_PACKAGES_WITH_CUSTOM_CONFIG]
library_packages_with_standard_config = [
*[
PackageSpec(pkg, upload_coverage=False)
for pkg in _get_uncustomized_pkg_roots("python_modules", custom_pkg_roots)
for pkg in _get_uncustomized_pkg_roots("python_modules", custom_library_pkg_roots)
],
*[
PackageSpec(pkg)
for pkg in _get_uncustomized_pkg_roots("python_modules/libraries", custom_pkg_roots)
],
*[
PackageSpec(
pkg,
upload_coverage=False,
for pkg in _get_uncustomized_pkg_roots(
"python_modules/libraries", custom_library_pkg_roots
)
for pkg in _get_uncustomized_pkg_roots("examples", custom_pkg_roots)
],
]

return _build_steps_from_package_specs(
LIBRARY_PACKAGES_WITH_CUSTOM_CONFIG + library_packages_with_standard_config
)


def _build_steps_from_package_specs(package_specs: List[PackageSpec]) -> List[BuildkiteStep]:
steps: List[BuildkiteStep] = []
all_packages = sorted(
PACKAGES_WITH_CUSTOM_CONFIG + packages_with_standard_config,
package_specs,
key=lambda p: f"{_PACKAGE_TYPE_ORDER.index(p.package_type)} {p.name}",
)
for pkg in all_packages:
Expand Down Expand Up @@ -299,7 +314,7 @@ def k8s_extra_cmds(version: str, _) -> List[str]:

# Some Dagster packages have more involved test configs or support only certain Python version;
# special-case those here
PACKAGES_WITH_CUSTOM_CONFIG: List[PackageSpec] = [
EXAMPLE_PACKAGES_WITH_CUSTOM_CONFIG: List[PackageSpec] = [
PackageSpec(
"examples/airflow_ingest",
unsupported_python_versions=[AvailablePythonVersion.V3_9],
Expand Down Expand Up @@ -356,6 +371,9 @@ def k8s_extra_cmds(version: str, _) -> List[str]:
AvailablePythonVersion.V3_6,
],
),
]

LIBRARY_PACKAGES_WITH_CUSTOM_CONFIG: List[PackageSpec] = [
PackageSpec("python_modules/automation"),
PackageSpec("python_modules/dagit", pytest_extra_cmds=dagit_extra_cmds),
PackageSpec(
Expand Down

0 comments on commit 90fd674

Please sign in to comment.