mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Actions: Add CI for utest and coverage
This commit is contained in:
parent
b02c814251
commit
8d44b982ee
7 changed files with 79 additions and 25 deletions
|
@ -1,36 +1,31 @@
|
|||
#!/bin/bash
|
||||
|
||||
# In .circleci/config.yml, generate *.gcno with
|
||||
# ./configure --gcov --without-research --without-librtmp && make
|
||||
# ./configure --gcov --with-utest --without-research --without-librtmp && make
|
||||
# and generate *.gcda by
|
||||
# ./objs/srs_utest
|
||||
|
||||
# Workdir is objs/cover.
|
||||
workdir=`pwd`/objs/cover
|
||||
|
||||
# Tool git is required to map the right path.
|
||||
git --version >/dev/null 2>&1
|
||||
ret=$?; if [[ $ret -ne 0 ]]; then echo "Tool git is required, ret=$ret"; exit $ret; fi
|
||||
|
||||
# Create trunk under workdir.
|
||||
mkdir -p $workdir && cd $workdir
|
||||
ret=$?; if [[ $ret -ne 0 ]]; then echo "Enter workdir failed, ret=$ret"; exit $ret; fi
|
||||
|
||||
# Collect all *.gcno and *.gcda to objs/cover.
|
||||
cd $workdir && (rm -rf src && cp -R ../../src . && cp -R ../src/* src/)
|
||||
ret=$?; if [[ $ret -ne 0 ]]; then echo "Collect *.gcno and *.gcda failed, ret=$ret"; exit $ret; fi
|
||||
|
||||
# Generate *.gcov for coverage.
|
||||
cd $workdir &&
|
||||
for file in `find src -name "*.cpp"|grep -v utest`; do
|
||||
gcov $file -o `dirname $file`
|
||||
ret=$?; if [[ $ret -ne 0 ]]; then echo "Collect $file failed, ret=$ret"; exit $ret; fi
|
||||
done
|
||||
|
||||
# Cook the gcov files.
|
||||
cd $workdir &&
|
||||
find . -name "*.gcov"|grep -v srs|xargs rm -f
|
||||
ret=$?; if [[ $ret -ne 0 ]]; then echo "Cook gcov files failed, ret=$ret"; exit $ret; fi
|
||||
CODECOV_ARGS=""
|
||||
if [[ $SRS_BRANCH != '' ]]; then
|
||||
# -B branch Specify the branch name
|
||||
CODECOV_ARGS="$CODECOV_ARGS -B $SRS_BRANCH"
|
||||
fi
|
||||
if [[ $SRS_SHA != '' ]]; then
|
||||
# -C sha Specify the commit sha
|
||||
CODECOV_ARGS="$CODECOV_ARGS -C $SRS_SHA"
|
||||
fi
|
||||
if [[ $SRS_PROJECT != '' ]]; then
|
||||
# -R root dir Used when not in git/hg project to identify project root directory
|
||||
# -p dir Project root directory. Also used when preparing gcov
|
||||
CODECOV_ARGS="$CODECOV_ARGS -R $SRS_PROJECT -p $SRS_PROJECT"
|
||||
fi
|
||||
|
||||
# Upload report with *.gcov
|
||||
# Remark: The file codecov.yml is not neccessary. It literally depends on git.
|
||||
|
@ -41,5 +36,6 @@ ret=$?; if [[ $ret -ne 0 ]]; then echo "Cook gcov files failed, ret=$ret"; exit
|
|||
# https://circleci.com/gh/ossrs/srs/tree/3.0release
|
||||
cd $workdir &&
|
||||
export CODECOV_TOKEN="493bba46-c468-4e73-8b45-8cdd8ff62d96" &&
|
||||
bash <(curl -s https://codecov.io/bash) &&
|
||||
bash <(curl -s https://codecov.io/bash) $CODECOV_ARGS &&
|
||||
echo "Done" && exit 0
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue