2
0

coverage.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. # In .circleci/config.yml, generate *.gcno with
  3. # ./configure --gcov --with-utest --without-research --without-librtmp && make
  4. # and generate *.gcda by
  5. # ./objs/srs_utest
  6. # Workdir is objs/cover.
  7. workdir=`pwd`/objs/cover
  8. # Create trunk under workdir.
  9. mkdir -p $workdir && cd $workdir
  10. ret=$?; if [[ $ret -ne 0 ]]; then echo "Enter workdir failed, ret=$ret"; exit $ret; fi
  11. CODECOV_ARGS=""
  12. if [[ $SRS_PROJECT != '' ]]; then
  13. # -R root dir Used when not in git/hg project to identify project root directory
  14. # -p dir Project root directory. Also used when preparing gcov
  15. CODECOV_ARGS="$CODECOV_ARGS -R $SRS_PROJECT -p $SRS_PROJECT"
  16. fi
  17. if [[ $SRS_BRANCH != '' ]]; then
  18. # -B branch Specify the branch name
  19. CODECOV_ARGS="$CODECOV_ARGS -B $SRS_BRANCH"
  20. fi
  21. if [[ $SRS_SHA != '' ]]; then
  22. # -C sha Specify the commit sha
  23. CODECOV_ARGS="$CODECOV_ARGS -C $SRS_SHA"
  24. fi
  25. if [[ $SRS_PR != '' ]]; then
  26. # -P pr Specify the pull request number
  27. CODECOV_ARGS="$CODECOV_ARGS -P $SRS_PR"
  28. fi
  29. # Upload report with *.gcov
  30. # Remark: The file codecov.yml is not neccessary. It literally depends on git.
  31. # Note: The right path is like:
  32. # https://codecov.io/gh/ossrs/srs/src/3.0release/trunk/src/protocol/srs_rtmp_stack.cpp
  33. # https://codecov.io/gh/ossrs/srs/src/20fbb4466fdc8ba5d810b8570df6004063212838/trunk/src/protocol/srs_rtmp_stack.cpp
  34. # Remark: It takes a few minutes to sync with github, so it might not available when CircleCI is done.
  35. # https://circleci.com/gh/ossrs/srs/tree/3.0release
  36. cd $workdir &&
  37. export CODECOV_TOKEN="493bba46-c468-4e73-8b45-8cdd8ff62d96" &&
  38. bash <(curl -s https://codecov.io/bash) $CODECOV_ARGS &&
  39. echo "Done" && exit 0