Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gitlab-ci-pipeline
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IOPSYS
gitlab-ci-pipeline
Commits
01297525
Commit
01297525
authored
9 months ago
by
Vivek Dutta
Browse files
Options
Downloads
Patches
Plain Diff
Move all static analysis tests in static_code_analysis.sh
parent
9566df31
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!26
Added infer and minor cleanup
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
docker/code-analysis/Dockerfile
+2
-3
2 additions, 3 deletions
docker/code-analysis/Dockerfile
docker/code-analysis/static_code_analysis.sh
+36
-2
36 additions, 2 deletions
docker/code-analysis/static_code_analysis.sh
static-code-analysis.yml
+9
-14
9 additions, 14 deletions
static-code-analysis.yml
with
47 additions
and
19 deletions
docker/code-analysis/Dockerfile
+
2
−
3
View file @
01297525
...
@@ -259,9 +259,8 @@ COPY supervisord.conf /etc/supervisor/
...
@@ -259,9 +259,8 @@ COPY supervisord.conf /etc/supervisor/
RUN
mkdir
-p
/usr/share/rpcd/schemas
&&
\
RUN
mkdir
-p
/usr/share/rpcd/schemas
&&
\
mkdir
-p
/usr/share/rpcd/definitions
mkdir
-p
/usr/share/rpcd/definitions
# Copy static_code_analysis script
# Copy more_test script
COPY
static_code_analysis.sh /usr/local/bin/static_code_analysis.sh
COPY
more_test.sh /usr/local/bin/more_test.sh
# Start entrypoint
# Start entrypoint
COPY
entrypoint.sh /usr/local/bin/entrypoint.sh
COPY
entrypoint.sh /usr/local/bin/entrypoint.sh
...
...
This diff is collapsed.
Click to expand it.
docker/code-analysis/
more_test
.sh
→
docker/code-analysis/
static_code_analysis
.sh
+
36
−
2
View file @
01297525
...
@@ -11,7 +11,12 @@ exec_cmd()
...
@@ -11,7 +11,12 @@ exec_cmd()
$@
$@
if
[
"
$?
"
-ne
0
]
;
then
if
[
"
$?
"
-ne
0
]
;
then
log
"Failed to run [
$@
]..."
log
"Failed to run [
$@
]..."
exit
1
if
[
-n
"
${
CI
}
"
]
;
then
exit
1
else
# Ignore errors for development environment
log
"Ignoring the last error ..."
fi
fi
fi
}
}
...
@@ -51,19 +56,45 @@ run_infer_analysis()
...
@@ -51,19 +56,45 @@ run_infer_analysis()
exec_cmd infer
--fail-on-issue
--compilation-database
compile_commands.json
exec_cmd infer
--fail-on-issue
--compilation-database
compile_commands.json
}
}
run_flawfinder_checks
()
{
exec_cmd flawfinder
--minlevel
4
--error-level
=
4
${
FLAWFINDER_OPTIONS
}
${
SOURCE_FOLDER
}
}
run_cpd_check
()
{
exec_cmd /usr/local/pmd/bin/run.sh cpd
--language
c
--exclude
./test/
${
CPD_OPTIONS
}
--files
${
SOURCE_FOLDER
}
}
main
()
main
()
{
{
log
"SOURCE_FOLDER:
${
SOURCE_FOLDER
}
"
log
"SOURCE_FOLDER:
${
SOURCE_FOLDER
}
"
log
"COMPILATION_FIXUP:
${
COMPILATION_FIXUP
}
"
log
"COMPILATION_FIXUP:
${
COMPILATION_FIXUP
}
"
log
"CPPCHECK_OPTIONS:
${
CPPCHECK_OPTIONS
}
"
log
"CPPCHECK_OPTIONS:
${
CPPCHECK_OPTIONS
}
"
log
"FLAWFINDER_OPTIONS:
${
FLAWFINDER_OPTIONS
}
"
log
"CPD_OPTIONS:
${
CPD_OPTIONS
:
=--minimum-tokens 200
}
"
log
""
log
""
if
[
-z
"
${
SOURCE_FOLDER
}
"
]
;
then
log
"SOURCE_FOLDER not defined"
if
[
-n
"
${
CI
}
"
]
;
then
log
"Can't proceed without SOURCE_FOLDER in pipeline"
exit
5
else
log
"Assuming current path '.' as SOURCE_FOLDER"
export
SOURCE_FOLDER
=
"."
fi
fi
# Install pre-req if present/defined
# Install pre-req if present/defined
if
[
-f
"./gitlab-ci/install-dependencies.sh"
]
;
then
if
[
-f
"./gitlab-ci/install-dependencies.sh"
]
;
then
log
"Installing prerequisites for compilation"
log
"Installing prerequisites for compilation"
exec_cmd ./gitlab-ci/install-dependencies.sh
exec_cmd ./gitlab-ci/install-dependencies.sh
fi
fi
# Run flawfinder
run_flawfinder_checks
# Generate compilation db
# Generate compilation db
generate_compilation_db
generate_compilation_db
...
@@ -72,11 +103,14 @@ main()
...
@@ -72,11 +103,14 @@ main()
# Run cppcheck with compilation-db
# Run cppcheck with compilation-db
run_cppcheck_validation
run_cppcheck_validation
# Run clag analysis
# Run cla
n
g analysis
run_cppcheck_clang_validation
run_cppcheck_clang_validation
# Run infer analysis
# Run infer analysis
run_infer_analysis
run_infer_analysis
# Run CPD checks
run_cpd_check
}
}
main
"
$@
"
main
"
$@
"
This diff is collapsed.
Click to expand it.
static-code-analysis.yml
+
9
−
14
View file @
01297525
variables
:
variables
:
COMMON_IMAGE
:
"
dev.iopsys.eu:5050/iopsys/gitlab-ci-pipeline/code-analysis:0.33"
COMMON_IMAGE
:
"
dev.iopsys.eu:5050/iopsys/gitlab-ci-pipeline/code-analysis:0.33"
FLAWFINDER_OPTIONS
:
"
"
FLAWFINDER_OPTIONS
:
"
"
CPD_OPTIONS
:
"
--minimum-tokens
200
--language
c
--exclude
./test/
--files
"
CPD_OPTIONS
:
"
--minimum-tokens
200"
CPPCHECK_OPTIONS
:
"
"
CPPCHECK_OPTIONS
:
"
"
COMPILATION_FIXUP
:
"
"
COMPILATION_FIXUP
:
"
"
SHELL_SRC
:
"
"
SHELL_SRC
:
"
"
...
@@ -13,17 +13,12 @@ run_static_code_analysis:
...
@@ -13,17 +13,12 @@ run_static_code_analysis:
stage
:
static_code_analysis
stage
:
static_code_analysis
allow_failure
:
false
allow_failure
:
false
script
:
script
:
-
echo "flawfinder --minlevel 4 --error-level=4 ${FLAWFINDER_OPTIONS} ${SOURCE_FOLDER}"
-
"
static_code_analysis.sh"
-
"
flawfinder
--minlevel
4
--error-level=4
${FLAWFINDER_OPTIONS}
${SOURCE_FOLDER}"
rules
:
-
echo "/usr/local/pmd/bin/run.sh cpd ${CPD_OPTIONS} ${SOURCE_FOLDER}"
-
if
:
${SOURCE_FOLDER}
-
"
/usr/local/pmd/bin/run.sh
cpd
${CPD_OPTIONS}
${SOURCE_FOLDER}"
when
:
always
-
echo "Run cppcheck/infer/clag/gcc to scan for more issues"
-
"
more_test.sh"
only
:
variables
:
-
$SOURCE_FOLDER
artifacts
:
artifacts
:
when
:
always
when
:
on_failure
paths
:
paths
:
-
infer-out/report.txt
-
infer-out/report.txt
...
@@ -36,6 +31,6 @@ run_shell_checks:
...
@@ -36,6 +31,6 @@ run_shell_checks:
-
echo "Running optional tests"
-
echo "Running optional tests"
-
echo "Running shellcheck ${SHELLCHECK_OPTIONS} ${SHELL_SRC}"
-
echo "Running shellcheck ${SHELLCHECK_OPTIONS} ${SHELL_SRC}"
-
"
shellcheck
${SHELLCHECK_OPTIONS}
${SHELL_SRC}"
-
"
shellcheck
${SHELLCHECK_OPTIONS}
${SHELL_SRC}"
only
:
rules
:
variables
:
-
if
:
${SHELL_SRC}
-
$SHELL_SRC
when
:
always
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment