-
Notifications
You must be signed in to change notification settings - Fork 33
54 lines (46 loc) · 1.63 KB
/
validation.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
name: Validation
on:
- pull_request
jobs:
validate-tds:
name: Validate TDs
runs-on: ubuntu-latest
steps:
- name: Checkout wot-testing
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: '20'
- name: Create empty folder
run: npm init -y
- name: Install Playground CLI
run: npm i @thing-description-playground/cli
- name: Run validation script on all new matching files
env:
VALIDATION_SCRIPT: node_modules/@thing-description-playground/cli/index.js
PATTERN: "*.td.jsonld"
run: |
# Get the list of changed files
url="https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files"
changed_files=$(curl -s -X GET -G $url | jq -r '.[] | if .status!="removed" then .filename else empty end')
exit_code=0
for file in $changed_files; do
echo "===================="
# Check the file extension
if [[ $file == $PATTERN ]]; then
echo 'Validating' $file '...'
result=$(node $VALIDATION_SCRIPT -i $file -d)
if [[ $result == *"'failed'"* ]]; then
echo "$result"
echo '::error::Validation failed ✗'
exit_code=1
else
echo "$result"
echo 'Validation passed ✓'
fi
else
echo 'Skipped' $file
fi
done
exit $exit_code