-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pre-commit to check consistency of new provider's workspace setup (…
…#45800) The new-structure providers require to be added to pyproject.toml in a few places. This pre-commit makes sure tha this is done.
- Loading branch information
Showing
7 changed files
with
101 additions
and
3 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1 +1 @@ | ||
c60e6ba1483da43b8708603bc2a3dc9c | ||
075f067748cbe2f9161815fc5a3f63f8 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env python | ||
# | ||
# 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. | ||
""" | ||
Test for an order of dependencies in setup.py | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import sys | ||
from pathlib import Path | ||
|
||
sys.path.insert(0, str(Path(__file__).parent.resolve())) # make sure common_precommit_utils is imported | ||
from common_precommit_utils import console, get_all_new_provider_ids | ||
|
||
AIRFLOW_ROOT_PATH = Path(__file__).parents[3].resolve() | ||
PYPROJECT_TOML_FILE = AIRFLOW_ROOT_PATH / "pyproject.toml" | ||
PROVIDERS_DIR = AIRFLOW_ROOT_PATH / "providers" | ||
|
||
if __name__ == "__main__": | ||
try: | ||
import tomllib | ||
except ImportError: | ||
import tomli as tomllib | ||
|
||
error = False | ||
toml_dict = tomllib.loads(PYPROJECT_TOML_FILE.read_text()) | ||
# TODO(potiuk): renamme when all providers are switched to new style | ||
all_new_providers = get_all_new_provider_ids() | ||
for provider_id in all_new_providers: | ||
expected_provider_package = f"apache-airflow-providers-{provider_id.replace('.', '-')}" | ||
expected_member = "providers/" + provider_id.replace(".", "/") | ||
dev_dependency_group = toml_dict["dependency-groups"]["dev"] | ||
if expected_provider_package not in dev_dependency_group: | ||
console.print( | ||
f"[red]ERROR: {expected_provider_package} is not found in airflow's pyproject.toml " | ||
f"in dev dependency-group: {dev_dependency_group}[/red]" | ||
) | ||
error = True | ||
tool_uv_sources = toml_dict["tool"]["uv"]["sources"] | ||
if expected_provider_package not in tool_uv_sources: | ||
console.print( | ||
f"[red]ERROR: {expected_provider_package} is not found in airflow's pyproject.toml " | ||
f"in tool.uv.sources: {tool_uv_sources}[/red]" | ||
) | ||
error = True | ||
tool_uv_workspace_members = toml_dict["tool"]["uv"]["workspace"]["members"] | ||
if expected_member not in tool_uv_workspace_members: | ||
console.print( | ||
f"[red]ERROR: {expected_member} is not found in airflow's pyproject.toml " | ||
f"in tool.uv.workspace members: {tool_uv_workspace_members}[/red]" | ||
) | ||
error = True | ||
if error: | ||
sys.exit(1) |
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