-
Notifications
You must be signed in to change notification settings - Fork 2
51 lines (45 loc) · 1.36 KB
/
pr.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
---
name: Validate pull requests
on:
pull_request:
push:
branches:
- main
env:
OSCAL_VERSION: "v1.0.4"
jobs:
schema:
name: Validate JSON Schema
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
path: oscal-demo-content
- name: Download schemas
uses: actions/checkout@v2
with:
repository: usnistgov/OSCAL
path: oscal
ref: ${{ env.OSCAL_VERSION }}
- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: lts/*
- name: Install validator CLI
run: npm install -g ajv-formats ajv-cli
- name: Run validation
run: |
declare -A content_types
content_types[catalog]="catalogs"
content_types[component]="component-definitions"
content_types[ssp]="system-security-plans"
schema_dir="oscal/json/schema"
errors=0
for schema_name in "${!content_types[@]}"; do
content_directory="oscal-demo-content/${content_types["$schema_name"]}"
schema_file="$schema_dir/oscal_${schema_name}_schema.json"
ajv validate --spec=draft7 --errors=json -c ajv-formats -s "$schema_file" -d "$content_directory/*.json"
errors=$(( $errors + $? ))
done
exit $errors