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 5bac5b39ff Update config hash in Breeze's README.md during 
reinstalllation (#28148)
5bac5b39ff is described below

commit 5bac5b39ffa415d535d629ddc4992337317a9c0e
Author: Jarek Potiuk <[email protected]>
AuthorDate: Tue Dec 6 22:14:10 2022 +0100

    Update config hash in Breeze's README.md during reinstalllation (#28148)
    
    Previously we updated Breeze's config hash using pre-commit whenever
    setup files changed. This has proven to be brittle.
    
    When you locally work and add new dependencies, breeze would keep
    reinstalling every time you run it locally - without the README
    being updated. You'd have to manually run pre-commit in order to
    get it regenerated.
    
    This PR adds a new flow. Whenever you automatically
    re-install breeze, the README.md file of the folder from which
    you reinstall breeze gets updated with the new hash **just** before
    reinstalling. This means that after installation the new hash is
    already present in the package, and next time you run breeze it
    will match the changed hash of your dependencies.
    
    The only thing left is to commit the changed README to the repo
    together with setup.py/cfg changes of yours.
    
    Pre-commit is still run on commit to verify that the hash of
    the config files is good.
---
 .pre-commit-config.yaml                           |  2 +-
 dev/breeze/src/airflow_breeze/utils/path_utils.py | 12 ++++++++++++
 images/breeze/output_static-checks.svg            |  4 ++--
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 6af5e51781..76b7a7941b 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -675,7 +675,7 @@ repos:
         name: Update Breeze README.md with config files hash
         language: python
         entry: ./scripts/ci/pre_commit/pre_commit_update_breeze_config_hash.py
-        files: 
^dev/breeze/setup.*$|^dev/breeze/pyproject.toml$|^dev/breeze/README.md$
+        files: 
dev/breeze/setup.py|dev/breeze/setup.cfg|dev/breeze/pyproject.toml|dev/breeze/README.md
         pass_filenames: false
         require_serial: true
       - id: check-breeze-top-dependencies-limited
diff --git a/dev/breeze/src/airflow_breeze/utils/path_utils.py 
b/dev/breeze/src/airflow_breeze/utils/path_utils.py
index d6b89cf475..7138d24c36 100644
--- a/dev/breeze/src/airflow_breeze/utils/path_utils.py
+++ b/dev/breeze/src/airflow_breeze/utils/path_utils.py
@@ -140,6 +140,17 @@ def set_forced_answer_for_upgrade_check():
         set_forced_answer("quit")
 
 
+def process_breeze_readme(breeze_sources: Path, sources_hash: str):
+    breeze_readme = breeze_sources / "README.md"
+    lines = breeze_readme.read_text().splitlines(keepends=True)
+    result_lines = []
+    for line in lines:
+        if line.startswith("Package config hash:"):
+            line = f"Package config hash: {sources_hash}\n"
+        result_lines.append(line)
+    breeze_readme.write_text("".join(result_lines))
+
+
 def reinstall_if_setup_changed() -> bool:
     """
     Prints warning if detected airflow sources are not the ones that Breeze 
was installed with.
@@ -162,6 +173,7 @@ def reinstall_if_setup_changed() -> bool:
         if installation_sources is not None:
             breeze_sources = installation_sources / "dev" / "breeze"
             warn_dependencies_changed()
+            process_breeze_readme(breeze_sources, sources_hash)
             set_forced_answer_for_upgrade_check()
             reinstall_breeze(breeze_sources)
             set_forced_answer(None)
diff --git a/images/breeze/output_static-checks.svg 
b/images/breeze/output_static-checks.svg
index 0418a91abd..acb8c2e319 100644
--- a/images/breeze/output_static-checks.svg
+++ b/images/breeze/output_static-checks.svg
@@ -212,9 +212,9 @@
             <circle cx="22" cy="0" r="7" fill="#febc2e"/>
             <circle cx="44" cy="0" r="7" fill="#28c840"/>
             </g>
-        
+
     <g transform="translate(9, 41)" 
clip-path="url(#breeze-static-checks-clip-terminal)">
-    
+
     <g class="breeze-static-checks-matrix">
     <text class="breeze-static-checks-r2" x="1464" y="20" textLength="12.2" 
clip-path="url(#breeze-static-checks-line-0)">
 </text><text class="breeze-static-checks-r3" x="12.2" y="44.4" 
textLength="85.4" 
clip-path="url(#breeze-static-checks-line-1)">Usage:&#160;</text><text 
class="breeze-static-checks-r1" x="97.6" y="44.4" textLength="268.4" 
clip-path="url(#breeze-static-checks-line-1)">breeze&#160;static-checks&#160;[</text><text
 class="breeze-static-checks-r4" x="366" y="44.4" textLength="85.4" 
clip-path="url(#breeze-static-checks-line-1)">OPTIONS</text><text 
class="breeze-static-checks-r1" x="451.4" y="44 [...]

Reply via email to