@@ -15,36 +15,25 @@ concurrency:
1515env :
1616 GO111MODULE : " on"
1717 RUN_BASE_COVERAGE : " on" # Runs test for PR base in case base test coverage is missing.
18- COV_GO_VERSION : 1.20.x # Version of Go to collect coverage
18+ COV_GO_VERSION : stable # Version of Go to collect coverage
1919 TARGET_DELTA_COV : 90 # Target coverage of changed lines, in percents
2020jobs :
2121 test :
2222 strategy :
2323 matrix :
24- go-version : [ 1.13.x, 1.19.x, 1.20.x ]
24+ go-version : [ 1.13.x, stable, oldstable ]
2525 runs-on : ubuntu-latest
2626 steps :
27- - name : Install Go stable
28- if : matrix.go-version != 'tip'
29- uses : actions/setup-go@v4
27+ - name : Install Go
28+ uses : actions/setup-go@v5
3029 with :
3130 go-version : ${{ matrix.go-version }}
3231
33- - name : Install Go tip
34- if : matrix.go-version == 'tip'
35- run : |
36- curl -sL https://storage.googleapis.com/go-build-snap/go/linux-amd64/$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}').tar.gz -o gotip.tar.gz
37- ls -lah gotip.tar.gz
38- mkdir -p ~/sdk/gotip
39- tar -C ~/sdk/gotip -xzf gotip.tar.gz
40- ~/sdk/gotip/bin/go version
41- echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
42-
4332 - name : Checkout code
44- uses : actions/checkout@v3
33+ uses : actions/checkout@v4
4534
4635 - name : Go cache
47- uses : actions/cache@v3
36+ uses : actions/cache@v4
4837 with :
4938 # In order:
5039 # * Module download cache
5948 - name : Restore base test coverage
6049 id : base-coverage
6150 if : matrix.go-version == env.COV_GO_VERSION && github.event.pull_request.base.sha != ''
62- uses : actions/cache@v2
51+ uses : actions/cache@v4
6352 with :
6453 path : |
6554 unit-base.txt
@@ -88,14 +77,15 @@ jobs:
8877 id : annotate
8978 if : matrix.go-version == env.COV_GO_VERSION && github.event.pull_request.base.sha != ''
9079 run : |
91- curl -sLO https://github.com/vearutop/gocovdiff/releases/download/v1.3.6 /linux_amd64.tar.gz && tar xf linux_amd64.tar.gz
80+ curl -sLO https://github.com/vearutop/gocovdiff/releases/download/v1.4.2 /linux_amd64.tar.gz && tar xf linux_amd64.tar.gz && rm linux_amd64.tar.gz
9281 gocovdiff_hash=$(git hash-object ./gocovdiff)
93- [ "$gocovdiff_hash" == "8e507e0d671d4d6dfb3612309b72b163492f28eb" ] || (echo "::error::unexpected hash for gocovdiff, possible tampering: $gocovdiff_hash" && exit 1)
94- git fetch origin master ${{ github.event.pull_request.base.sha }}
95- REP=$(./gocovdiff -cov unit.coverprofile -gha-annotations gha-unit.txt -delta-cov-file delta-cov-unit.txt -target-delta-cov ${TARGET_DELTA_COV})
82+ [ "$gocovdiff_hash" == "c37862c73a677e5a9c069470287823ab5bbf0244" ] || (echo "::error::unexpected hash for gocovdiff, possible tampering: $gocovdiff_hash" && exit 1)
83+ # Fetch PR diff from GitHub API.
84+ curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3.diff" https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} > pull_request.diff
85+ REP=$(./gocovdiff -diff pull_request.diff -mod github.com/$GITHUB_REPOSITORY -cov unit.coverprofile -gha-annotations gha-unit.txt -delta-cov-file delta-cov-unit.txt -target-delta-cov ${TARGET_DELTA_COV})
9686 echo "${REP}"
9787 cat gha-unit.txt
98- DIFF=$(test -e unit-base.txt && ./gocovdiff -func-cov unit.txt -func-base-cov unit-base.txt || echo "Missing base coverage file")
88+ DIFF=$(test -e unit-base.txt && ./gocovdiff -mod github.com/$GITHUB_REPOSITORY - func-cov unit.txt -func-base-cov unit-base.txt || echo "Missing base coverage file")
9989 TOTAL=$(cat delta-cov-unit.txt)
10090 echo "rep<<EOF" >> $GITHUB_OUTPUT && echo "$REP" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
10191 echo "diff<<EOF" >> $GITHUB_OUTPUT && echo "$DIFF" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
@@ -130,7 +120,7 @@ jobs:
130120
131121 - name : Upload code coverage
132122 if : matrix.go-version == env.COV_GO_VERSION
133- uses : codecov/codecov-action@v1
123+ uses : codecov/codecov-action@v5
134124 with :
135- file : ./unit.coverprofile
125+ files : ./unit.coverprofile
136126 flags : unittests
0 commit comments