-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.pre-commit-hooks.yaml
201 lines (173 loc) · 6.47 KB
/
.pre-commit-hooks.yaml
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#
# Define running hooks.
#
- id: validate-turtle
name: Validate a turtle file
description: |-
This hook validate a turtle file using the rules.shacl files
in the closest parent tree.
By default, only `.ttl` files in `assets/` are processed,
but this can be tweaked using the `files` property.
Files containing the following strings are excluded by default:
-aligns, -DBGT, example.
entry: python -m dati_playground validate --validate-shacl=true
language: python
files: >-
^assets/.*\.ttl$
exclude: >-
.*(-aligns|-DBGT|example).*
types:
- file
- id: validate-oas-schema
name: Validate yaml schema
description: This hook validates a schema provided in yaml format
entry: python -m dati_playground validate --validate-jsonschema=true
language: python
files: ^assets/.*\.schema.yaml
exclude: >-
.*example.*
types:
- file
- id: validate-openapi-schema
name: Validate oas3 schema
description: This hook validates an openapi schema provided in yaml format
entry: python -m dati_playground validate --validate-oas3=true
language: python
files: ^assets/.*\.oas3.yaml
exclude: >-
.*example.*
types:
- file
- id: validate-directory-versioning
name: Validate directory layout
description: |-
Check that the `latest/` version directory has the same content
of the directory with the latest semantic versioning.
By default, only `.ttl` files in `assets/` are processed,
but this can be tweaked using the `files` property.
Files containing the following strings are excluded by default:
-aligns, -DBGT, example.
entry: python -m dati_playground validate --validate-versioned-directory=true
exclude: >-
.*(-aligns|-DBGT|example).*
files: >-
^assets/.*\.ttl
language: python
types:
- file
- id: validate-csv
name: Validate csv layout
description: |-
Check that CSV files are coherent.
By default, only `.csv` files in `assets/` are processed,
but this can be tweaked using the `files` property.
Files containing the following strings are excluded by default:
example.
entry: python -m dati_playground validate --validate-csv=true
files: >-
^assets/vocabularies/.*\.csv
language: python
types:
- file
- id: validate-repo-structure
name: Validate repository structure
description: |-
Check that the structure of the assets directories
complies with the specified requirements.
The required directories are as follows:
"assets/controlled-vocabularies", "assets/ontologies", "assets/schemas".
If there are any other directories within "assets", the check will fail.
If the present directories match the required ones and their names are compliant,
the check will pass, even if there are fewer directories
entry: python -m dati_playground validate --validate-repo-structure=true
files: >-
^assets\/.*
language: python
fail_fast: true
types:
- file
- id: validate-filename-format
name: Validate filename e directory name formats
description: |-
This check ensures that file and directory name adhere to a predefined naming pattern.
It verifies file extensions and the names of files and their parent directories
against a specified regular expression pattern.
The check will fail if any deviations are found.
entry: python -m dati_playground validate --validate-filename-format=true
files: >-
^assets\/.*
language: python
types:
- file
- id: validate-filename-match-uri
name: Validate filename match uri
description: |-
It checks if a file's name matches its corresponding URI extracted from a TTL file.
It extracts the main URI relative to the TTL file,
then compares it with the filename to ensure consistency.
In the case of schemas, it verifies the filename with the .oas3.yaml extension
instead of the .ttl file as in other cases.
If a discrepancy is found, the check fails.
entry: python -m dati_playground validate --validate-filename-match-uri=true
files: >-
^assets\/.*\.ttl
language: python
types:
- file
- id: validate-filename-match-directory
name: Validate filename match directory name
description: |-
It checks that each file's name matches the name of the directory containing it
(excluding versioning directories).
It excludes specific filenames and file extensions from the validation process.
If a file's name or its containing directory name does not match
the expected pattern, an error is logged, and the validation fails.
entry: python -m dati_playground validate --validate-filename-match-directory=true
files: >-
^assets\/.*
language: python
exclude: >-
.*example.*
types:
- file
- id: validate-directory-versioning-pattern
name: Validate versioning pattern of directory
description: |-
Checks the directory structure for versioned directories.
It ensures that the directory is a leaf, is versioned,
and has consistent versioning patterns with its sibling directories.
If the directory name does not match the expected versioning pattern,
an error is logged, and the validation fails.
entry: python -m dati_playground validate --validate-directory-versioning-pattern=true
files: >-
^assets\/.*\.ttl
language: python
types:
- file
- id: validate-mandatory-files-presence
name: Validate mandatory files presence
description: |-
Checks if the directory containing the given file is a leaf directory
and contains at least one turtle (.ttl) file.
If the directory path contains 'schemas',
it also verifies the presence of .oas3.yaml and index.ttl files.
if it does not find the required files
an error is logged, and the validation fails.
entry: python -m dati_playground validate --validate-mandatory-files-presence=true
files: >-
^assets\/.*
language: python
types:
- file
- id: validate-utf8-file-encoding
name: Validate utf8 file encoding
description: |-
Checks if the file is encoded in UTF-8.
if it's not encoded in UTF-8
an error is logged, and the validation fails
entry: python -m dati_playground validate --validate-utf8-file-encoding=true
files: >-
^assets\/.*
language: python
types:
- file