forked from kubeflow/pipelines-components
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
103 lines (103 loc) · 3.69 KB
/
.pre-commit-config.yaml
File metadata and controls
103 lines (103 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
repos:
- repo: local
hooks:
- id: uv-lock-check
name: uv lock check
entry: uv lock --check
language: system
files: (^pyproject\.toml$|^uv\.lock$)
pass_filenames: false
- id: ruff-format
name: ruff format
# --force-exclude respects pyproject.toml excludes when files are passed directly
entry: uv run ruff format --force-exclude
language: system
types: [python]
- id: ruff-check
name: ruff check
# --force-exclude respects pyproject.toml excludes when files are passed directly
entry: uv run ruff check --fix --force-exclude
language: system
types: [python]
- id: yamllint
name: yamllint
entry: uv run yamllint -c .yamllint.yml
language: system
types: [yaml]
- id: import-guard
name: import-guard
entry: >
uv run python .github/scripts/check_imports/check_imports.py
--config .github/scripts/check_imports/import_exceptions.yaml
language: system
types: [python]
files: ^(components|pipelines)/
- id: validate-readme
name: validate-readme
entry: >
bash -c '
asset_dirs="";
for file in "$@"; do
d=$(dirname "$file");
while [[ "$d" == components/* || "$d" == pipelines/* ]]; do
if [ -f "$d/component.py" ] || [ -f "$d/pipeline.py" ]; then
asset_dirs="$asset_dirs $d";
break;
fi;
d=$(dirname "$d");
done;
done;
asset_dirs=$(echo "$asset_dirs" | xargs -n1 2>/dev/null | sort -u | xargs);
if [ -n "$asset_dirs" ]; then
./.github/scripts/validate_readmes/test-readme-check.sh $asset_dirs || exit 1;
fi
' --
language: system
files: ^(components|pipelines)/[^/]+/[^/]+/
- id: markdownlint
name: markdownlint
entry: npx markdownlint-cli@0.39.0 --fix -c .markdownlint.json
language: system
types: [markdown]
- id: validate-metadata
name: validate-metadata
entry: >
bash -c '
asset_dirs="";
for file in "$@"; do
dir=$(dirname "$file");
if [[ "$dir" == components/*/* || "$dir" == pipelines/*/* ]]; then
asset_dirs="$asset_dirs $dir";
fi;
done;
asset_dirs=$(echo "$asset_dirs" | xargs -n1 2>/dev/null | sort -u | xargs);
for dir in $asset_dirs; do
echo "Validating metadata for $dir";
uv run python scripts/validate_metadata/validate_metadata.py --dir "$dir" || exit 1;
done
' --
language: system
files: ^(components|pipelines)/[^/]+/[^/]+(/[^/]+)?/(metadata\.yaml|OWNERS)$
- id: validate-base-images
name: validate-base-images
entry: >
bash -c '
components=();
pipelines=();
for file in "$@"; do
dir=$(dirname "$file");
if [[ "$file" == components/*/component.py ]]; then
components+=("--component" "$dir");
elif [[ "$file" == pipelines/*/pipeline.py ]]; then
pipelines+=("--pipeline" "$dir");
fi;
done;
if [[ ${#components[@]} -gt 0 || ${#pipelines[@]} -gt 0 ]]; then
echo "Validating base images for changed components/pipelines";
uv run python scripts/validate_base_images/validate_base_images.py \
"${components[@]}" "${pipelines[@]}" || exit 1;
fi
' --
language: system
files: ^(components|pipelines)/.+/(component|pipeline)\.py$