From c1faa8cd6257f60565dd2730047e7db7daba6c9d Mon Sep 17 00:00:00 2001 From: Miguel Angel Reina Ortega Date: Wed, 26 Oct 2022 23:20:09 +0200 Subject: [PATCH 1/2] Allowing YANG Strict to fail + no exposure of logs if empty as artifacts --- sa5/.gitlab-ci.yml | 6 ++++-- sa5/lint-data-models.sh | 8 ++++++-- sa5/validate-all.sh | 4 ++++ sa5/validate-data-models.sh | 4 ++++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/sa5/.gitlab-ci.yml b/sa5/.gitlab-ci.yml index 424b09b..627116c 100644 --- a/sa5/.gitlab-ci.yml +++ b/sa5/.gitlab-ci.yml @@ -34,15 +34,15 @@ YANG Strict: script: - echo 'YANG Strict' - ./validate-data-models.sh . - after_script: - - ls artifacts: name: "YANG strict validation result" + when: always paths: - ${LOGFILE_YANG} YANG 3GPP Checks: stage: validation + allow_failure: true before_script: - | curl "${CI_API_V4_URL}/projects/57/repository/files/sa5%2Flint-data-models%2Esh/raw?ref=master" >> lint-data-models.sh @@ -52,6 +52,7 @@ YANG 3GPP Checks: - ./lint-data-models.sh . artifacts: name: "YANG 3gpp style check result" + when: always paths: - ${LOGFILE_LINT} @@ -66,6 +67,7 @@ Validate OpenAPI: - ./validate-all.sh ./OpenAPI artifacts: name: "OpenAPI validation result" + when: always paths: - ./OpenAPI/${LOGFILE_OPENAPI} diff --git a/sa5/lint-data-models.sh b/sa5/lint-data-models.sh index b9d8b4f..aae8525 100755 --- a/sa5/lint-data-models.sh +++ b/sa5/lint-data-models.sh @@ -76,6 +76,10 @@ if [ $ret == 1 ] ; then echo "To see the full output of the linter, download the archived artifact named '$LOGFILE'." fi -# exit $ret -exit 0 +if [ ! -s $LOGFILE ] ;then + rm "$LOGFILE" +fi + +exit $ret +#exit 0 diff --git a/sa5/validate-all.sh b/sa5/validate-all.sh index 4c35f43..43ab13e 100755 --- a/sa5/validate-all.sh +++ b/sa5/validate-all.sh @@ -80,6 +80,10 @@ echo -e $LOG | tee -a $LOGFILE echo -e "\n------ Content of the folder ------" | tee -a $LOGFILE ls | tee -a $LOGFILE +if [ ! -s $LOGFILE ] ;then + rm "$LOGFILE" +fi + # Exit code needed for jenkins to know the verdict of the build exit $fres diff --git a/sa5/validate-data-models.sh b/sa5/validate-data-models.sh index eca92e3..9c94ae9 100755 --- a/sa5/validate-data-models.sh +++ b/sa5/validate-data-models.sh @@ -37,5 +37,9 @@ if [ $ret == 0 ] ; then echo "No errors found by pyang --strict validation." fi +if [ ! -s $LOGFILE ] ;then + rm "$LOGFILE" +fi + exit $ret -- GitLab From 6f33ecd93dcbfd14ba8f35ed16e08075f8706352 Mon Sep 17 00:00:00 2001 From: Miguel Angel Reina Ortega Date: Fri, 28 Oct 2022 12:31:17 +0200 Subject: [PATCH 2/2] Renaming of jobs artifacts + exposing all artifacts --- sa5/.gitlab-ci.yml | 19 ++++++++++--------- sa5/lint-data-models.sh | 3 ++- sa5/validate-all.sh | 18 ++++++++++-------- sa5/validate-data-models.sh | 6 ++++-- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/sa5/.gitlab-ci.yml b/sa5/.gitlab-ci.yml index 627116c..f4fa27d 100644 --- a/sa5/.gitlab-ci.yml +++ b/sa5/.gitlab-ci.yml @@ -1,7 +1,5 @@ # CI/CD: # -# RESOLVE triggered by: -# - any (branch commit) # VALIDATION triggered by: # - any (branch commit) # @@ -25,7 +23,7 @@ stages: - validation - generation -YANG Strict: +YANG Validation Strict: stage: validation before_script: - | @@ -35,12 +33,13 @@ YANG Strict: - echo 'YANG Strict' - ./validate-data-models.sh . artifacts: - name: "YANG strict validation result" + name: "YANG validation strict result" when: always paths: - - ${LOGFILE_YANG} + - yang-validation.log + expose_as: 'YANG validation strict result' -YANG 3GPP Checks: +YANG Additional 3GPP Checks: stage: validation allow_failure: true before_script: @@ -51,10 +50,11 @@ YANG 3GPP Checks: - echo 'YANG 3GPP Checks' - ./lint-data-models.sh . artifacts: - name: "YANG 3gpp style check result" + name: "YANG Additional 3GPP checks result" when: always paths: - - ${LOGFILE_LINT} + - yang-linting.log + expose_as: 'YANG Additional 3GPP checks result' Validate OpenAPI: stage: validation @@ -69,7 +69,8 @@ Validate OpenAPI: name: "OpenAPI validation result" when: always paths: - - ./OpenAPI/${LOGFILE_OPENAPI} + - OpenAPI/openapi-validation.log + expose_as: 'OpenAPI validation result' Word CR text: stage: generation diff --git a/sa5/lint-data-models.sh b/sa5/lint-data-models.sh index aae8525..28fb0d1 100755 --- a/sa5/lint-data-models.sh +++ b/sa5/lint-data-models.sh @@ -73,11 +73,12 @@ echo $ret if [ $ret == 1 ] ; then echo "Some issues were collected by the linter, but they are treated as warnings and are not failing the validation." - echo "To see the full output of the linter, download the archived artifact named '$LOGFILE'." fi if [ ! -s $LOGFILE ] ;then rm "$LOGFILE" +else + echo "To see the full output of the linter, download the archived artifact named '$LOGFILE'." fi exit $ret diff --git a/sa5/validate-all.sh b/sa5/validate-all.sh index 43ab13e..a79e5c4 100755 --- a/sa5/validate-all.sh +++ b/sa5/validate-all.sh @@ -64,24 +64,26 @@ done echo -e "\n-- Final validator returns $fres." | tee -a $LOGFILE if [ $fres == 0 ] ; then - echo "No errors found, all files validate the OpenAPI definition. Below the complete log." | tee -a $LOGFILE + echo "No errors found, all files validate the OpenAPI definition" | tee -a $LOGFILE else - echo "Some errors found, see below the details." | tee -a $LOGFILE + echo "Some errors found by the OpenAPI validation" | tee -a $LOGFILE fi if [ ! "$ERR" == "" ] ; then - echo -e "\n---- Errors detected ----" | tee -a $LOGFILE - echo -e $ERR | tee -a $LOGFILE + echo -e "\n---- Errors detected ----" >> $LOGFILE + echo -e $ERR >> $LOGFILE fi -echo -e "\n---- Complete log of validation ----" | tee -a $LOGFILE -echo -e $LOG | tee -a $LOGFILE +echo -e "\n---- Complete log of validation ----" >> $LOGFILE +echo -e $LOG >> $LOGFILE -echo -e "\n------ Content of the folder ------" | tee -a $LOGFILE -ls | tee -a $LOGFILE +echo -e "\n------ Content of the folder ------" >> $LOGFILE +ls >> $LOGFILE if [ ! -s $LOGFILE ] ;then rm "$LOGFILE" +else + echo "To see the full output of the OpenAPI validation, download the archived artifact named '$LOGFILE'." fi # Exit code needed for jenkins to know the verdict of the build diff --git a/sa5/validate-data-models.sh b/sa5/validate-data-models.sh index 9c94ae9..ba6cafb 100755 --- a/sa5/validate-data-models.sh +++ b/sa5/validate-data-models.sh @@ -31,14 +31,16 @@ docker pull -q "${DOCKER_IMG}" docker run --rm -v $(pwd)/yang-models:/yang "${DOCKER_IMG}" "/bin/sh" -c 'pyang --strict -p external-yams *.yang' 2>>$LOGFILE >>$LOGFILE ret=$? -cat $LOGFILE - if [ $ret == 0 ] ; then echo "No errors found by pyang --strict validation." +else + echo "Some issues were collected by pyang --strict validation." fi if [ ! -s $LOGFILE ] ;then rm "$LOGFILE" +else + echo "To see the full output of the validation, download the archived artifact named '$LOGFILE'." fi exit $ret -- GitLab