Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .rat-excludes
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,6 @@ pnpm-lock.yaml
# python generated file
generated.py
auth_generated.py

# hash files
www-hash.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"materialIcons.js": "materialIcons.f88ecdbfcf2e0c4cd9d9.js",
"moment.js": "moment.e78a32283d6b95c3888d.js",
"runtime.js": "runtime.2ef1c2ebcabcb259d0c9.js",
"743.js": "743.4d8bb3a60c838fac9e80.js",
"743.js": "743.1f45c836ec447657c06d.js",
"jquery-ui.min.js": "jquery-ui.min.js",
"jquery-ui.min.css": "jquery-ui.min.css",
"oss-licenses.json": "oss-licenses.json",
Expand Down
1 change: 1 addition & 0 deletions providers/fab/www-hash.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dcce95d1f3f0f8e01c1e94c3915367e3acc00c022f76ebb8efad935cafe36d03
16 changes: 7 additions & 9 deletions scripts/ci/pre_commit/compile_fab_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
# here that are not available in stdlib! You should not import common_precommit_utils.py here because
# They are importing rich library which is not available in the node environment.

WWW_HASH_FILE = AIRFLOW_ROOT_PATH / ".build" / "www" / "hash.txt"
FAB_PROVIDER_ROOT_PATH = AIRFLOW_ROOT_PATH / "providers" / "fab"
FAB_PROVIDER_WWW_PATH = FAB_PROVIDER_ROOT_PATH / "src" / "airflow" / "providers" / "fab" / "www"
FAB_PROVIDER_WWW_HASH_FILE = FAB_PROVIDER_ROOT_PATH / "www-hash.txt"


def get_directory_hash(directory: Path, skip_path_regexp: str | None = None) -> str:
Expand All @@ -59,10 +61,9 @@ def get_directory_hash(directory: Path, skip_path_regexp: str | None = None) ->
def compile_assets(www_directory: Path, www_hash_file_name: str):
node_modules_directory = www_directory / "node_modules"
dist_directory = www_directory / "static" / "dist"
www_hash_file = AIRFLOW_ROOT_PATH / ".build" / "www" / www_hash_file_name
www_hash_file.parent.mkdir(exist_ok=True, parents=True)
FAB_PROVIDER_WWW_HASH_FILE.parent.mkdir(exist_ok=True, parents=True)
if node_modules_directory.exists() and dist_directory.exists():
old_hash = www_hash_file.read_text() if www_hash_file.exists() else ""
old_hash = FAB_PROVIDER_WWW_HASH_FILE.read_text() if FAB_PROVIDER_WWW_HASH_FILE.exists() else ""
new_hash = get_directory_hash(www_directory, skip_path_regexp=r".*node_modules.*")
if new_hash == old_hash:
print(f"The '{www_directory}' directory has not changed! Skip regeneration.")
Expand All @@ -88,12 +89,9 @@ def compile_assets(www_directory: Path, www_hash_file_name: str):
sys.exit(result.returncode)
subprocess.check_call(["yarn", "run", "build"], cwd=os.fspath(www_directory), env=env)
new_hash = get_directory_hash(www_directory, skip_path_regexp=r".*node_modules.*")
www_hash_file.write_text(new_hash)
FAB_PROVIDER_WWW_HASH_FILE.write_text(new_hash + "\n")


if __name__ == "__main__":
# Compile assets for fab provider
fab_provider_www_directory = (
AIRFLOW_ROOT_PATH / "providers" / "fab" / "src" / "airflow" / "providers" / "fab" / "www"
)
compile_assets(fab_provider_www_directory, "hash_fab.txt")
compile_assets(FAB_PROVIDER_WWW_PATH, "hash_fab.txt")