-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: boot-go <[email protected]>
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,44 @@ jobs: | |
|
||
- name: Test | ||
run: go test -cpu 2 -timeout 2m -race -v ./... | ||
|
||
- name: Test coverage | ||
run: | | ||
until go test -v -p 1 -covermode=count -coverprofile=coverage.out ./...; do | ||
echo Test coverage failed, retrying in 3 seconds... | ||
sleep 3 | ||
done | ||
- name: Tool cover to func | ||
run: go tool cover -func=coverage.out -o=cover.out | ||
|
||
- name: Obtain coverage | ||
run: echo "COVERAGE=$(grep -e 'total' cover.out | awk '{print $3;}')" >> $GITHUB_ENV | ||
|
||
- name: Create coverage badge | ||
uses: schneegans/[email protected] | ||
with: | ||
auth: ${{ secrets.GIST_SECRET }} | ||
gistID: c77b22000b3e249510dfb4542847c708 | ||
filename: test_coverage.json | ||
label: "test coverage" | ||
message: ${{ env.COVERAGE }} | ||
valColorRange: ${{ env.COVERAGE }} | ||
maxColorRange: 100 | ||
minColorRange: 0 | ||
|
||
- name: Tool cover to html | ||
run: go tool cover -html=coverage.out -o=cover.html | ||
|
||
- name: Obtain html coverage | ||
run: echo "HTML_COVERAGE=$(cat cover.html)" >> $GITHUB_ENV | ||
|
||
- name: Upload html coverage | ||
uses: gorgbus/gist-actions@main | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GIST_SECRET }} | ||
with: | ||
action: "update" | ||
gist_id: "c77b22000b3e249510dfb4542847c708" | ||
file_name: "cover.html" | ||
content: ${{ env.HTML_COVERAGE }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters