Skip to content

Commit 72e9bb3

Browse files
committed
Add cmake_coverity job
1 parent e2b7f58 commit 72e9bb3

3 files changed

Lines changed: 203 additions & 0 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
@Library(value='lammps_testing', changelog=false)
2+
import org.lammps.ci.Utils
3+
4+
def project_url = 'https://github.com/lammps/lammps.git'
5+
def set_github_status = false
6+
def send_slack = true
7+
8+
def lammps_branch = "master"
9+
def lammps_testing_branch = "master"
10+
11+
node('atlas2') {
12+
def utils = new Utils()
13+
14+
stage('Checkout') {
15+
dir('lammps') {
16+
commit = checkout([$class: 'GitSCM', branches: [[name: "*/${lammps_branch}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 1, noTags: false, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'lammps-jenkins', url: 'https://github.com/lammps/lammps']]])
17+
}
18+
19+
dir('lammps-testing') {
20+
checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: "*/${lammps_testing_branch}"]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'lammps-jenkins', url: 'https://github.com/lammps/lammps-testing']]]
21+
}
22+
}
23+
24+
if (set_github_status) {
25+
utils.setGitHubCommitStatus(project_url, env.JOB_NAME, commit.GIT_COMMIT, 'building...', 'PENDING')
26+
}
27+
28+
def err = null
29+
30+
try {
31+
env.LAMMPS_DIR = "${env.WORKSPACE}/lammps"
32+
env.LAMMPS_TESTING_DIR = "${env.WORKSPACE}/lammps-testing"
33+
env.LAMMPS_CACHE_DIR = "${env.WORKSPACE}/cache"
34+
env.LAMMPS_CONTAINER_DIR = "/home/jenkins/containers"
35+
36+
def container = "ubuntu20.04"
37+
def container_args = "--nv -B /opt/coverity:/opt/coverity"
38+
39+
def build_script = "cmake_coverity.sh"
40+
41+
def launch_container = "singularity exec ${container_args} \$LAMMPS_CONTAINER_DIR/${container}.sif"
42+
43+
timeout(time: 2, unit: 'HOURS') {
44+
stage('Build') {
45+
ansiColor('xterm') {
46+
sh(label: "Run static code analysis in ${container}",
47+
script: "${launch_container} \$LAMMPS_TESTING_DIR/scripts/static_analysis/${build_script}")
48+
}
49+
}
50+
}
51+
52+
def tools = []
53+
54+
if (build_script.contains("cmake")) {
55+
tools.add(cmake())
56+
}
57+
58+
if (build_script.contains("_icc_")) {
59+
tools.add(intel())
60+
} else if (build_script.contains("_clang_")) {
61+
tools.add(clang())
62+
} else {
63+
tools.add(gcc())
64+
}
65+
66+
recordIssues(tools: tools)
67+
68+
} catch (caughtErr) {
69+
err = caughtErr
70+
currentBuild.result = 'FAILURE'
71+
} finally {
72+
if (currentBuild.result == 'FAILURE') {
73+
if (set_github_status) {
74+
utils.setGitHubCommitStatus(project_url, env.JOB_NAME, commit.GIT_COMMIT, 'build failed!', 'FAILURE')
75+
}
76+
if (send_slack) {
77+
slackSend color: 'danger', message: "Build <${env.BUILD_URL}|#${env.BUILD_NUMBER}> of ${env.JOB_NAME} failed!"
78+
}
79+
} else {
80+
if (set_github_status) {
81+
utils.setGitHubCommitStatus(project_url, env.JOB_NAME, commit.GIT_COMMIT, 'build successful!', 'SUCCESS')
82+
}
83+
if (send_slack) {
84+
slackSend color: 'good', message: "Build <${env.BUILD_URL}|#${env.BUILD_NUMBER}> of ${env.JOB_NAME} succeeded!"
85+
}
86+
}
87+
88+
if(err) {
89+
throw err
90+
}
91+
}
92+
}

