-
Notifications
You must be signed in to change notification settings - Fork 213
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
85 lines (77 loc) · 2.62 KB
/
.pre-commit-config.yaml
File metadata and controls
85 lines (77 loc) · 2.62 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
repos:
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.0"
hooks:
- id: prettier
exclude: \.html$|^docs/|^tests/unit/messages/formats/markdown/fixtures/
- repo: https://github.com/crate-ci/typos
rev: v1.16.6
hooks:
- id: typos
exclude: index\.html$|elementary_output\.json$
- repo: local
hooks:
- id: no_commit
name: Check for NO_COMMIT marker
entry: bash -c "git diff --cached -U0 | (! grep NO_COMMIT)"
language: system
require_serial: true
pass_filenames: false
- repo: local
hooks:
- id: mypy
name: mypy
entry: mypy --no-error-summary
language: system
files: ^elementary/.*\.py$
- repo: local
hooks:
- id: strip-name-from-package-lock
name: Strip 'name' fields from package-lock.yml (unsupported in dbt 1.8)
entry: |
python -c "
import yaml, sys
lock_file = 'elementary/monitor/dbt_project/package-lock.yml'
with open(lock_file) as f:
data = yaml.safe_load(f)
changed = False
for pkg in data.get('packages', []):
if 'name' in pkg:
del pkg['name']
changed = True
if changed:
with open(lock_file, 'w') as f:
yaml.dump(data, f, default_flow_style=False, sort_keys=False)
print(f'Removed unsupported name fields from {lock_file}')
sys.exit(1)
"
language: system
files: package-lock\.yml$
pass_filenames: false
- id: verify-dbt-project-packages-lock
name: Verify internal dbt project package lock
entry: |
bash -c '
dbt_version=$(python -c "from dbt.version import __version__; print(__version__)");
required_version="1.8";
if [[ $(echo -e "$dbt_version\n$required_version" | sort -V | tail -1) == "$dbt_version" ]]; then
dbt deps --lock --project-dir elementary/monitor/dbt_project && git diff --quiet elementary/monitor/dbt_project/package-lock.yml || (echo "Changes detected in package lock file!" && exit 1);
else
echo "Skipping hook, dbt version is $dbt_version (< 1.8).";
fi
'
language: system
pass_filenames: false