Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Add static checks in github action and sanitizers for unit tests #2725

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,20 @@ build:gcc7-later --cxxopt -faligned-new
build --incompatible_blacklisted_protos_requires_proto_info=false
build --copt=-fdiagnostics-color=always

build:sanitize-common --strip=never
build:sanitize-common --copt -O1
build:sanitize-common --copt -g
build:sanitize-common --copt -fno-omit-frame-pointer

build:asan --config=sanitize-common
build:asan --copt -fsanitize=address
build:asan --copt -DADDRESS_SANITIZER
build:asan --linkopt -fsanitize=address

build:asan --config=sanitize-common
build:msan --copt -fsanitize=memory
build:msan --copt -fsanitize=undefined
build:msan --linkopt -fsanitize=address
build:msan --linkopt -fsanitize=undefined

run --copt=-fdiagnostics-color=always
22 changes: 22 additions & 0 deletions .github/workflows/cppcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: cppcheck-action
czm23333 marked this conversation as resolved.
Show resolved Hide resolved
on: [push, pull_request]

jobs:
cppcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: deep5050/cppcheck-action@main
with:
inconclusive: disable
other_options: "--suppress=syntaxError:* --suppress=danglingTemporaryLifetime:* --suppress=deallocuse:* --suppress=uninitvar:* --suppress=unknownMacro:* --suppress=ctuOneDefinitionRuleViolation:*"
- name: Error check
run: |
if grep -qF 'error: ' cppcheck_report.txt; then
exit 1
fi
- uses: actions/upload-artifact@v3
if: always()
with:
name: cppcheck
path: cppcheck_report.txt
18 changes: 18 additions & 0 deletions .github/workflows/cpplint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: cpplint-action
on: [push, pull_request]

jobs:
cpplint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- run: pip install cpplint
- run: cpplint --recursive . > cpplint_report.txt 2>&1
continue-on-error: true
- uses: actions/upload-artifact@v3
if: always()
with:
name: cpplint
path: cpplint_report.txt

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ dep:
@bash util/build.sh --stor=$(stor) --only="" --dep=1

ci-build:
@bash util/build_in_image.sh --stor=$(stor) --only=$(only) --dep=$(dep) --release=$(release) --ci=$(ci) --os=$(os)
@bash util/build_in_image.sh --stor=$(stor) --only=$(only) --dep=$(dep) --release=$(release) --ci=$(ci) --os=$(os) --sanitizer=$(sanitizer)

ci-dep:
@bash util/build_in_image.sh --stor=$(stor) --only="" --dep=1
Expand Down
6 changes: 5 additions & 1 deletion ut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ print_title() {
############################ FUNCTIONS

get_options() {
local args=`getopt -o ldorh --long stor:,list,dep:,only:,os:,release:,ci:,build_rocksdb: -n "$0" -- "$@"`
local args=`getopt -o ldorhS --long sanitizer:,stor:,list,dep:,only:,os:,release:,ci:,build_rocksdb: -n "$0" -- "$@"`
eval set -- "${args}"
while true
do
Expand Down Expand Up @@ -56,6 +56,10 @@ get_options() {
g_ci=$2
shift 2
;;
-S|--sanitizer)
g_san=$2
shift 2
;;
--os)
g_os=$2
shift 2
Expand Down
12 changes: 11 additions & 1 deletion util/build_in_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@ _EOC_
}

get_options() {
local args=`getopt -o ldorh --long stor:,list,dep:,only:,os:,release:,ci:,build_rocksdb: -n "$0" -- "$@"`
local args=`getopt -o ldorhS --long sanitizer:,stor:,list,dep:,only:,os:,release:,ci:,build_rocksdb: -n "$0" -- "$@"`
eval set -- "${args}"
while true
do
case "$1" in
-S|--sanitizer)
g_san=$2
shift 2
;;
-s|--stor)
g_stor=$2
shift 2
Expand Down Expand Up @@ -199,6 +203,12 @@ build_target() {
target_array=("...")
fi

if [ $g_san == 1 ]; then
g_build_opts+=("--config=asan")
elif [ $g_san == 2 ]; then
g_build_opts+=("--config=msan")
fi

for target in "${target_array[@]}"
do
bazel build ${g_build_opts[@]} $target
Expand Down
27 changes: 25 additions & 2 deletions util/ut_in_image.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
#!/bin/bash
get_options() {
czm23333 marked this conversation as resolved.
Show resolved Hide resolved
local args=`getopt -o S --long sanitizer: -n "$0" -- "$@"`
eval set -- "${args}"
while true
do
case "$1" in
-S|--sanitizer)
g_san=$2
shift 2
;;
--)
shift
break
;;
*)
exit 1
;;
esac
done
}

get_options "$@"

WORKSPACE="/var/lib/jenkins/workspace/curve/curve_multijob/"
sudo mkdir -p /var/lib/jenkins/log/curve_unittest/$BUILD_NUMBER
git config --global --add safe.directory /var/lib/jenkins/workspace/curve/curve_multijob
Expand Down Expand Up @@ -68,10 +91,10 @@ set -e

#test_bin_dirs="bazel-bin/test/ bazel-bin/nebd/test/ bazel-bin/curvefs/test/"
if [ $1 == "curvebs" ];then
make ci-build stor=bs ci=1 dep=1
make ci-build stor=bs ci=1 dep=1 sanitizer=$g_san
test_bin_dirs="bazel-bin/test/ bazel-bin/nebd/test/"
elif [ $1 == "curvefs" ];then
make ci-build stor=fs ci=1 dep=1 only=curvefs/test/*
make ci-build stor=fs ci=1 dep=1 only=curvefs/test/* sanitizer=$g_san
test_bin_dirs="bazel-bin/curvefs/test/"
fi
echo $test_bin_dirs
Expand Down
Loading