pipelines/master/jobs.dsl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,25 @@ docker_config.containers.each { name ->
293293
}
294294
}
295295
}
296+
297+
folder('dev/master/static_analysis')
298+
299+
pipelineJob("dev/master/static_analysis/cmake_coverity") {
300+
quietPeriod(120)
301+
302+
properties {
303+
disableConcurrentBuilds()
304+
pipelineTriggers {
305+
triggers {
306+
githubPush()
307+
}
308+
}
309+
}
310+
311+
definition {
312+
cps {
313+
script(readFileFromWorkspace('pipelines/master/cmake_coverity.groovy'))
314+
sandbox()
315+
}
316+
}
317+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/bash -x
2+
if [ -z "${LAMMPS_DIR}" ]
3+
then
4+
echo "Must set LAMMPS_DIR environment variable"
5+
exit 1
6+
fi
7+
8+
if [ -z "${LAMMPS_CI_RUNNER}" ]
9+
then
10+
# local testing
11+
BUILD=build-$(basename $0 .sh)
12+
else
13+
# when running lammps_test or inside jenkins
14+
BUILD=build
15+
fi
16+
17+
exists()
18+
{
19+
command -v "$1" >/dev/null 2>&1
20+
}
21+
22+
if exists "cmake3"
23+
then
24+
CMAKE_COMMAND=cmake3
25+
else
26+
CMAKE_COMMAND=cmake
27+
fi
28+
29+
LAMMPS_COMPILE_NPROC=${LAMMPS_COMPILE_NPROC-8}
30+
31+
export PYTHON=$(which python3)
32+
33+
# Set up environment
34+
virtualenv --python=$PYTHON pyenv
35+
source pyenv/bin/activate
36+
pip install --upgrade pip setuptools
37+
38+
# Create build directory
39+
if [ -d "${BUILD}" ]; then
40+
rm -rf ${BUILD}
41+
fi
42+
43+
mkdir -p ${BUILD}
44+
cd ${BUILD}
45+
46+
# need to set this to avoid picking up parallel HDF5 on centos/fedora
47+
export HDF5_ROOT=/usr
48+
49+
# add coverity tools to PATH
50+
export PATH=/opt/coverity/bin:$PATH
51+
52+
# Configure
53+
${CMAKE_COMMAND} \
54+
-C ${LAMMPS_DIR}/cmake/presets/clang.cmake \
55+
-C ${LAMMPS_DIR}/cmake/presets/most.cmake \
56+
-C ${LAMMPS_DIR}/cmake/presets/kokkos-openmp.cmake \
57+
-D CMAKE_BUILD_TYPE="RelWithDebug" \
58+
-D CMAKE_TUNE_FLAGS="-Wall -Wextra -Wno-unused-result" \
59+
-D CMAKE_INSTALL_PREFIX=${VIRTUAL_ENV} \
60+
-D BUILD_MPI=on \
61+
-D BUILD_OMP=on \
62+
-D BUILD_SHARED_LIBS=on \
63+
-D LAMMPS_SIZES=SMALLBIG \
64+
-D LAMMPS_EXCEPTIONS=on \
65+
-D PKG_MESSAGE=on \
66+
-D PKG_MPIIO=on \
67+
-D PKG_USER-ATC=on \
68+
-D PKG_USER-AWPMD=on \
69+
-D PKG_USER-BOCS=on \
70+
-D PKG_USER-EFF=on \
71+
-D PKG_USER-H5MD=on \
72+
-D PKG_USER-INTEL=on \
73+
-D PKG_USER-LB=on \
74+
-D PKG_USER-MANIFOLD=on \
75+
-D PKG_USER-MGPT=on \
76+
-D PKG_USER-MOLFILE=on \
77+
-D PKG_USER-NETCDF=on \
78+
-D PKG_USER-PTM=on \
79+
-D PKG_USER-QTB=on \
80+
-D PKG_USER-SDPD=on \
81+
-D PKG_USER-SMTBQ=on \
82+
-D PKG_USER-TALLY=on \
83+
${LAMMPS_DIR}/cmake || exit 1
84+
85+
# Build
86+
cov-build --dir cov-int cmake --build . -- -j ${LAMMPS_COMPILE_NPROC} || exit 1
87+
88+
# Create tarball with scan results
89+
tar czvf lammps.tgz cov-int

0 commit comments

Comments
 (0)