This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 54619a54ad Speed up testing of CI workflow changes (#37868)
54619a54ad is described below
commit 54619a54add61b9f2b6bd0ab822d24312a92dbe0
Author: Jarek Potiuk <[email protected]>
AuthorDate: Sun Mar 3 17:54:31 2024 +0100
Speed up testing of CI workflow changes (#37868)
Testing CI workflows takes a LOT of time and resources. When changing
workflows we run "full tests needed" workflow, but we really need
only to see if the single-python version is working.
This PR adds support for "default versions only" label that will
override the choice of python versions and kubernetes versions
if "full tests needed" is derived - to only default python version
and default kubernetes version.
---
dev/breeze/doc/ci/04_selective_checks.md | 20 +++++++------
dev/breeze/doc/ci/07_debugging.md | 5 ++++
.../src/airflow_breeze/utils/selective_checks.py | 11 ++++++--
dev/breeze/tests/test_selective_checks.py | 33 ++++++++++++++++++++++
4 files changed, 58 insertions(+), 11 deletions(-)
diff --git a/dev/breeze/doc/ci/04_selective_checks.md
b/dev/breeze/doc/ci/04_selective_checks.md
index b80969ba0f..2c6c3e0133 100644
--- a/dev/breeze/doc/ci/04_selective_checks.md
+++ b/dev/breeze/doc/ci/04_selective_checks.md
@@ -264,20 +264,24 @@ Also, for most of the jobs, committer builds by default
use "Self-hosted" runner
builds use "Public" runners. For committers, this can be overridden by setting
the
`use public runners` label in the PR.
+If you are testing ci workflow changes and want to limit the number of matrix
combinations generated by
+the jobs - you can set `default versions only` label in the PR. This will
limit the number of versions
+used in the matrix to the default ones (default Python version and default
Kubernetes version).
## PR labels
As mentioned below, you can influence the outputs of selected checks by
setting labels to the PR. Here is
am overview of possible labels and their meaning:
-| Label | Affected outputs | Meaning
|
-|-------------------------------|-------------------------------|-------------------------------------------------------------------------------------------------------|
-| canary | is-canary-run | If set, the
PR run from apache/airflow repo behaves as `canary` run (can only be run by
maintainer). |
-| debug ci resources | debug-ci-resources | If set, then
debugging resources is enabled during parallel tests and you can see them in
the output. |
-| full tests needed | full-tests-needed | Run complete
set of tests, including all Python all DB versions, and all test types.
|
-| non committer build | is-committer-build | If set then
even for non-committer builds, the scripts used for images are used from target
branch. |
-| upgrade to newer dependencies | upgrade-to-newer-dependencies | If set then
dependencies in the CI image build are upgraded to the newer ones.
|
-| use public runners | runs-on | Force using
public runners even for Committer runs.
|
+| Label | Affected outputs |
Meaning
|
+|-------------------------------|------------------------------------------|--------------------------------------------------------------------------------------------------------|
+| canary | is-canary-run |
If set, the PR run from apache/airflow repo behaves as `canary` run (can only
be run by maintainer). |
+| debug ci resources | debug-ci-resources |
If set, then debugging resources is enabled during parallel tests and you can
see them in the output. |
+| default versions only | python-versions-*, kubernetes-versions-* |
If set, the number of Python and Kubernetes versions used by the build will be
limitd to default ones. |
+| full tests needed | full-tests-needed |
Run complete set of tests, including all Python all DB versions, and all test
types. |
+| non committer build | is-committer-build |
If set then even for non-committer builds, the scripts used for images are used
from target branch. |
+| upgrade to newer dependencies | upgrade-to-newer-dependencies |
If set then dependencies in the CI image build are upgraded to the newer ones.
|
+| use public runners | runs-on |
Force using public runners even for Committer runs.
|
-----
diff --git a/dev/breeze/doc/ci/07_debugging.md
b/dev/breeze/doc/ci/07_debugging.md
index fee9e17485..94ffd99329 100644
--- a/dev/breeze/doc/ci/07_debugging.md
+++ b/dev/breeze/doc/ci/07_debugging.md
@@ -53,6 +53,11 @@ maintainer.
your fork. This will run the images as part of the `CI` workflow
rather than using `Build images` workflow and use the same breeze
version for building image and testing
+- When you want to test changes to workflows and CI scripts you can set
+ `default versions only` label to the PR. This will make the PR run
+ using the default versions of Python and Kubernetes. This is useful
+ when you want to test changes to the CI scripts and workflows and you
+ want to use far less resources than the full tests.
- When you want to test changes to `build-images.yml` workflow you
should push your branch as `main` branch in your local fork. This will
run changed `build-images.yml` workflow as it will be in `main` branch
diff --git a/dev/breeze/src/airflow_breeze/utils/selective_checks.py
b/dev/breeze/src/airflow_breeze/utils/selective_checks.py
index 8886a5cb94..da6b8ffb43 100644
--- a/dev/breeze/src/airflow_breeze/utils/selective_checks.py
+++ b/dev/breeze/src/airflow_breeze/utils/selective_checks.py
@@ -66,6 +66,7 @@ FULL_TESTS_NEEDED_LABEL = "full tests needed"
DEBUG_CI_RESOURCES_LABEL = "debug ci resources"
USE_PUBLIC_RUNNERS_LABEL = "use public runners"
NON_COMMITTER_BUILD_LABEL = "non committer build"
+DEFAULT_VERSIONS_ONLY_LABEL = "default versions only"
UPGRADE_TO_NEWER_DEPENDENCIES_LABEL = "upgrade to newer dependencies"
ALL_CI_SELECTIVE_TEST_TYPES = (
@@ -446,7 +447,7 @@ class SelectiveChecks:
def python_versions(self) -> list[str]:
return (
CURRENT_PYTHON_MAJOR_MINOR_VERSIONS
- if self.full_tests_needed
+ if self.full_tests_needed and DEFAULT_VERSIONS_ONLY_LABEL not in
self._pr_labels
else [DEFAULT_PYTHON_MAJOR_MINOR_VERSION]
)
@@ -458,7 +459,7 @@ class SelectiveChecks:
def all_python_versions(self) -> list[str]:
return (
ALL_PYTHON_MAJOR_MINOR_VERSIONS
- if self.full_tests_needed
+ if self.full_tests_needed and DEFAULT_VERSIONS_ONLY_LABEL not in
self._pr_labels
else [DEFAULT_PYTHON_MAJOR_MINOR_VERSION]
)
@@ -514,7 +515,11 @@ class SelectiveChecks:
@cached_property
def kubernetes_versions(self) -> list[str]:
- return CURRENT_KUBERNETES_VERSIONS if self.full_tests_needed else
[DEFAULT_KUBERNETES_VERSION]
+ return (
+ CURRENT_KUBERNETES_VERSIONS
+ if (self.full_tests_needed and "default versions only" not in
self._pr_labels)
+ else [DEFAULT_KUBERNETES_VERSION]
+ )
@cached_property
def kubernetes_versions_list_as_string(self) -> str:
diff --git a/dev/breeze/tests/test_selective_checks.py
b/dev/breeze/tests/test_selective_checks.py
index 7f0df24123..e016c5696c 100644
--- a/dev/breeze/tests/test_selective_checks.py
+++ b/dev/breeze/tests/test_selective_checks.py
@@ -710,6 +710,9 @@ def test_full_test_needed_when_scripts_changes(files:
tuple[str, ...], expected_
"all-python-versions-list-as-string": "3.8 3.9 3.10 3.11",
"python-versions": "['3.8', '3.9', '3.10', '3.11']",
"python-versions-list-as-string": "3.8 3.9 3.10 3.11",
+ "kubernetes-versions": "['v1.25.16', 'v1.26.14',
'v1.27.11', 'v1.28.7', 'v1.29.2']",
+ "kubernetes-versions-list-as-string": "v1.25.16 v1.26.14
v1.27.11 v1.28.7 v1.29.2",
+ "kubernetes-combos-list-as-string": "3.8-v1.25.16
3.9-v1.26.14 3.10-v1.27.11 3.11-v1.28.7 3.8-v1.29.2",
"ci-image-build": "true",
"prod-image-build": "true",
"run-tests": "true",
@@ -725,6 +728,36 @@ def test_full_test_needed_when_scripts_changes(files:
tuple[str, ...], expected_
id="Everything should run including all providers when full
tests are needed",
)
),
+ (
+ pytest.param(
+ ("INTHEWILD.md",),
+ ("full tests needed", "default versions only"),
+ "main",
+ {
+ "affected-providers-list-as-string":
ALL_PROVIDERS_AFFECTED,
+ "all-python-versions": "['3.8']",
+ "all-python-versions-list-as-string": "3.8",
+ "python-versions": "['3.8']",
+ "python-versions-list-as-string": "3.8",
+ "kubernetes-versions": "['v1.25.16']",
+ "kubernetes-versions-list-as-string": "v1.25.16",
+ "kubernetes-combos-list-as-string": "3.8-v1.25.16",
+ "ci-image-build": "true",
+ "prod-image-build": "true",
+ "run-tests": "true",
+ "docs-build": "true",
+ "docs-list-as-string": ALL_DOCS_SELECTED_FOR_BUILD,
+ "full-tests-needed": "true",
+ "skip-pre-commits":
"identity,mypy-core,mypy-dev,mypy-docs,mypy-providers",
+ "upgrade-to-newer-dependencies": "false",
+ "parallel-test-types-list-as-string":
ALL_CI_SELECTIVE_TEST_TYPES,
+ "needs-mypy": "true",
+ "mypy-folders": "['airflow', 'providers', 'docs', 'dev']",
+ },
+ id="Everything should run including all providers when full
tests are needed "
+ "but with single python and kubernetes if `default versions
only` label is set",
+ )
+ ),
(
pytest.param(
("INTHEWILD.md",),