-
Notifications
You must be signed in to change notification settings - Fork 327
110 lines (108 loc) · 3.65 KB
/
lint-yaml.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
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
name: Lint the yaml
on:
pull_request_target:
push:
branches: [master]
jobs:
yamllint:
runs-on: ubuntu-latest
steps:
- name: Pull down repo
uses: actions/checkout@v3
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name: Install script dependencies
run: pip install -r ./scripts/requirements.txt
- name: Run yamllint
run: yamllint analytics/ data_model/ sensors/
analysis-schema:
runs-on: ubuntu-latest
steps:
- name: Pull down repo
uses: actions/checkout@v3
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name: Install script dependencies
run: pip install -r ./scripts/requirements.txt
- name: Validate against analysis schema
run: yamale -s scripts/analytic_schema.yaml --no-strict analytics/
datamodel-schema:
runs-on: ubuntu-latest
steps:
- name: Pull down repo
uses: actions/checkout@v3
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name: Install script dependencies
run: pip install -r ./scripts/requirements.txt
- name: Validate against data model schema
run: yamale -s scripts/datamodel_schema.yaml --no-strict data_model/
sensor-schema:
runs-on: ubuntu-latest
steps:
- name: Pull down repo
uses: actions/checkout@v3
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name: Install script dependencies
run: pip install -r ./scripts/requirements.txt
- name: Validate against sensor schema
run: yamale -s scripts/sensor_schema.yaml --no-strict sensors/
filetype-is-yaml:
runs-on: ubuntu-latest
steps:
- name: Pull down repo
uses: actions/checkout@v3
- name: Files should be .yaml not .yml and should also be actual files (ex. not directories)
shell: bash
run: find analytics data_model sensors -mindepth 1 -maxdepth 1 \( ! -name "*.yaml" \) -o \( ! -type f \)
id-filename-equivalence:
runs-on: ubuntu-latest
steps:
- name: Pull down repo
uses: actions/checkout@v3
- name: Analytics files need to have their filename be '{id}.yaml'
run: >
ret=0;
for file in analytics/*.yaml; do
echo "Checking $file";
if ! [ "$(basename $file | sed -e "s/\.yaml$//")" = "$(yq '.id' < $file)" ]; then
echo "Failed";
ret=1;
fi;
done;
exit "$ret"
- name: Data model files need to have their filename be '{name but fully lowercase and with underscores replacing spaces}.yaml'
run: >
ret=0;
for file in data_model/*.yaml; do
echo "Checking $file";
if ! [ "$(basename $file | sed -e "s/\.yaml$//")" = "$(yq '.name | downcase | sub(" ", "_")' < $file)" ]; then
echo "Failed";
ret=1;
fi;
done;
exit "$ret"
- name: Sensor files need to have their filename be '{sensor_name but fully lowercase}_{sensor_version}.yaml'
run: >
ret=0;
for file in sensors/*.yaml; do
echo "Checking $file";
if ! [ "$(basename $file | sed -e "s/\.yaml$//")" = "$(yq '(.sensor_name | downcase) + "_" + .sensor_version' < $file)" ]; then
echo "Failed";
ret=1;
fi;
done;
exit "$ret"