Commit c13f9180 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Initial trial to include gitlab-ci to parse yaml files


Signed-off-by: Miguel Angel Reina Ortega's avatarMiguel Angel Reina Ortega <miguelangel.reinaortega@etsi.org>
parent 825d4644
Pipeline #12052 failed with stages
in 17 seconds
# CI/CD:
# * branch Continuously Builds & Push TOSCA parser image
#image: docker:latest
#services:
# - docker:dind
variables:
GIT_DEPTH: "3"
TOSCA_PARSER: "Cloudnet-TOSCA-toolbox" # "Puccini"
stages:
- build
- test
build-tosca-toolbox:
stage: build
only:
refs:
- dev
variables:
- $TOSCA_PARSER == "Cloudnet-TOSCA-toolbox"
#before_script:
# - echo "Check Docker Images and System info"
# - docker image ls
# - docker system info
script:
- echo "Building Cloudnet-TOSCA-toolbox image..."
- ./build_tosca_parser.sh $TOSCA_PARSER
- echo "Build finished"
test-definitions:
stage: test
script:
- echo "Parsing TOSCA definitions"
- ./parse_tosca_definitions.sh $TOSCA_PARSER
only:
- dev
artifacts:
paths:
- debug.log
#!/bin/bash
TOSCA_PARSER="Cloudnet-TOSCA-toolbox"
GIT_URL_TOSCA_TOOLBOX="https://github.com/Orange-OpenSource/Cloudnet-TOSCA-toolbox.git"
TOSCA_PARSER_FOLDER="tosca-parser/"
while getopts v: flag
do
case "${flag}" in
v) TOSCA_PARSER=${OPTARG};;
esac
done
if [ ${TOSCA_PARSER} == "Cloudnet-TOSCA-toolbox" ] ; then
# clone robot tests
git clone $GIT_URL_TOSCA_TOOLBOX $TOSCA_PARSER_FOLDER
cd $TOSCA_PARSER_FOLDER
docker build -t cloudnet/toscaware bin/toscaware
echo docker run --mount="${PWD}:/work" --mount="${PWD}/bin/cloudnet:/cloudnet" --workdir="/work" cloudnet/toscaware /bin/sh -c "echo Building image"
docker run --mount="${PWD}:/work" --mount="${PWD}/bin/cloudnet:/cloudnet" --workdir="/work" cloudnet/toscaware /bin/sh -c "echo Building image"
sleep 5;
container_to_update=`docker ps -n 1 --format '{{.Names}}'`
echo "Creating updated image from container ${container_to_update}"
docker container commit ${container_to_update} cloudnet/toscaware:latest
echo "Deleting old container ${container_to_update}"
docker container rm ${container_to_update}
fi
\ No newline at end of file
#!/bin/bash
TOSCA_PARSER="Cloudnet-TOSCA-toolbox"
GIT_URL_TOSCA_TOOLBOX="https://github.com/Orange-OpenSource/Cloudnet-TOSCA-toolbox.git"
TOSCA_PARSER_FOLDER="tosca-parser"
while getopts v: flag
do
case "${flag}" in
v) TOSCA_PARSER=${OPTARG};;
esac
done
if [ ${TOSCA_PARSER} == "Cloudnet-TOSCA-toolbox" ] ; then
# Parse TOSCA definitions
# CLOUDNET_BINDIR=${TOSCA_PARSER_FOLDER}/bin
# . ${CLOUDNET_BINDIR}/cloudnet_rc.sh
res=0
for i in /*.yaml ; do
docker ${DOCKER_OPTS} run --user "$(id -u)":"$(id -g)" --rm --attach=stdin --attach=stdout --attach=stderr cloudnet/toscaware python ${PYTHON_OPTS} /cloudnet/tosca/tosca2cloudnet.py --template-file "$1" ${TOSCAWARE_OPTS}
#docker ${DOCKER_OPTS} run --user "$(id -u)":"$(id -g)" --rm --attach=stdin --attach=stdout --attach=stderr cloudnet/toscaware python ${PYTHON_OPTS} /cloudnet/tosca/tosca2cloudnet.py --template-file "$1" ${TOSCAWARE_OPTS}
#./${TOSCA_PARSER_FOLDER}/bin/toscaware/toscaware $i $> debug.log
if [ $? != 0 ] ; then
echo "++++ Issues found with TOSCA parser tool"
echo "$msg"
res=1
fi
if [ $? == 0 ] ; then
echo "++++ TOSCA parser finished validation of $i"
#Check the debug messages, if there's at least one ERROR then res=1
if [grep "ERROR" < debug.log | wc -l == 0 ] ; then
echo "++++ TOSCA parser finished validation of $i with no errors"
else
echo "++++ TOSCA parser finished validation of $i with errors"
grep "ERROR" < debug.log
res = 1
fi
fi
done
fi
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