This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-1-test by this push:
new b7d69a24e5b [v3-1-test] Extract prek hooks for Helm (#57263) (#57303)
b7d69a24e5b is described below
commit b7d69a24e5b48a8285332b530679782187e5ac5c
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sun Oct 26 16:02:43 2025 +0100
[v3-1-test] Extract prek hooks for Helm (#57263) (#57303)
* Extract prek hooks for Helm
* Fix load template from parent folder
* Fix relative file lookup in check script
(cherry picked from commit 9eebbefdbb3ab36ef4a63f9a61eb96c3c11e9459)
Co-authored-by: Jens Scheffler <[email protected]>
---
.pre-commit-config.yaml | 84 +---------------------
chart/.pre-commit-config.yaml | 112 ++++++++++++++++++++++++++++++
scripts/ci/prek/vendor_k8s_json_schema.py | 3 +-
3 files changed, 116 insertions(+), 83 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 84c49d635a2..639b0f8374c 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -123,20 +123,12 @@ repos:
- --license-filepath
- scripts/ci/license-templates/LICENSE.txt
- --fuzzy-match-generates-todo
- - id: insert-license
- name: Add license for all Helm template files
- files: ^chart/templates/.*
- args:
- - --comment-style
- - "{{/*||*/}}"
- - --license-filepath
- - scripts/ci/license-templates/LICENSE.txt
- - --fuzzy-match-generates-todo
- id: insert-license
name: Add license for all YAML files except Helm templates
exclude: >
(?x)
- ^\.github/.*$|^chart/templates/.*|
+ ^\.github/.*$|
+ ^chart/templates/.*|
.*reproducible_build\.yaml$|
^.*/v2.*\.yaml$|
^.*/openapi/_private_ui.*\.yaml$|
@@ -197,14 +189,6 @@ repos:
language: python
pass_filenames: false
require_serial: true
- - id: update-chart-dependencies
- name: Update chart dependencies to latest (manual)
- entry: ./scripts/ci/prek/update_chart_dependencies.py
- stages: ['manual']
- language: python
- files:
^\.pre-commit-config\.yaml$|^scripts/ci/prek/update_build_dependencies\.py$
- pass_filenames: false
- require_serial: true
- id: check-taskinstance-tis-attrs
name: Check that TI and TIS have the same attributes
entry: ./scripts/ci/prek/check_ti_vs_tis_attributes.py
@@ -264,15 +248,6 @@ repos:
^dev/breeze/doc/images/output.*$|
^.*/openapi-gen/.*$|
^airflow-ctl/docs/images/.*\.svg$
- - id: pretty-format-json
- name: Format JSON files
- args:
- - --autofix
- - --no-sort-keys
- - --indent
- - "4"
- files: ^chart/values\.schema\.json$|^chart/values_schema\.schema\.json$
- pass_filenames: true
- repo: https://github.com/pre-commit/pygrep-hooks
rev: 3a6eb0fadf60b3cccfd80bad9dbb6fae7e47b316 # frozen: v1.10.0
hooks:
@@ -739,26 +714,6 @@ repos:
files: ^\.pre-commit-config\.yaml$|^docs/spelling_wordlist\.txt$
require_serial: true
pass_filenames: false
- - id: lint-helm-chart
- name: Lint Helm Chart
- entry: ./scripts/ci/prek/lint_helm.py
- language: python
- pass_filenames: false
- files: ^chart
- require_serial: true
- - id: validate-chart-annotations
- name: Validate chart annotations
- entry: ./scripts/ci/prek/validate_chart_annotations.py
- language: python
- pass_filenames: false
- files: ^chart/Chart\.yaml$
- - id: kubeconform
- name: Kubeconform check on our helm chart
- entry: ./scripts/ci/prek/check_kubeconform.py
- language: python
- pass_filenames: false
- files: ^chart
- require_serial: true
- id: shellcheck
name: Check Shell scripts syntax correctness
language: docker_image
@@ -878,34 +833,6 @@ repos:
^scripts/ci/docker-compose/gremlin/.|
^scripts/ci/docker-compose/.+-config\.ya?ml$
require_serial: true
- - id: lint-json-schema
- name: Lint chart/values.schema.json
- entry: ./scripts/ci/prek/lint_json_schema.py
- args:
- - --spec-file
- - chart/values_schema.schema.json
- - chart/values.schema.json
- language: python
- pass_filenames: false
- files: ^chart/values\.schema\.json$|^chart/values_schema\.schema\.json$
- require_serial: true
- - id: update-vendored-in-k8s-json-schema
- name: Vendor k8s definitions into values.schema.json
- entry: ./scripts/ci/prek/vendor_k8s_json_schema.py
- language: python
- files: ^chart/values\.schema\.json$
- - id: lint-json-schema
- name: Lint chart/values.yaml
- entry: ./scripts/ci/prek/lint_json_schema.py
- args:
- - --enforce-defaults
- - --spec-file
- - chart/values.schema.json
- - chart/values.yaml
- language: python
- pass_filenames: false
- files: ^chart/values\.yaml$|^chart/values\.schema\.json$
- require_serial: true
- id: lint-json-schema
name: Lint config_templates/config.yml
entry: ./scripts/ci/prek/lint_json_schema.py
@@ -943,13 +870,6 @@ repos:
language: python
pass_filenames: true
files: ^airflow-core/src/airflow/.*\.py$
- - id: lint-chart-schema
- name: Lint chart/values.schema.json file
- entry: ./scripts/ci/prek/chart_schema.py
- language: python
- pass_filenames: false
- files: ^chart/values\.schema\.json$
- require_serial: true
- id: update-inlined-dockerfile-scripts
name: Inline Dockerfile and Dockerfile.ci scripts
entry: ./scripts/ci/prek/inline_scripts_in_docker.py
diff --git a/chart/.pre-commit-config.yaml b/chart/.pre-commit-config.yaml
new file mode 100644
index 00000000000..1fdc19b57e6
--- /dev/null
+++ b/chart/.pre-commit-config.yaml
@@ -0,0 +1,112 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+---
+default_stages: [pre-commit, pre-push]
+minimum_prek_version: '0.0.28'
+repos:
+ - repo: https://github.com/Lucas-C/pre-commit-hooks
+ # replace hash with version once PR #103 merged comes in a release
+ rev: abdd8b62891099da34162217ecb3872d22184a51
+ hooks:
+ - id: insert-license
+ name: Add license for all Helm template files
+ files: ^templates/.*
+ args:
+ - --comment-style
+ - "{{/*||*/}}"
+ - --license-filepath
+ - ../scripts/ci/license-templates/LICENSE.txt
+ - --fuzzy-match-generates-todo
+ - repo: local
+ hooks:
+ - id: update-chart-dependencies
+ name: Update chart dependencies to latest (manual)
+ entry: ../scripts/ci/prek/update_chart_dependencies.py
+ stages: ['manual']
+ language: python
+ files:
^\.pre-commit-config\.yaml$|^../scripts/ci/prek/update_build_dependencies\.py$
+ pass_filenames: false
+ require_serial: true
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
+ hooks:
+ - id: pretty-format-json
+ name: Format JSON files
+ args:
+ - --autofix
+ - --no-sort-keys
+ - --indent
+ - "4"
+ files: ^chart/values\.schema\.json$|^chart/values_schema\.schema\.json$
+ pass_filenames: true
+ - repo: local
+ hooks:
+ - id: lint-helm-chart
+ name: Lint Helm Chart
+ entry: ../scripts/ci/prek/lint_helm.py
+ language: python
+ pass_filenames: false
+ files: ^.*
+ require_serial: true
+ - id: validate-chart-annotations
+ name: Validate chart annotations
+ entry: ../scripts/ci/prek/validate_chart_annotations.py
+ language: python
+ pass_filenames: false
+ files: ^Chart\.yaml$
+ - id: kubeconform
+ name: Kubeconform check on our helm chart
+ entry: ../scripts/ci/prek/check_kubeconform.py
+ language: python
+ pass_filenames: false
+ files: ^.*
+ require_serial: true
+ - id: lint-json-schema
+ name: Lint chart/values.schema.json
+ entry: ../scripts/ci/prek/lint_json_schema.py
+ args:
+ - --spec-file
+ - values_schema.schema.json
+ - values.schema.json
+ language: python
+ pass_filenames: false
+ files: ^values\.schema\.json$|^values_schema\.schema\.json$
+ require_serial: true
+ - id: update-vendored-in-k8s-json-schema
+ name: Vendor k8s definitions into values.schema.json
+ entry: ../scripts/ci/prek/vendor_k8s_json_schema.py
+ language: python
+ files: ^values\.schema\.json$
+ - id: lint-json-schema
+ name: Lint chart/values.yaml
+ entry: ../scripts/ci/prek/lint_json_schema.py
+ args:
+ - --enforce-defaults
+ - --spec-file
+ - values.schema.json
+ - values.yaml
+ language: python
+ pass_filenames: false
+ files: ^values\.yaml$|^values\.schema\.json$
+ require_serial: true
+ - id: lint-chart-schema
+ name: Lint chart/values.schema.json file
+ entry: ../scripts/ci/prek/chart_schema.py
+ language: python
+ pass_filenames: false
+ files: ^values\.schema\.json$
+ require_serial: true
diff --git a/scripts/ci/prek/vendor_k8s_json_schema.py
b/scripts/ci/prek/vendor_k8s_json_schema.py
index 6ceb2a4c1dc..a049a398c6b 100755
--- a/scripts/ci/prek/vendor_k8s_json_schema.py
+++ b/scripts/ci/prek/vendor_k8s_json_schema.py
@@ -28,12 +28,13 @@ import json
from collections.abc import Iterator
import requests
+from common_prek_utils import AIRFLOW_ROOT_PATH
K8S_DEFINITIONS = (
"https://raw.githubusercontent.com/yannh/kubernetes-json-schema"
"/master/v1.29.0-standalone-strict/_definitions.json"
)
-VALUES_SCHEMA_FILE = "chart/values.schema.json"
+VALUES_SCHEMA_FILE = AIRFLOW_ROOT_PATH / "chart/values.schema.json"
with open(VALUES_SCHEMA_FILE) as f: