Update Energy Management use case #754
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |