...
 
Commits (84)
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
}
}
}
pipeline {
agent {
label 'bellatrix'
}
options {
disableConcurrentBuilds()
timestamps()
gitLabConnection('OAI GitLab')
gitlabBuilds(builds: ["Build", "Test"])
}
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 {
TERMINATE_STATUS = 'todo'
echo "TERMINATE is ${TERMINATE_STATUS}"
if ("MERGE".equals(env.gitlabActionType)) {
//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}"
sh "./scripts/checkCodingFormattingRules.sh"
}
}
}
}
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 {
always {
script {
TERMINATE_STATUS = 'done'
}
}
}
}
stage ("Test") {
steps {
gitlabCommitStatus(name: "Test") {
sh "./bin/test1"
sh "./bin/test2"
sh "./bin/test3"
}
echo "TERMINATE is ${TERMINATE_STATUS}"
}
}
stage ("Test slave job") {
steps {
build job: 'CI-Sandbox4-slave',
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))
]
}
}
}
post {
always {
script {
if(fileExists('cppcheck.xml')) {
archiveArtifacts artifacts: 'cppcheck.xml'
}
}
}
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)
}
}
}
}
}
#!/bin/groovy
pipeline {
agent {
label 'bellatrix'
}
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"
}
}
}
}
}
}
# 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"
/*
* 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 ("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);
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;
}