-
Notifications
You must be signed in to change notification settings - Fork 1
/
run-coverity.sh
executable file
·117 lines (90 loc) · 3.39 KB
/
run-coverity.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env bash
set -e
echo "::group::Launching container"
echo "Checking if there is a working CVMFS mount"
if [ ! -d "/cvmfs/sft.cern.ch/lcg/" ]; then
echo "The directory /cvmfs/sft.cern.ch/lcg/ cannot be accessed!"
echo "Make sure you are using the cvmfs-contrib/github-action-cvmfs@v2 action"
exit 1
fi
if [ ! -d "/cvmfs/sft-nightlies.cern.ch/lcg/" ]; then
echo "The directory /cvmfs/sft-nightlies.cern.ch/lcg/ cannot be accessed!"
echo "Make sure you are using the cvmfs-contrib/github-action-cvmfs@v2 action"
exit 1
fi
if [ ! -d "/cvmfs/geant4.cern.ch/share/" ]; then
echo "The directory /cvmfs/geant4.cern.ch/share/ cannot be accessed!"
echo "Make sure you are using the cvmfs-contrib/github-action-cvmfs@v2 action"
exit 1
fi
echo "CVMFS mount present"
if [ -z "${VIEW_PATH}" ]; then
VIEW_PATH="/cvmfs/sft.cern.ch/lcg/views/${LCG_RELEASE_PLATFORM}"
if [[ "${LCG_RELEASE}" == *"dev"* ]]; then
VIEW_PATH="/cvmfs/sft-nightlies.cern.ch/lcg/views/${LCG_RELEASE}/latest/${LCG_PLATFORM}"
fi
fi
echo "Full view path is ${VIEW_PATH}"
if [ ! -d "${VIEW_PATH}" ]; then
echo "Did not find a view under this path!"
exit 1
fi
if [ -z "${COVERITY_CONTAINER}" ]; then
echo "Action variable coverity-container empty!"
exit 1
fi
if [ -z "${COVERITY_CMAKE_COMMAND}" ]; then
echo "Action variable coverity-cmake-command empty!"
exit 1
fi
if [ -z "${COVERITY_PROJECT}" ]; then
echo "Action variable coverity-project empty!"
exit 1
fi
if [ -z "${COVERITY_PROJECT_TOKEN}" ]; then
echo "Action variable coverity-project-token empty!"
exit 1
fi
if [ -z "${GITHUB_PAT}" ]; then
echo "Action variable github-pat empty!"
exit 1
fi
echo "Login into GitHub Container Registry"
echo ${GITHUB_PAT} | docker login ghcr.io --username ${GITHUB_ACTOR} --password-stdin;
echo "Login successful"
echo "Starting docker image ${COVERITY_CONTAINER} for Coverity"
docker run -it --name view_worker -v ${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE} -v /cvmfs:/cvmfs:shared -d ${COVERITY_CONTAINER} /bin/bash
echo "Docker image ready for Coverity"
echo "#!/usr/bin/env bash
set -e
source ${VIEW_PATH}/${SETUP_SCRIPT}
${RUN}
mkdir build
cd build
${COVERITY_CMAKE_COMMAND}
cov-build --dir cov-int make -j4
tar czvf /myproject.tgz cov-int
" > ${GITHUB_WORKSPACE}/coverity_scan.sh
chmod a+x ${GITHUB_WORKSPACE}/coverity_scan.sh
echo "::endgroup::" # Launch container
echo "#####################################################################"
echo "###################### Executing Coverity Scan ######################"
echo "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV"
docker exec view_worker /bin/bash -c "cd ${GITHUB_WORKSPACE}; ./coverity_scan.sh"
echo "#####################################################################"
echo "###################### Coverity Scan Compelte #######################"
echo "#####################################################################"
echo "::group::Upload artifacts"
echo "Start uploading compilation units for analysis"
docker cp view_worker:/myproject.tgz myproject.tgz
if [ "$1" != "local" ]; then
curl --form token=${COVERITY_PROJECT_TOKEN} \
--form [email protected] \
--form [email protected] \
--form version="master" \
--form description="Scan by run-lcg-view GitHub Action" \
https://scan.coverity.com/builds?project=${COVERITY_PROJECT}
else
echo "Not submitting to server only test run"
fi
echo "::endgroup::"