This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch v3-0-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-0-test by this push:
new c682888317b [v3-0-test] Stabilize FAB asset compilation (#50829)
(#50901)
c682888317b is described below
commit c682888317b773567bc654a20895e959cf0d90a8
Author: Jarek Potiuk <[email protected]>
AuthorDate: Wed May 21 10:34:02 2025 -0400
[v3-0-test] Stabilize FAB asset compilation (#50829) (#50901)
The FAB asset compilation might trigger different results depending
on time/libraries it is run with. Since we commit generated files to
repository, we should also commit the hash file of the www directory
so that we only trigger rebuild when any of the www files change.
Previously we stored the hash in `.build` directory which was not
committed to the repo - which works fine for dynamic assset generation
we have for the UI, but since FAB assets change rarely - we commmit the
generated files, and we should also commit the hash file in this case.
(cherry picked from commit 0a3b58abf372442843d649eb88cd829ff8aa0ea7)
---
.rat-excludes | 8 ++++++++
providers/fab/www-hash.txt | 1 +
scripts/ci/pre_commit/compile_fab_assets.py | 19 +++++++++----------
3 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/.rat-excludes b/.rat-excludes
index 75a85f9873f..95e31f35fba 100644
--- a/.rat-excludes
+++ b/.rat-excludes
@@ -161,9 +161,17 @@ PKG-INFO
.openapi-generator-ignore
version.txt
v1*.yaml
+v2*.yaml
_private_ui*.yaml
# Front end generated files
api-generated.ts
openapi-gen
pnpm-lock.yaml
+
+# python generated file
+generated.py
+auth_generated.py
+
+# hash files
+www-hash.txt
diff --git a/providers/fab/www-hash.txt b/providers/fab/www-hash.txt
new file mode 100644
index 00000000000..2df879f9871
--- /dev/null
+++ b/providers/fab/www-hash.txt
@@ -0,0 +1 @@
+dcce95d1f3f0f8e01c1e94c3915367e3acc00c022f76ebb8efad935cafe36d03
diff --git a/scripts/ci/pre_commit/compile_fab_assets.py
b/scripts/ci/pre_commit/compile_fab_assets.py
index eb767972a89..58f4c9fde36 100755
--- a/scripts/ci/pre_commit/compile_fab_assets.py
+++ b/scripts/ci/pre_commit/compile_fab_assets.py
@@ -25,13 +25,16 @@ import subprocess
import sys
from pathlib import Path
+from common_precommit_utils import AIRFLOW_ROOT_PATH
+
# NOTE!. This script is executed from node environment created by pre-commit
and this environment
# Cannot have additional Python dependencies installed. We should not import
any of the libraries
# 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.
-AIRFLOW_SOURCES_PATH = Path(__file__).parents[3].resolve()
-WWW_HASH_FILE = AIRFLOW_SOURCES_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:
@@ -58,10 +61,9 @@ INTERNAL_SERVER_ERROR = "500 Internal Server Error"
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_SOURCES_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.")
@@ -87,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_SOURCES_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")