Skip to content

Commit

Permalink
[BK] Add overrides arg to skip_if_no_python_changes, use to whitelist…
Browse files Browse the repository at this point in the history
… pyright dir for pyright (dagster-io#20411)

## Summary & Motivation

Add `overrides` to `skip_if_no_python_changes`, which allows opting out
of this behavior for specified directories. Use this to run pyright
steps for changes to the pyright dir.

## How I Tested These Changes

Upstack PR changes only pyright, runs pyright steps.
  • Loading branch information
smackesey authored Mar 11, 2024
1 parent 2a9e0f9 commit 398c216
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def build_repo_wide_pyright_steps() -> List[CommandStep]:
"make pyright",
)
.on_test_image(AvailablePythonVersion.get_default())
.with_skip(skip_if_no_python_changes())
.with_skip(skip_if_no_python_changes(overrides=["pyright"]))
.build(),
]

Expand Down
9 changes: 7 additions & 2 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 os
import subprocess
from pathlib import Path
from typing import Dict, List, Optional, Union
from typing import Dict, List, Optional, Sequence, Union

import packaging.version
import yaml
Expand Down Expand Up @@ -193,13 +193,18 @@ def get_commit(rev):
return subprocess.check_output(["git", "rev-parse", "--short", rev]).decode("utf-8").strip()


def skip_if_no_python_changes():
def skip_if_no_python_changes(overrides: Optional[Sequence[str]] = None):
if not is_feature_branch():
return None

if any(path.suffix == ".py" for path in ChangedFiles.all):
return None

if overrides and any(
Path(override) in path.parents for override in overrides for path in ChangedFiles.all
):
return None

return "No python changes"


Expand Down

0 comments on commit 398c216

Please sign in to comment.