-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restructuring files in selective check
- Loading branch information
Showing
6 changed files
with
245 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
dev/breeze/src/airflow_breeze/build_image/ci/selective_checks/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
"""Selective Check.""" |
68 changes: 68 additions & 0 deletions
68
dev/breeze/src/airflow_breeze/build_image/ci/selective_checks/selective_ci_checks.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
import os | ||
import os.path | ||
|
||
import click | ||
|
||
from airflow_breeze.build_image.ci.selective_checks.utilities import get_changed_files | ||
from airflow_breeze.build_image.ci.selective_checks.validate_selective_checks import ( | ||
check_if_any_py_files_changed, | ||
validate_github_default_branch, | ||
validate_github_sha, | ||
) | ||
|
||
GITHUB_SHA = os.environ.get('GITHUB_SHA') | ||
DEFAULT_BRANCH = os.environ.get('DEFAULT_BRANCH') | ||
PR_LABELS = os.environ.get('PR_LABELS') | ||
INCOMING_COMMIT_SHA = os.environ.get('GITHUB_SHA') | ||
|
||
|
||
ANY_PY_FILES_CHANGED = r"\.py$" | ||
AIRFLOW_SOURCES_TRIGGERING_TESTS = """ '^.pre-commit-config.yaml$' | ||
'^airflow' | ||
'^chart' | ||
'^tests' | ||
'^kubernetes_tests'""" | ||
upgrade_to_newer_dependencies = "false" | ||
print(AIRFLOW_SOURCES_TRIGGERING_TESTS) | ||
print(ANY_PY_FILES_CHANGED) | ||
|
||
|
||
@click.group() | ||
def main(): | ||
validate_github_sha(GITHUB_SHA) | ||
validate_github_default_branch(DEFAULT_BRANCH) | ||
get_changed_files(INCOMING_COMMIT_SHA) | ||
check_if_any_py_files_changed() | ||
|
||
|
||
@main.command(name='build-image') | ||
def build_image(): | ||
print("BUILD IMAGE") | ||
|
||
|
||
@main.command(name='matrix-strategy') | ||
def matrix_strategy(): | ||
print("PRINT python-versions") | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
63 changes: 63 additions & 0 deletions
63
dev/breeze/src/airflow_breeze/build_image/ci/selective_checks/utilities.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
|
||
import os | ||
import os.path | ||
import subprocess | ||
|
||
INCOMING_COMMIT_SHA = os.environ.get('GITHUB_SHA') | ||
|
||
|
||
def get_changed_files(INCOMING_COMMIT_SHA): | ||
print("") | ||
print(f"Incoming commit SHA: ${INCOMING_COMMIT_SHA}") | ||
print("") | ||
print(f"Changed files from ${INCOMING_COMMIT_SHA} vs it's first parent") | ||
print("") | ||
CHANGED_FILES = ( | ||
subprocess.check_output( | ||
[ | ||
"git", | ||
"diff-tree", | ||
"--no-commit-id", | ||
"--name-only", | ||
"-r", | ||
f"{INCOMING_COMMIT_SHA}^", | ||
f"{INCOMING_COMMIT_SHA}", | ||
] | ||
) | ||
.decode('utf-8') | ||
.strip() | ||
) | ||
|
||
if not CHANGED_FILES: | ||
print("") | ||
# print(f"${COLOR_YELLOW}WARNING: Could not find any changed files ${COLOR_RESET}" | ||
print("WARNING: Could not find any changed files") | ||
print("Assuming that we should run all tests in this case") | ||
print("") | ||
print("set_outputs_run_everything_and_exit") | ||
else: | ||
print("") | ||
print("Changed files:") | ||
print("") | ||
print(CHANGED_FILES) | ||
|
||
return CHANGED_FILES |
81 changes: 81 additions & 0 deletions
81
dev/breeze/src/airflow_breeze/build_image/ci/selective_checks/validate_selective_checks.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
|
||
import os | ||
import os.path | ||
|
||
|
||
from airflow_breeze.build_image.ci.selective_checks.utilities import ( | ||
get_changed_files | ||
) | ||
|
||
INCOMING_COMMIT_SHA = os.environ.get('GITHUB_SHA') | ||
|
||
def validate_pull_request_label(PR_LABELS): | ||
if "full tests needed" in PR_LABELS: | ||
print(f"Found the right PR labels in ${PR_LABELS} : 'full tests needed'") | ||
FULL_TESTS_NEEDED_LABEL = True | ||
else: | ||
print(f"Did not find the right PR labels in ${PR_LABELS}: 'full tests needed'") | ||
FULL_TESTS_NEEDED_LABEL = False | ||
return FULL_TESTS_NEEDED_LABEL | ||
|
||
|
||
# Call it from Python Main | ||
def validate_github_sha(GITHUB_SHA): | ||
PR_LABELS = os.environ.get('PR_LABELS') | ||
FULL_TESTS_NEEDED_LABEL = validate_pull_request_label(PR_LABELS) | ||
global INCOMING_COMMIT_SHA | ||
if not GITHUB_SHA: | ||
print("") | ||
print("No Commit SHA - running all tests (likely direct merge, or scheduled run)!") | ||
print("") | ||
INCOMING_COMMIT_SHA = "" | ||
FULL_TESTS_NEEDED_LABEL = "true" | ||
# output_all_basic_variables | ||
# output_all_basic_variables() | ||
# check_upgrade_to_newer_dependencies_needed | ||
# set_outputs_run_everything_and_exit | ||
print(FULL_TESTS_NEEDED_LABEL) | ||
else: | ||
INCOMING_COMMIT_SHA = GITHUB_SHA | ||
print("") | ||
print(f"Commit SHA passed: ${INCOMING_COMMIT_SHA}!") | ||
print("") | ||
|
||
|
||
def validate_github_default_branch(default_branch): | ||
# === Validationg BRANCH === | ||
if default_branch == "main": | ||
ALL_TESTS = "Always API Core Other CLI Providers WWW Integration" | ||
print(f'ALL_TESTS {ALL_TESTS}') | ||
else: | ||
# Skips Provider tests in case current default branch is not main | ||
ALL_TESTS = "Always API Core Other CLI WWW Integration" | ||
print(f'ALL_TESTS {ALL_TESTS}') | ||
|
||
# Validations | ||
def check_if_any_py_files_changed(): | ||
"""" | ||
Checking if Python files changed, if yes Build Image | ||
""" | ||
CHANGED_FILES = get_changed_files(INCOMING_COMMIT_SHA) | ||
if ".py" in CHANGED_FILES: | ||
print("check files changed and if there is python files BUILD IMAGE") | ||
else: | ||
print("No build image") |