Skip to content

Commit

Permalink
Optimize CI jobs when for example only pre-commits change in scripts (#…
Browse files Browse the repository at this point in the history
…37308)

(cherry picked from commit cb65c38)
  • Loading branch information
potiuk committed Feb 12, 2024
1 parent a9b7fea commit ec4fb1a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dev/breeze/src/airflow_breeze/utils/selective_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ def __hash__(self):
r"^dev/breeze",
r"^dev/.*\.py$",
r"^Dockerfile",
r"^scripts",
r"^scripts/ci/docker-compose",
r"^scripts/ci/kubernetes",
r"^scripts/docker",
r"^scripts/in_container",
r"^generated/provider_dependencies.json$",
],
FileGroupForCi.PYTHON_PRODUCTION_FILES: [
Expand Down
51 changes: 51 additions & 0 deletions dev/breeze/tests/test_selective_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,57 @@ def test_full_test_needed_when_pyproject_toml_changes(
assert_outputs_are_printed(expected_outputs, str(stderr))


@pytest.mark.parametrize(
"files, expected_outputs",
[
(
pytest.param(
("scripts/ci/pre_commit/file.sh",),
{
"full-tests-needed": "false",
},
id="No full tests needed when pre-commit scripts change",
)
),
(
pytest.param(
("scripts/docker-compose/test.yml",),
{
"full-tests-needed": "true",
},
id="Full tests needed when docker-compose changes",
)
),
(
pytest.param(
("scripts/ci/kubernetes/some_file.txt",),
{
"full-tests-needed": "true",
},
id="Full tests needed when ci/kubernetes changes",
)
),
(
pytest.param(
("scripts/in_container/script.sh",),
{
"full-tests-needed": "true",
},
id="Full tests needed when in_container script changes",
)
),
],
)
def test_full_test_needed_when_scripts_changes(files: tuple[str, ...], expected_outputs: dict[str, str]):
stderr = SelectiveChecks(
files=files,
github_event=GithubEvents.PULL_REQUEST,
commit_ref="HEAD",
default_branch="main",
)
assert_outputs_are_printed(expected_outputs, str(stderr))


@pytest.mark.parametrize(
"files, pr_labels, default_branch, expected_outputs,",
[
Expand Down

0 comments on commit ec4fb1a

Please sign in to comment.