Skip to content
GitLab
Explore
Sign in
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
3d68606e
Commit
3d68606e
authored
7 months ago
by
Vivek Dutta
Browse files
Options
Downloads
Patches
Plain Diff
Enhance error handling
parent
731c8510
Branches
merge_pipeline
No related tags found
1 merge request
!31
Enhance error handling
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docker/code-analysis/static_code_analysis.sh
+39
-3
39 additions, 3 deletions
docker/code-analysis/static_code_analysis.sh
static-code-analysis.yml
+4
-12
4 additions, 12 deletions
static-code-analysis.yml
with
43 additions
and
15 deletions
docker/code-analysis/static_code_analysis.sh
+
39
−
3
View file @
3d68606e
#!/bin/bash
set
-eo
pipefail
log
()
{
...
...
@@ -106,7 +107,7 @@ run_cpd_check()
exec_cmd /usr/local/pmd/bin/run.sh cpd
--language
c
--exclude
./test/
${
CPD_OPTIONS
}
--files
${
SOURCE_FOLDER
}
}
main
()
validate_c_code
()
{
log
"SOURCE_FOLDER:
${
SOURCE_FOLDER
}
"
log
"COMPILATION_FIXUP:
${
COMPILATION_FIXUP
}
"
...
...
@@ -126,6 +127,11 @@ main()
fi
fi
if
[
"
${
SOURCE_FOLDER
}
"
==
"SKIP"
]
;
then
log
"Skipping C code analysis"
exit
0
fi
# Install pre-req if present/defined
if
[
-f
"./gitlab-ci/install-dependencies.sh"
]
;
then
log
"Installing prerequisites for compilation"
...
...
@@ -147,10 +153,40 @@ main()
run_cppcheck_validation
# Run clang analysis
run_cppcheck_clang_validation
#
run_cppcheck_clang_validation
# Run infer analysis
run_infer_analysis
}
main
"
$@
"
validate_shell_script
()
{
log
"Running optional tests"
if
[
-z
"
${
SHELL_SRC
}
"
]
;
then
log
"Skipping ShellCheck path not defined"
exit
0
fi
if
[
"
${
SHELL_SRC
}
"
==
"SKIP"
]
;
then
log
"Skipping ShellChecks ..."
exit
0
fi
log
"Running shellcheck
${
SHELLCHECK_OPTIONS
}
${
SHELL_SRC
}
"
exec_cmd shellcheck
${
SHELLCHECK_OPTIONS
}
${
SHELL_SRC
}
}
validation_type
=
"
${
1
}
"
case
"
${
validation_type
}
"
in
c_code
)
validate_c_code
"
${
@
}
"
;;
shell_script
)
validate_shell_script
"
${
@
}
"
;;
*
)
echo
"Unsupported validation type:
${
validation_type
}
"
exit
1
;;
esac
This diff is collapsed.
Click to expand it.
static-code-analysis.yml
+
4
−
12
View file @
3d68606e
variables
:
COMMON_IMAGE
:
"
dev.iopsys.eu:5050/iopsys/gitlab-ci-pipeline/code-analysis:1.
2
"
COMMON_IMAGE
:
"
dev.iopsys.eu:5050/iopsys/gitlab-ci-pipeline/code-analysis:1.
3
"
FLAWFINDER_OPTIONS
:
"
"
CPD_OPTIONS
:
"
--minimum-tokens
200"
CPPCHECK_OPTIONS
:
"
"
...
...
@@ -14,10 +14,7 @@ run_static_code_analysis:
stage
:
static_code_analysis
allow_failure
:
false
script
:
-
"
static_code_analysis.sh"
rules
:
-
if
:
$SOURCE_FOLDER
when
:
always
-
"
static_code_analysis.sh
c_code"
artifacts
:
when
:
on_failure
paths
:
...
...
@@ -27,11 +24,6 @@ run_static_code_analysis:
run_shell_checks
:
image
:
${COMMON_IMAGE}
stage
:
static_code_analysis
allow_failure
:
tru
e
allow_failure
:
fals
e
script
:
-
echo "Running optional tests"
-
echo "Running shellcheck ${SHELLCHECK_OPTIONS} ${SHELL_SRC}"
-
"
shellcheck
${SHELLCHECK_OPTIONS}
${SHELL_SRC}"
rules
:
-
if
:
$SHELL_SRC
when
:
always
-
"
static_code_analysis.sh
shell_script"
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