|
| 1 | +name: Lint the yaml |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request_target: |
| 5 | + push: |
| 6 | + branches: [master] |
| 7 | + |
| 8 | +jobs: |
| 9 | + yamllint: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Pull down repo |
| 13 | + uses: actions/checkout@v3 |
| 14 | + - name: Set up python |
| 15 | + uses: actions/setup-python@v4 |
| 16 | + with: |
| 17 | + python-version: '3.10' |
| 18 | + cache: 'pip' |
| 19 | + - name: Install script dependencies |
| 20 | + run: pip install -r ./scripts/requirements.txt |
| 21 | + - name: Run yamllint |
| 22 | + run: yamllint analytics/ data_model/ sensors/ |
| 23 | + analysis-schema: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - name: Pull down repo |
| 27 | + uses: actions/checkout@v3 |
| 28 | + - name: Set up python |
| 29 | + uses: actions/setup-python@v4 |
| 30 | + with: |
| 31 | + python-version: '3.10' |
| 32 | + cache: 'pip' |
| 33 | + - name: Install script dependencies |
| 34 | + run: pip install -r ./scripts/requirements.txt |
| 35 | + - name: Validate against analysis schema |
| 36 | + run: yamale -s scripts/analytic_schema.yaml --no-strict analytics/ |
| 37 | + datamodel-schema: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + steps: |
| 40 | + - name: Pull down repo |
| 41 | + uses: actions/checkout@v3 |
| 42 | + - name: Set up python |
| 43 | + uses: actions/setup-python@v4 |
| 44 | + with: |
| 45 | + python-version: '3.10' |
| 46 | + cache: 'pip' |
| 47 | + - name: Install script dependencies |
| 48 | + run: pip install -r ./scripts/requirements.txt |
| 49 | + - name: Validate against data model schema |
| 50 | + run: yamale -s scripts/datamodel_schema.yaml --no-strict data_model/ |
| 51 | + sensor-schema: |
| 52 | + runs-on: ubuntu-latest |
| 53 | + steps: |
| 54 | + - name: Pull down repo |
| 55 | + uses: actions/checkout@v3 |
| 56 | + - name: Set up python |
| 57 | + uses: actions/setup-python@v4 |
| 58 | + with: |
| 59 | + python-version: '3.10' |
| 60 | + cache: 'pip' |
| 61 | + - name: Install script dependencies |
| 62 | + run: pip install -r ./scripts/requirements.txt |
| 63 | + - name: Validate against sensor schema |
| 64 | + run: yamale -s scripts/sensor_schema.yaml --no-strict sensors/ |
| 65 | + filetype-is-yaml: |
| 66 | + runs-on: ubuntu-latest |
| 67 | + steps: |
| 68 | + - name: Pull down repo |
| 69 | + uses: actions/checkout@v3 |
| 70 | + - name: Files should be .yaml not .yml and should also be actual files (ex. not directories) |
| 71 | + shell: bash |
| 72 | + run: find analytics data_model sensors -mindepth 1 -maxdepth 1 \( ! -name "*.yaml" \) -o \( ! -type f \) |
| 73 | + id-filename-equivalence: |
| 74 | + runs-on: ubuntu-latest |
| 75 | + steps: |
| 76 | + - name: Pull down repo |
| 77 | + uses: actions/checkout@v3 |
| 78 | + - name: Analytics files need to have their filename be '{id}.yaml' |
| 79 | + run: > |
| 80 | + ret=0; |
| 81 | + for file in analytics/*.yaml; do |
| 82 | + echo "Checking $file"; |
| 83 | + if ! [ "$(basename $file | sed -e "s/\.yaml$//")" = "$(yq '.id' < $file)" ]; then |
| 84 | + echo "Failed"; |
| 85 | + ret=1; |
| 86 | + fi; |
| 87 | + done; |
| 88 | + exit "$ret" |
| 89 | + - name: Data model files need to have their filename be '{name but fully lowercase and with underscores replacing spaces}.yaml' |
| 90 | + run: > |
| 91 | + ret=0; |
| 92 | + for file in data_model/*.yaml; do |
| 93 | + echo "Checking $file"; |
| 94 | + if ! [ "$(basename $file | sed -e "s/\.yaml$//")" = "$(yq '.name | downcase | sub(" ", "_")' < $file)" ]; then |
| 95 | + echo "Failed"; |
| 96 | + ret=1; |
| 97 | + fi; |
| 98 | + done; |
| 99 | + exit "$ret" |
| 100 | + - name: Sensor files need to have their filename be '{sensor_name but fully lowercase}_{sensor_version}.yaml' |
| 101 | + run: > |
| 102 | + ret=0; |
| 103 | + for file in sensors/*.yaml; do |
| 104 | + echo "Checking $file"; |
| 105 | + if ! [ "$(basename $file | sed -e "s/\.yaml$//")" = "$(yq '(.sensor_name | downcase) + "_" + .sensor_version' < $file)" ]; then |
| 106 | + echo "Failed"; |
| 107 | + ret=1; |
| 108 | + fi; |
| 109 | + done; |
| 110 | + exit "$ret" |
0 commit comments