Commit 3ba651b6 authored by Michele Carignani's avatar Michele Carignani
Browse files

Build script now can receive as argument the prefix or the API to filter out files not matching.



Change-Id: Iab60d79246ce0b9cd89ceca6444776af90a1cea9
Signed-off-by: Michele Carignani's avatarMichele Carignani <michele.carignani@etsi.org>
parent e3a90e27
...@@ -12,7 +12,7 @@ rm build/*-API.json ...@@ -12,7 +12,7 @@ rm build/*-API.json
cd docker cd docker
./build-container.sh ./build-container.sh
./run-container.sh "${run_dir}" ./run-container.sh "${run_dir}" "$1"
cd .. cd ..
......
...@@ -22,4 +22,5 @@ RUN npm install -g yamljs@0.3.0 ...@@ -22,4 +22,5 @@ RUN npm install -g yamljs@0.3.0
ADD validate-in-docker.sh /validate-in-docker.sh ADD validate-in-docker.sh /validate-in-docker.sh
RUN chmod +x /validate-in-docker.sh RUN chmod +x /validate-in-docker.sh
CMD ["/validate-in-docker.sh", "/work", "/storage"] ENTRYPOINT ["/validate-in-docker.sh"]
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
WEB_PUBLISH=true WEB_PUBLISH=true
f="${1:-`pwd`}" f="${1:-`pwd`}"
filter="$2"
echo "Mounting dir $f as /work" echo "Mounting dir $f as /work"
...@@ -16,9 +17,9 @@ if [ -n "$JOB_BASE_NAME" -a "$WEB_PUBLISH" = true ] ; then ...@@ -16,9 +17,9 @@ if [ -n "$JOB_BASE_NAME" -a "$WEB_PUBLISH" = true ] ; then
s="/var/www/html/api/nfv/$JOB_BASE_NAME/$BUILD_NUMBER" s="/var/www/html/api/nfv/$JOB_BASE_NAME/$BUILD_NUMBER"
mkdir -v -p "$s" mkdir -v -p "$s"
echo "Mounting dir $s as /storage" echo "Mounting dir $s as /storage"
docker run -v "$f":/work -v "$s":/storage openapivalidator docker run -v "$f":/work -v "$s":/storage openapivalidator "/work" "/storage" "$filter"
else else
docker run -v "$f":/work openapivalidator docker run -v "$f":/work openapivalidator "/work" "/storage" "$filter"
fi fi
......
...@@ -52,8 +52,12 @@ function get_deliverable_from_fn () { ...@@ -52,8 +52,12 @@ function get_deliverable_from_fn () {
## Main ## ## Main ##
wd="${1?"Usage: $0 <working-directory> <storage-directory>"}" wd="${1?"Usage: $0 <working-directory> <storage-directory> [<filter_regex>]"}"
storage_dir="${2?"Usage: $0 <working-directory> <storage-directory>"}" storage_dir="${2?"Usage: $0 <working-directory> <storage-directory> [<filter_regex>]"}"
filter="$3"
echo "Using filter '$filter'"
echo
mkdir -p "$wd/build" mkdir -p "$wd/build"
...@@ -64,16 +68,21 @@ cd "$wd/src" ...@@ -64,16 +68,21 @@ cd "$wd/src"
# (single results in OR) # (single results in OR)
fres=0 fres=0
for f in $(find -name "*.yaml") ; do for f in $(find -name "*.yaml") ; do
echo "Found yaml file: $f" # echo "Found yaml file: $f"
file=$(basename "$f") file=$(basename "$f")
api=$(get_api_from_fn $f) api=$(get_api_from_fn $f)
deliverable=$(get_deliverable_from_fn $f) deliverable=$(get_deliverable_from_fn $f)
if [ "$file" = "$api.yaml" ]; then if [ "$file" = "$api.yaml" ]; then
echo "-- Will validate: $f (api: $api) (deliverable:$deliverable)" if [[ -n "$filter" && ! "$f" =~ ^[a-zA-Z0-9\.\/\-]*$filter[a-zA-Z\.\/0-9\-]*$ ]] ; then
validate_api "$f" "$api" "$deliverable" echo "Filtered out: $f (api: $api) (deliverable:$deliverable)."
res=$? else
fres=$(($fres||$res)) echo "-- Will validate: $f (api: $api) (deliverable:$deliverable)"
validate_api "$f" "$api" "$deliverable"
res=$?
fres=$(($fres||$res))
fi
fi fi
done done
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment