Skip to content

Commit

Permalink
Do not fail the build if only trove-classifiers change (apache#43236) (
Browse files Browse the repository at this point in the history
…apache#43237)

Trove classifiers is a non-code package so generally spaeking we
have no need to update it every time it is released, but it would
be great if we could update it together with other build
dependencies - and not fail the build when only trove classifiers
change, but update trove-classifiers nevertheless when we run

pre-commit run --hook-stage manual update-build-dependencies --all-files

This is very similar to what we already do with UV.

This PR achieves that:

* in CI we set the env SKIP_TROVE_CLASSIFIERS_ONLY to true
* this one will check if the only change in pyproject.toml are
  trove-classifiers
* If so - it only prints warning and exits with success
  • Loading branch information
potiuk authored Oct 22, 2024
1 parent 7daa556 commit b35b410
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/basic-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ jobs:
--hook-stage manual
update-build-dependencies
if: always()
env:
SKIP_TROVE_CLASSIFIERS_ONLY: "true"
- name: "Run automated upgrade for chart dependencies"
run: >
pre-commit run
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ repos:
files: ^.pre-commit-config.yaml$|^scripts/ci/pre_commit/update_build_dependencies.py$
pass_filenames: false
require_serial: true
additional_dependencies: ['rich>=12.4.4']
- id: update-installers
name: Update installers to latest (manual)
entry: ./scripts/ci/pre_commit/update_installers.py
Expand Down
24 changes: 23 additions & 1 deletion scripts/ci/pre_commit/update_build_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@
# under the License.
from __future__ import annotations

import os
import re
import shutil
import subprocess
import sys
import tempfile
from pathlib import Path

COMMON_PRECOMMIT_PATH = Path(__file__).parent.resolve()
sys.path.insert(0, COMMON_PRECOMMIT_PATH.as_posix()) # make sure common_precommit_utils is imported
from common_precommit_utils import console

AIRFLOW_SOURCES = Path(__file__).parents[3].resolve()
PYPROJECT_TOML_FILE = AIRFLOW_SOURCES / "pyproject.toml"

Expand Down Expand Up @@ -72,6 +77,18 @@
result.append("")
new_pyproject_toml_file_content = "\n".join(result)
if new_pyproject_toml_file_content != pyproject_toml_content:
if os.environ.get("SKIP_TROVE_CLASSIFIERS_ONLY", "false").lower() == "true":
diff = set(new_pyproject_toml_file_content.splitlines()) - (
set(pyproject_toml_content.splitlines())
)
if len(diff) == 1 and "trove-classifiers" in next(iter(diff)):
console.print("\n[yellow]Trove classifiers were changed. Please update them manually.\n")
console.print(
"\n[blue]Please run:[/blue]\n\n"
"pre-commit run --hook-stage manual update-build-dependencies --all-files\n"
)
console.print("\n[blue]Then commit the resulting files.\n")
sys.exit(0)
files_changed = True
PYPROJECT_TOML_FILE.write_text(new_pyproject_toml_file_content)
for file_to_replace_hatchling in FILES_TO_REPLACE_HATCHLING_IN:
Expand All @@ -84,5 +101,10 @@
shutil.rmtree(temp_dir)

if files_changed:
print("Some files changed. Please commit the changes.")
console.print("\n[red]Build dependencies have changed. Please update them manually.\n")
console.print(
"\n[blue]Please run:[/blue]\n\n"
"pre-commit run --hook-stage manual update-build-dependencies --all-files\n"
)
console.print("\n[blue]Then commit the resulting files.\n")
sys.exit(1)

0 comments on commit b35b410

Please sign in to comment.