Commit cf602608 authored by carignani's avatar carignani
Browse files

execute pyang in a docker, separate validate and lint stages

parent c68a7709
Loading
Loading
Loading
Loading

lint-data-models.sh

0 → 100644
+24 −0
Original line number Diff line number Diff line
#!/bin/bash
# Copyright ETSI 2020

echo "------ Switching to $1 folder --------"
cd $1

echo "------ Content of the folder ------"
ls

echo "------ Validating all YANG, JSON and XML files ------"
# If there are no YANG, JSON or XML files, then simply exit
ls | grep -q 'yang\|json\|xml\|xsd'
found_data_models=$?
if [ ! $found_data_models ] ; then 
    echo "-- No YANG, JSON, XML or XSD files."
    exit 0
fi

echo "------ Linting all YANG files ------"
#  Display all  errors and warnings to the user. Errors are allowed.
docker run --rm -v $(pwd)/yang-models:/yang hellt/pyang "/bin/sh" -c 'pyang --lint -p . _3gpp-*.yang'
ret=$?

exit $ret
 No newline at end of file
+9 −2
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ pipeline {
        gitlabBuilds(builds: ["Resolve", "Validate"])
    }
     
	agent any
	agent { dockerfile true }

	environment {
		def resolveSucceded = "false"
@@ -54,6 +54,14 @@ pipeline {
    			updateGitlabCommitStatus name: 'Validate', state: 'success'
			}
		}
		stage('Lint') {
    		steps{
    		    updateGitlabCommitStatus name: 'Lint', state: 'pending'
    			sh 'echo Lint stage'
    			sh 'bash ./scripts/lint-data-models.sh ./data-models'
    			updateGitlabCommitStatus name: 'Lint', state: 'success'
			}
		}
		stage('Deploy to FTP') {
    		steps{
    			sh 'echo DEPLOY stage'
@@ -69,7 +77,6 @@ pipeline {
				}
			}

			
			updateGitlabCommitStatus name: 'Validate', state: 'failed'
			mail to: 'cti_support@etsi.org',
				subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
+1 −5
Original line number Diff line number Diff line
@@ -17,11 +17,7 @@ if [ ! $found_data_models ] ; then
fi

# This must run error-free and must display all warnings to the user
pyang –strict -p ./yang-models _3gpp-*.yang
docker run --rm -v $(pwd)/yang-models:/yang hellt/pyang "/bin/sh" -c 'pyang --strict -p . _3gpp-*.yang'
ret=$?

echo "------ Linting all YANG files ------"
#  Display all  errors and warnings to the user. Errors are allowed.
pyang --lint-p ./yang-models _3gpp-*.yang  

exit $ret
 No newline at end of file