Skip to content

Commit

Permalink
Add parallel schema validation runs (#527)
Browse files Browse the repository at this point in the history
  • Loading branch information
petechd authored Oct 15, 2024
1 parent 8643b10 commit e18a71f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .schema-validator-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v8.0.0
v9.0.0
13 changes: 10 additions & 3 deletions scripts/validate_schemas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ passed=0

file_path_name=$(find "$file_path" -name '*.json')

for schema in ${file_path_name}; do

validate() {
schema=$1
result="$(curl -s -w 'HTTPSTATUS:%{http_code}' -X POST -H "Content-Type: application/json" -d @"$schema" http://localhost:5001/validate | tr -d '\n')"
# shellcheck disable=SC2001
HTTP_BODY=$(echo "${result}" | sed -e 's/HTTPSTATUS\:.*//g')
Expand All @@ -57,9 +57,16 @@ for schema in ${file_path_name}; do
(( failed++ ))
exit=1
fi
}


N_TIMES_IN_PARALLEL=20

for schema in ${file_path_name}; do
((i=i%N_TIMES_IN_PARALLEL)); ((i++==0)) && wait
# Spawn multiple (N_TIMES_IN_PARALLEL) processes in subshells and send to background, but keep printing outputs.
validate "$schema" &
done

echo -e "\\n${green}$passed Passed${default} - ${red}$failed Failed${default}"

exit "$exit"

0 comments on commit e18a71f

Please sign in to comment.