...
 
Commits (137)
cppcheck.xml
/*
* Copyright OAI Software Alliance - 2018
* Author Raphael Defosseux
* Comments : Proper comments
*/
#include <stdio.h>
typedef unsigned int oai_uint_t;
#!/bin/groovy
// Comments
// author raphael defosseux
// date 2018-07-17
// copyright oai
//
def TERMINATE_STATUS
// Abstraction function to send social media messages:
// like on Slack or Mattermost
def sendSocialMediaMessage(pipeChannel, pipeColor, pipeMessage) {
if (params.pipelineUsesSlack != null) {
if (params.pipelineUsesSlack) {
slackSend channel: pipeChannel, color: pipeColor, message: pipeMessage
}
}
}
def gitCommitAuthorEmailAddr
def BUILD_STAGE_ID = 0
def TEST_STAGE_ID = 1
def SLAVE_JOB_STAGE_ID = 2
def NB_STAGES = SLAVE_JOB_STAGE_ID + 1
def pipelineStateStatusArray = new Boolean[NB_STAGES]
pipeline {
agent {
label 'carabe'
}
options {
disableConcurrentBuilds()
timestamps()
gitLabConnection('OAI GitLab')
gitlabBuilds(builds: ["Build", "Test"])
lock(extra: [[resource: 'CI-Dummy-2']], resource: 'CI-Dummy-1')
}
stages {
stage ("Verify Parameters") {
steps {
echo 'Verify Parameters'
//echo "Base URL is ${JENKINS_URL}"
echo "Git URL is ${GIT_URL}"
echo "GitLab Act is ${env.gitlabActionType}"
script {
for (int i = 0; i < NB_STAGES; i++) {
pipelineStateStatusArray[i] = false
}
JOB_TIMESTAMP = sh returnStdout: true, script: 'date --utc --rfc-3339=seconds | sed -e "s#+00:00##"'
JOB_TIMESTAMP = JOB_TIMESTAMP.trim()
echo "JOB_TIMESTAMP is ${JOB_TIMESTAMP}"
sh "git clean -x -d -ff"
TERMINATE_STATUS = 'todo'
echo "TERMINATE is ${TERMINATE_STATUS}"
if ("MERGE".equals(env.gitlabActionType)) {
gitCommitAuthorEmailAddr = env.gitlabUserEmail
echo "GitLab Usermail is ${gitCommitAuthorEmailAddr}"
//echo "GitLab src branch is ${env.gitlabSourceBranch}"
//echo "GitLab tar branch is ${env.gitlabTargetBranch}"
//echo "Git Last Commit is ${env.gitlabMergeRequestLastCommit}"
// GitLab-Jenkins pugin integration is lacking to perform the merge by itself
// Doing it manually --> it may have merge conflicts
sh "./scripts/doGitLabMerge.sh ${env.gitlabSourceBranch} ${env.gitlabMergeRequestLastCommit} ${env.gitlabTargetBranch} ${GIT_COMMIT}"
sh "./scripts/checkCodingFormattingRules.sh ${env.gitlabSourceBranch} ${env.gitlabTargetBranch}"
def res=readFile('./oai_rules_result.txt').trim();
if ("0".equals(res)) {
addGitLabMRComment comment: "All Changed files in Merge Request follow OAI Formatting Rules"
} else {
def fileList=readFile('./oai_warning_files_list.txt').trim();
addGitLabMRComment comment: "Some Changed files in Merge Request DO NOT follow OAI Formatting Rules (" + fileList + ")"
}
} else {
echo "Git Branch is ${GIT_BRANCH}"
echo "Git Commit is ${GIT_COMMIT}"
gitCommitAuthorEmailAddr = sh returnStdout: true, script: 'git log -n1 --pretty=format:%ae ${GIT_COMMIT}'
echo "GitLab Usermail is ${gitCommitAuthorEmailAddr}"
sh "./scripts/checkCodingFormattingRules.sh"
}
// xmlTestSuite should be a list of XML files to execute
if (params.xmlTestSuite != null) {
String[] myXmlTestSuite = params.xmlTestSuite.split("\\r?\\n")
def xmlField = ""
for (xmlFile in myXmlTestSuite) {
xmlField += "--XMLTestFile=" + xmlFile + " "
}
echo "Calling with $xmlField"
for (xmlFile in myXmlTestSuite) {
echo "XML FILE is $xmlFile"
}
}
}
}
}
stage ("Build") {
steps {
gitlabCommitStatus(name: "Build") {
sh "gcc src/test1.c -I./include -o bin/test1"
sh "gcc src/test2.c -I./include -o bin/test2"
sh "gcc src/test2.c -I./include -o bin/test3"
sh "cppcheck --enable=warning --force --xml --xml-version=2 src 2> cppcheck.xml"
}
}
post {
success {
script {
pipelineStateStatusArray[BUILD_STAGE_ID] = true
}
}
always {
script {
TERMINATE_STATUS = 'done'
}
}
}
}
stage ("Test") {
steps {
script {
try {
gitlabCommitStatus(name: "Test") {
sh "./bin/test1"
sh "./bin/test2"
sh "./bin/test3"
echo "TERMINATE is ${TERMINATE_STATUS}"
sh "sed -e 's#TEMPLATE_JOB_NAME#${JOB_NAME}#g' -e 's#TEMPLATE_BUILD_ID#${BUILD_ID}#g' -e 's#TEMPLATE_GIT_URL#${GIT_URL}#g' -e 's#TEMPLATE_GIT_BRANCH#${GIT_BRANCH}#g' -e 's#TEMPLATE_GIT_COMMIT#${GIT_COMMIT}#g' -e 's#TEMPLATE_JOB_TIMESTAMP#${JOB_TIMESTAMP}#g' scripts/template_results.html > test_results.html"
}
} catch (Exception e) {
currentBuild.result = 'FAILURE'
}
}
}
post {
success {
script {
pipelineStateStatusArray[TEST_STAGE_ID] = true
}
}
}
}
stage ("Test slave job") {
steps {
script {
triggerSlaveJob ('CI-Sandbox4-slave')
}
}
post {
success {
script {
finalizeSlaveJob ('CI-Sandbox4-slave')
pipelineStateStatusArray[SLAVE_JOB_STAGE_ID] = true
}
}
cleanup {
script {
if (!fileExists('test-result.txt')) {
finalizeSlaveJob ('CI-Sandbox4-slave')
}
}
}
}
}
}
post {
always {
script {
if(fileExists('cppcheck.xml')) {
archiveArtifacts artifacts: 'cppcheck.xml'
}
if(fileExists('test_results.html')) {
archiveArtifacts artifacts: 'test_results.html'
}
sendEmailToContributor(pipelineStateStatusArray, NB_STAGES, gitCommitAuthorEmailAddr)
}
}
success {
script {
def message = "OAI build #" + BUILD_ID + " passed (" + BUILD_URL + ")"
if ("MERGE".equals(env.gitlabActionType)) {
addGitLabMRComment comment: message
def message2 = "OAI build #" + BUILD_ID + " passed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")"
sendSocialMediaMessage('sandbox', 'good', message2)
} else {
sendSocialMediaMessage('sandbox', 'good', message)
}
}
}
failure {
script {
def message = "OAI build #" + BUILD_ID + " failed (" + BUILD_URL + ")"
if ("MERGE".equals(env.gitlabActionType)) {
addGitLabMRComment comment: message
def message2 = "OAI build #" + BUILD_ID + " failed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")"
sendSocialMediaMessage('sandbox', 'danger', message2)
} else {
sendSocialMediaMessage('sandbox', 'danger', message)
}
}
}
}
}
def triggerSlaveJob (jobName) {
if ("MERGE".equals(env.gitlabActionType)) {
echo "Triggering slave job in MR case"
} else {
echo "Triggering slave job in PUSH case"
}
localStatus = build job: jobName,
parameters: [
string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)),
string(name: 'eNB_Branch', value: String.valueOf(GIT_BRANCH)),
string(name: 'eNB_CommitID', value: String.valueOf(GIT_COMMIT)),
booleanParam(name: 'eNB_manageMergeRequest', value: Boolean.valueOf(params.eNB_manageMergeRequest))
]
return localStatus
}
def finalizeSlaveJob (jobName) {
copyArtifacts(projectName: jobName, filter: "test-result*.txt", selector: lastCompleted())
if (fileExists('test-result.txt')) {
archiveArtifacts artifacts: 'test-result.txt'
}
}
def sendEmailToContributor (stageStatuses, maxStages, toMailAddr) {
def header = false
def bodyMsg = '''Hi,
'''
for (int i = 0; i < maxStages; i++) {
if (!stageStatuses[i]) {
if (!header) {
bodyMsg += '''Stages that did fail:
'''
header = true
}
}
switch (i) {
case BUILD_STAGE_ID:
bodyMsg += ''' -- Build Stage
'''
break;
case TEST_STAGE_ID:
bodyMsg += ''' -- Test Stage
'''
break;
case SLAVE_JOB_STAGE_ID:
bodyMsg += ''' -- Slave Job Stage
'''
break;
default:
break;
}
}
bodyMsg += '''
Here are attached HTML report files for $PROJECT_NAME - Build # $BUILD_NUMBER
Regards,
OAI CI Team'''
emailext attachmentsPattern: 'cppcheck.xml,test-result*.txt',
body: bodyMsg,
replyTo: 'no-reply@openairinterface.org',
subject: '$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!',
to: toMailAddr
}
#!/bin/groovy
pipeline {
agent {
label 'orion'
}
options {
disableConcurrentBuilds()
timestamps()
}
stages {
stage ("Verify") {
steps {
script {
def allParametersPresent = true
echo params.eNB_IPaddress
if (params.eNB_Repository == null) {
echo "missing git url parameter"
allParametersPresent = false
} else {
echo params.eNB_Repository
}
if (params.eNB_Branch == null) {
echo "missing git branch parameter"
allParametersPresent = false
} else {
echo params.eNB_Branch
}
if (params.eNB_CommitID == null) {
echo "missing git commit parameter"
allParametersPresent = false
} else {
echo params.eNB_CommitID
}
if (params.eNB_manageMergeRequest == null) {
echo "missing gitlab merge request manage boolean parameter"
allParametersPresent = false
} else {
if (params.eNB_manageMergeRequest) {
echo "Slave job manages GitLab merge process"
} else {
echo "Slave job DO NOT manage GitLab merge process"
}
}
if (allParametersPresent) {
echo "All parameters are present"
//deleteDir()
//sh "git clone ${params.eNB_Repository}"
//sh "cd openair-ci-sandbox; git checkout -f ${params.eNB_CommitID}"
} else {
echo "Some parameters are missing"
}
sh "echo ${JOB_NAME} > test-result.txt"
sh "echo ${BUILD_ID} >> test-result.txt"
sh "echo ${NODE_NAME} >> test-result.txt"
if (fileExists('test-result.txt')) {
archiveArtifacts artifacts: 'test-result.txt'
}
//sh "sh scripts/fail.sh"
}
}
}
}
}
# OAI is using a style that is similar to the Google style
--style=google
# long options can be written without the preceding '--'
# Convert tabs to spaces
convert-tabs
# Indentation is 2 spaces
indent=spaces=2
# Indent 'switch' blocks so that the 'case X:' statements are indented in the switch block.
indent-switches
# Indent C++ comments beginning in column one.
indent-col1-comments
# Pad empty lines around header blocks
break-blocks
delete-empty-lines
# Attach a pointer or reference operator (*, &, or ^) to the variable name (right)
align-pointer=name
# The code line length is 200 characters/columns
max-code-length=200
break-after-logical
lineend=linux
#!/bin/bash
if [ $# -eq 0 ]
then
NB_FILES_TO_FORMAT=`astyle --dry-run --options=scripts/astyle-options.txt --recursive *.c *.h | grep -c Formatted `
echo "common/utils/itti/assertions.h openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c openair1/SCHED_UE/phy_procedures_lte_ue.c openair1/SIMULATION/LTE_PHY/dlsim.c openair1/SIMULATION/LTE_PHY/ulsim.c openair2/ENB_APP/enb_config.c openair2/ENB_APP/flexran_agent_ran_api.c openair2/LAYER2/MAC/eNB_scheduler_phytest.c openair2/LAYER2/RLC/rlc.c openair2/RRC/LTE/rrc_eNB.c openair2/RRC/LTE/rrc_UE.c" > oai_warning_files_list.txt
echo "Nb Files that do NOT follow OAI rules: $NB_FILES_TO_FORMAT"
exit 0
fi
if [ $# -eq 2 ]
then
# Merge request scenario
SOURCE_BRANCH=$1
echo "Source Branch is : $SOURCE_BRANCH"
TARGET_BRANCH=$2
echo "Target Branch is : $TARGET_BRANCH"
MERGE_COMMMIT=`git log -n1 | grep commit | sed -e "s@commit @@"`
echo "Merged Commit is : $MERGE_COMMMIT"
TARGET_INIT_COMMIT=`cat .git/refs/remotes/origin/$TARGET_BRANCH`
echo "Target Init is : $TARGET_INIT_COMMIT"
# Retrieve the list of modified files since the latest develop commit
MODIFIED_FILES=`git log $TARGET_INIT_COMMIT..$MERGE_COMMMIT --oneline --name-status | egrep "^M|^A" | sed -e "s@^M\t*@@" -e "s@^A\t*@@" | sort | uniq`
NB_TO_FORMAT=0
for FULLFILE in $MODIFIED_FILES
do
echo $FULLFILE
filename=$(basename -- "$FULLFILE")
EXT="${filename##*.}"
if [ $EXT = "c" ] || [ $EXT = "h" ] || [ $EXT = "cpp" ] || [ $EXT = "hpp" ]
then
TO_FORMAT=`astyle --dry-run --options=scripts/astyle-options.txt $FULLFILE | grep -c Formatted `
NB_TO_FORMAT=$((NB_TO_FORMAT + TO_FORMAT))
fi
done
echo "Nb Files that do NOT follow OAI rules: $NB_TO_FORMAT"
echo $NB_TO_FORMAT > ./oai_rules_result.txt
echo "common/utils/itti/assertions.h openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c openair1/SCHED_UE/phy_procedures_lte_ue.c openair1/SIMULATION/LTE_PHY/dlsim.c openair1/SIMULATION/LTE_PHY/ulsim.c openair2/ENB_APP/enb_config.c openair2/ENB_APP/flexran_agent_ran_api.c openair2/LAYER2/MAC/eNB_scheduler_phytest.c openair2/LAYER2/RLC/rlc.c openair2/RRC/LTE/rrc_eNB.c openair2/RRC/LTE/rrc_UE.c" > oai_warning_files_list.txt
exit 0
fi
if [ $# -ne 0 ] || [ $# -ne 2 ]
then
echo "Syntax error: $0 without any option will check all files in repository"
echo " or: $0 source-branch target-branch"
echo " will only check files that are pushed for a merge-request"
exit 1
fi
#!/bin/bash
if [ $# -ne 4 ]
then
echo "Syntax Error: $0 src-branch src-commit-id dest-branch dest-commit-id"
exit 1
fi
SOURCE_BRANCH=$1
echo "Source Branch is : $SOURCE_BRANCH"
SOURCE_COMMIT_ID=$2
echo "Source Commit ID is : $SOURCE_COMMIT_ID"
TARGET_BRANCH=$3
echo "Target Branch is : $TARGET_BRANCH"
TARGET_COMMIT_ID=$4
echo "Target Commit ID is : $TARGET_COMMIT_ID"
git config user.email "jenkins@openairinterface.org"
git config user.name "OAI Jenkins"
git checkout -f $SOURCE_COMMIT_ID
git merge --ff $TARGET_COMMIT_ID -m "Temporary merge for CI"
#!/bin/bash
exit -1
<!DOCTYPE html>
<html class="no-js" lang="en-US">
<head>
<title>Test Results for TEMPLATE_JOB_NAME job build #TEMPLATE_BUILD_ID</title>
<base href = "http://www.openairinterface.org/" />
</head>
<body>
<table style="border-collapse: collapse; border: none;">
<tr style="border-collapse: collapse; border: none;">
<td style="border-collapse: collapse; border: none;">
<a href="http://www.openairinterface.org/">
<img src="/wp-content/uploads/2016/03/cropped-oai_final_logo2.png" alt="" border="none" height=50 width=150>
</img>
</a>
</td>
<td style="border-collapse: collapse; border: none; vertical-align: center;">
<b><font size = "6">Job Summary -- Job: TEMPLATE_JOB_NAME -- Build-ID: TEMPLATE_BUILD_ID</font></b>
</td>
</tr>
</table>
<br>
<table border = "1">
<tr>
<td bgcolor = "lightcyan" >GIT Repository</td>
<td><a href="TEMPLATE_GIT_URL">TEMPLATE_GIT_URL</a></td>
</tr>
<tr>
<td bgcolor = "lightcyan" >Branch</td>
<td>TEMPLATE_GIT_BRANCH</td>
</tr>
<tr>
<td bgcolor = "lightcyan" >Commit ID</td>
<td>TEMPLATE_GIT_COMMIT</td>
</tr>
<tr>
<td bgcolor = "lightcyan" >Job Build Time (UTC)</td>
<td>TEMPLATE_JOB_TIMESTAMP</td>
</tr>
</table>
</body>
</html>
/*
* Copyright OAI Software Alliance - 2018
* Author Raphael Defosseux
* Comments : Proper comments!!!
*/
#include <stdio.h>
#include "test1.h"
int main()
{
oai_uint_t testId = 1;
printf ("Merge request\n");
printf ("Test%d\n", testId);
#ifdef _DEBUG
char a[10];
a[10] = 0;
#endif
return 0;
}
/*
* Copyright OAI Software Alliance - 2018
* Author Raphael Defosseux
* Comments : Proper comments
*/
#include <stdio.h>
int main() {
int testId = 2;
/*
* Proper Signed int usage
*/
printf ("Test #%d\n", testId);
printf (" new test\n");
return 0;
}
/*
* Copyright OAI Software Alliance - 2018
* Author Raphael Defosseux
* Comments : Proper comments
* another test file
*/
#include <stdio.h>
int main() {
int testId = 3;
/*
* Using proper formatter in printf
*/
printf ("Test #%d\n", testId);
return 0;
}