-
Notifications
You must be signed in to change notification settings - Fork 150
50 lines (42 loc) · 1.76 KB
/
validate.yml
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
name: validate each item against its schema
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
yaml-schema-validation:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v4
- name: checkout yaml schemas
uses: actions/checkout@v4
with:
repository: 'crowdsecurity/crowdsec-yaml-schemas'
path: crowdsec-yaml-schemas
- name: transform to json all parsers/scenarios/collections/postovfw
uses: mikefarah/yq@master
with:
cmd: find . -path ./.tests -prune -o -name "*"yaml -exec sh -c 'yq -o=json {} > $(dirname {})/$(basename {} .yaml).json' \;
- name: transform to json schema
uses: mikefarah/yq@master
with:
cmd: for i in crowdsec-yaml-schema/*.yaml ; do yq -o=json $i > $(basename $i .yaml).json ; done
- name: validate parsers against schema
# Don't get confused by the version, the cli has a different schema than the library
run: |
go install github.com/santhosh-tekuri/jsonschema/cmd/[email protected]
find .
for ITEM in ./parsers/*/*/*.json; do echo $ITEM && ~/go/bin/jv crowdsec-yaml-schemas/parser_schema.json $ITEM ; done
- name: validate scenarios against schema
run: |
for ITEM in ./scenarios/*/*.json; do echo $ITEM && ~/go/bin/jv crowdsec-yaml-schemas/scenario_schema.json $ITEM ; done
- name: validate postoverflows against schema
run: |
for ITEM in ./postoverflows/*/*/*.json; do echo $ITEM && ~/go/bin/jv crowdsec-yaml-schemas/parser_schema.json $ITEM ; done
# - name: validate collections against schema
# run: |
# for ITEM in ./collections/*/*.json; do echo $ITEM && ~/go/bin/jv crowdsec-yaml-schemas/collection_schema.json $ITEM ; done