Skip to content

Commit

Permalink
Simplify helm lint pre-commit by using common pre-commit code (#35880)
Browse files Browse the repository at this point in the history
* Simplify helm lint pre-commit by using common pre-commit code

* Update scripts/ci/pre_commit/pre_commit_helm_lint.py
  • Loading branch information
potiuk authored Nov 27, 2023
1 parent c41088b commit f3ddefc
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions scripts/ci/pre_commit/pre_commit_helm_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,28 @@
from __future__ import annotations

import os
import subprocess
import sys
from pathlib import Path

AIRFLOW_SOURCES_DIR = Path(__file__).parents[3].resolve()

sys.path.insert(0, str(Path(__file__).parent.resolve()))
from common_precommit_utils import console, initialize_breeze_precommit

sys.path.insert(0, os.fspath(Path(__file__).parent.resolve())) # make sure common_precommit_utils is imported
sys.path.insert(0, os.fspath(AIRFLOW_SOURCES_DIR)) # make sure setup is imported from Airflow
sys.path.insert(
0, os.fspath(AIRFLOW_SOURCES_DIR / "dev" / "breeze" / "src")
) # make sure setup is imported from Airflow
initialize_breeze_precommit(__name__, __file__)

if __name__ == "__main__":
from airflow_breeze.utils.kubernetes_utils import HELM_BIN_PATH, make_sure_kubernetes_tools_are_installed
from airflow_breeze.utils.run_utils import run_command
res_setup = subprocess.run(["breeze", "k8s", "setup-env"], check=True)
if res_setup.returncode != 0:
console.print("[red]\nError while setting up k8s environment.")
sys.exit(res_setup.returncode)

make_sure_kubernetes_tools_are_installed()
AIRFLOW_SOURCES_DIR = Path(__file__).parents[3].resolve()
HELM_BIN_PATH = AIRFLOW_SOURCES_DIR / ".build" / ".k8s-env" / "bin" / "helm"

result = run_command(
[os.fspath(HELM_BIN_PATH), "lint", ".", "-f", "values.yaml"],
check=False,
cwd=AIRFLOW_SOURCES_DIR / "chart",
)
sys.exit(result.returncode)
result = subprocess.run(
[os.fspath(HELM_BIN_PATH), "lint", ".", "-f", "values.yaml"],
check=False,
cwd=AIRFLOW_SOURCES_DIR / "chart",
)
if res_setup.returncode != 0:
console.print("[red]\nError while linting charts.")
sys.exit(res_setup.returncode)

0 comments on commit f3ddefc

Please sign in to comment.