Files
airflow/chart/.pre-commit-config.yaml
Jarek PotiukandWei Lee 0cde487d42 Stop parallel prek hooks racing on __pycache__ cleanup (#73823)
* Stop parallel prek hooks racing on __pycache__ cleanup

prek runs hooks in parallel and every breeze invocation removes all
__pycache__ directories in the checkout on start-up. Any other hook
process importing from the source tree (breeze itself, prek hook
scripts, local mypy runs) can write a fresh .pyc between rmtree emptying
a directory and removing it, which fails the breeze hook with
"OSError: [Errno 39] Directory not empty" - a flaky Static checks
failure in CI.

Redirecting bytecode of every hook into a hidden, gitignored .build/
directory keeps the source tree free of new .pyc files while hooks run,
and a new check keeps future hooks from reintroducing the race. The
cleanup additionally tolerates ENOTEMPTY for writers prek does not
control, such as an IDE.

Generated-by: Claude Opus 5

* Set PYTHONPYCACHEPREFIX on the hooks added since the branch was cut

Eight hooks that landed on main after this branch was created did not redirect their bytecode, so the new check-prek-hooks-pycache-prefix hook failed after the rebase.

Generated-by: Claude Opus 5

* Update scripts/ci/prek/check_prek_hooks_pycache_prefix.py

Co-authored-by: Wei Lee <hello@wei-lee.me>

---------

Co-authored-by: Wei Lee <hello@wei-lee.me>
2026-10-21 00:58:38 +02:00

175 lines
6.1 KiB
YAML

# 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.3.4'
default_language_version:
python: python3
node: 22.19.0
golang: 1.24.0
repos:
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: ad1b27d73581aa16cca06fc4a0761fc563ffe8e8 # frozen: v1.5.6
hooks:
- id: insert-license
name: Add license for all Helm template files
env:
PYTHONPYCACHEPREFIX: .build/pycache
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)
env:
PYTHONPYCACHEPREFIX: .build/pycache
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: mypy-helm-tests
name: Run mypy for helm-tests
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: python
entry: ../scripts/ci/prek/run_mypy_full_dist_local_venv_or_breeze_in_ci.py chart/tests
pass_filenames: false
files: ^tests/.*\.py$
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
env:
PYTHONPYCACHEPREFIX: .build/pycache
args:
- --autofix
- --no-sort-keys
- --indent
- "4"
files:
(?x)
^values\.schema\.json$|
^values_schema\.schema\.json$
pass_filenames: true
- repo: local
hooks:
- id: lint-helm-chart
name: Lint Helm Chart
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/lint_helm.py
language: python
pass_filenames: false
files: ^.*
require_serial: true
- id: validate-chart-annotations
name: Validate chart annotations
env:
PYTHONPYCACHEPREFIX: .build/pycache
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
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/check_kubeconform.py
language: python
pass_filenames: false
files: ^.*
require_serial: true
- id: build-kustomize-overlays
name: Build and smoke-test Kustomize overlays
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/build_kustomize_overlays.py
language: python
pass_filenames: false
files: ^kustomize-overlays/.*\.(yaml|yml)$|^kustomize-overlays/.*/STATUS$
require_serial: true
- id: sort-helm-values-schema-file-type-field
name: Sort Helm Values Schema File (type field)
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/sort_helm_values_schema_file_type_field.py
language: python
pass_filenames: false
files: ^values\.schema\.json$
require_serial: true
- id: update-helm-values-schema-schema-file-type-field-match
name: Update Helm Values Schema Schema File (type field match)
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/update_helm_schema_schema_type_fields_match.py
language: python
pass_filenames: false
files: ^values\.schema\.json$|^values\.schema\.schema\.json$
require_serial: true
- id: lint-json-schema
name: Lint chart/values.schema.json
env:
PYTHONPYCACHEPREFIX: .build/pycache
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
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/vendor_k8s_json_schema.py
language: python
files: ^values\.schema\.json$
- id: lint-json-schema
name: Lint chart/values.yaml
env:
PYTHONPYCACHEPREFIX: .build/pycache
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
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/chart_schema.py
language: python
pass_filenames: false
files: ^values\.schema\.json$
require_serial: true