From 1d79ef87a516475b241d5c5a96c1b5b7fef12da1 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 15 Aug 2021 17:41:15 +0800 Subject: [PATCH] Acitons: Support pullrequest CI --- .github/workflows/test.yml | 15 +++++++++++---- trunk/auto/coverage.sh | 12 ++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a0b439693..19f8b7914 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,9 +32,16 @@ jobs: run: docker build --tag srs:cov -f trunk/Dockerfile.cov . # For coverage - name: Run SRS covergae - if: ${{ startsWith(github.ref, 'refs/heads/') }} + if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/remotes/') }} run: | - SRS_BRANCH=$(echo ${{ github.ref }}| awk -F '/' '{print $3}') && SRS_SHA=${{ github.sha }} && SRS_PROJECT=/srs - echo "For ref=${{ github.ref }}, sha=${{ github.sha }}, SRS_BRANCH=$SRS_BRANCH, SRS_SHA=$SRS_SHA, SRS_PROJECT=$SRS_PROJECT" - docker run --rm --env SRS_BRANCH=$SRS_BRANCH --env SRS_SHA=$SRS_SHA --env SRS_PROJECT=$SRS_PROJECT \ + # The hash of commit. + SRS_SHA=${{ github.sha }} + # Note that the root of SRS, must contains .git, for report fixing. + SRS_PROJECT=/srs + # The github.ref is, for example, refs/heads/3.0release + SRS_BRANCH=$(echo ${{ github.ref }}| awk -F 'refs/heads/' '{print $2}'| awk -F '/' '{print $1}') + # The github.ref is, for example, refs/remotes/pull/2536/merge + SRS_PR=$(echo ${{ github.ref }}| awk -F 'refs/remotes/pull/' '{print $2}'| awk -F '/' '{print $1}') + echo "For ref=${{ github.ref }}, sha=${{ github.sha }}, SRS_BRANCH=$SRS_BRANCH, SRS_PR=$SRS_PR, SRS_SHA=$SRS_SHA, SRS_PROJECT=$SRS_PROJECT" + docker run --rm --env SRS_BRANCH=$SRS_BRANCH --env SRS_PR=$SRS_PR --env SRS_SHA=$SRS_SHA --env SRS_PROJECT=$SRS_PROJECT \ srs:cov bash -c 'make && ./objs/srs_utest && bash auto/coverage.sh' \ No newline at end of file diff --git a/trunk/auto/coverage.sh b/trunk/auto/coverage.sh index 0e7443f28..25f7041d5 100644 --- a/trunk/auto/coverage.sh +++ b/trunk/auto/coverage.sh @@ -13,6 +13,11 @@ mkdir -p $workdir && cd $workdir ret=$?; if [[ $ret -ne 0 ]]; then echo "Enter workdir failed, ret=$ret"; exit $ret; fi CODECOV_ARGS="" +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 if [[ $SRS_BRANCH != '' ]]; then # -B branch Specify the branch name CODECOV_ARGS="$CODECOV_ARGS -B $SRS_BRANCH" @@ -21,10 +26,9 @@ 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" +if [[ $SRS_PR != '' ]]; then + # -P pr Specify the pull request number + CODECOV_ARGS="$CODECOV_ARGS -P $SRS_PR" fi # Upload report with *.gcov