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
cd docker
./build-container.sh
./run-container.sh "${run_dir}"
./run-container.sh "${run_dir}" "$1"
cd ..
......
......@@ -22,4 +22,5 @@ RUN npm install -g yamljs@0.3.0
ADD validate-in-docker.sh /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 @@
WEB_PUBLISH=true
f="${1:-`pwd`}"
filter="$2"
echo "Mounting dir $f as /work"
......@@ -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"
mkdir -v -p "$s"
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
docker run -v "$f":/work openapivalidator
docker run -v "$f":/work openapivalidator "/work" "/storage" "$filter"
fi
......
......@@ -52,8 +52,12 @@ function get_deliverable_from_fn () {
## Main ##
wd="${1?"Usage: $0 <working-directory> <storage-directory>"}"
storage_dir="${2?"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> [<filter_regex>]"}"
filter="$3"
echo "Using filter '$filter'"
echo
mkdir -p "$wd/build"
......@@ -64,17 +68,22 @@ cd "$wd/src"
# (single results in OR)
fres=0
for f in $(find -name "*.yaml") ; do
echo "Found yaml file: $f"
# echo "Found yaml file: $f"
file=$(basename "$f")
api=$(get_api_from_fn $f)
deliverable=$(get_deliverable_from_fn $f)
if [ "$file" = "$api.yaml" ]; then
if [[ -n "$filter" && ! "$f" =~ ^[a-zA-Z0-9\.\/\-]*$filter[a-zA-Z\.\/0-9\-]*$ ]] ; then
echo "Filtered out: $f (api: $api) (deliverable:$deliverable)."
else
echo "-- Will validate: $f (api: $api) (deliverable:$deliverable)"
validate_api "$f" "$api" "$deliverable"
res=$?
fres=$(($fres||$res))
fi
fi
done
chmod -R o+w "$wd/build"
......
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