99env :
1010 GO111MODULE : " on"
1111 RUN_BASE_COVERAGE : " on" # Runs test for PR base in case base test coverage is missing.
12+ COV_GO_VERSION : 1.17.x # Version of Go to collect coverage
1213jobs :
1314 test :
1415 strategy :
1516 matrix :
16- go-version : [ 1.16.x, 1.17.x ]
17+ go-version : [ 1.16.x, 1.17.x, tip ]
1718 runs-on : ubuntu-latest
1819 steps :
19- - name : Install Go
20+ - name : Install Go stable
21+ if : matrix.go-version != 'tip'
2022 uses : actions/setup-go@v2
2123 with :
2224 go-version : ${{ matrix.go-version }}
25+ - name : Install Go tip
26+ if : matrix.go-version == 'tip'
27+ run : |
28+ 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
29+ ls -lah gotip.tar.gz
30+ mkdir -p ~/sdk/gotip
31+ tar -C ~/sdk/gotip -xzf gotip.tar.gz
32+ ~/sdk/gotip/bin/go version
33+ echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
2334 - name : Checkout code
2435 uses : actions/checkout@v2
2536 - name : Go cache
@@ -36,21 +47,21 @@ jobs:
3647 ${{ runner.os }}-go-cache
3748 - name : Restore base test coverage
3849 id : base-coverage
39- if : matrix.go-version == '1.17.x'
50+ if : matrix.go-version == env.COV_GO_VERSION
4051 uses : actions/cache@v2
4152 with :
4253 path : |
4354 unit-base.txt
4455 # Use base sha for PR or new commit hash for master/main push in test result key.
4556 key : ${{ runner.os }}-unit-test-coverage-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }}
4657 - name : Checkout base code
47- if : matrix.go-version == '1.17.x' && env.RUN_BASE_COVERAGE == 'on' && steps.base-coverage.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != ''
58+ if : matrix.go-version == env.COV_GO_VERSION && env.RUN_BASE_COVERAGE == 'on' && steps.base-coverage.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != ''
4859 uses : actions/checkout@v2
4960 with :
5061 ref : ${{ github.event.pull_request.base.sha }}
5162 path : __base
5263 - name : Run test for base code
53- if : matrix.go-version == '1.17.x' && env.RUN_BASE_COVERAGE == 'on' && steps.base-coverage.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != ''
64+ if : matrix.go-version == env.COV_GO_VERSION && env.RUN_BASE_COVERAGE == 'on' && steps.base-coverage.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != ''
5465 run : |
5566 cd __base
5667 make | grep test-unit && (make test-unit && go tool cover -func=./unit.coverprofile | sed -e 's/.go:[0-9]*:\t/.go\t/g' | sed -e 's/\t\t*/\t/g' > ../unit-base.txt) || echo "No test-unit in base"
7182 run : cp unit.txt unit-base.txt
7283 - name : Comment Test Coverage
7384 continue-on-error : true
74- if : matrix.go-version == '1.17.x'
85+ if : matrix.go-version == env.COV_GO_VERSION
7586 uses : marocchino/sticky-pull-request-comment@v2
7687 with :
7788 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
8798 </details>
8899
89100 - name : Upload code coverage
90- if : matrix.go-version == '1.17.x'
101+ if : matrix.go-version == env.COV_GO_VERSION
91102 uses : codecov/codecov-action@v1
92103 with :
93104 file : ./unit.coverprofile
0 commit comments