Skip to content

Commit 613d243

Browse files
committed
update coverage
1 parent 61270c3 commit 613d243

2 files changed

Lines changed: 27 additions & 22 deletions

File tree

.github/workflows/go.yml

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,51 +41,56 @@ jobs:
4141
- name: Go report card
4242
uses: creekorful/goreportcard-action@v1.0
4343

44-
# Generate code coverage badge and push it to the 'badges' branch.
44+
# Generate code coverage badge and push it to the 'coverage' branch.
4545
# Reference it in your README.md like this:
4646
#
47-
# [![coverage](https://github.com/USERNAME/REPO/blob/badges/BRANCH/badge.svg)](#)
47+
# [![coverage](https://github.com/USERNAME/REPO/blob/coverage/BRANCH/badge.svg)](#)
4848
#
49-
# If you have a detailed HTML report of the coverage (here called coverage.html), replace the '#' with:
49+
# If you have a detailed HTML report of the coverage (here called report.html), replace the '#' with:
5050
#
51-
# https://htmlpreview.github.io/?https://github.com/USERNAME/REPO/blob/badges/BRANCH/coverage.html
51+
# https://htmlpreview.github.io/?https://github.com/USERNAME/REPO/blob/coverage/BRANCH/report.html
5252
#
53-
# To create the 'badges' branch for the repository:
53+
# You need to have given write permissions for the for the workflow:
5454
#
55-
# git checkout BRANCH
56-
# git checkout --orphan badges && git rm --cached $(git ls-files) && echo '# Badges branch' > README.md
57-
# git add README.md && git commit -m 'Add dedicated README' && git push origin badges
58-
# git checkout --force BRANCH
59-
55+
# permissions:
56+
# contents: write
57+
#
58+
# To create the 'coverage' branch for the repository (replace 'main' with the branch you want to publish for):
59+
#
60+
# git checkout main
61+
# git checkout --orphan coverage && git rm --cached $(git ls-files) && echo '# Coverage branch' > README.md
62+
# git add README.md && git commit -m 'Add README.md' && git push origin coverage
63+
# git checkout --force main
6064
- name: Extract branch name
6165
run: echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
6266
id: extract_branch
6367
- uses: actions/checkout@v3
6468
with:
65-
ref: badges
66-
path: badges
69+
ref: coverage
70+
path: coverage
6771
- name: Ensure directories for this branch exist
6872
env:
6973
BRANCH: ${{ steps.extract_branch.outputs.branch }}
70-
run: mkdir -p badges/${BRANCH}
74+
run: mkdir -p coverage/${BRANCH}
7175
- name: Extract code coverage
7276
id: coverage
7377
env:
7478
BRANCH: ${{ steps.extract_branch.outputs.branch }}
7579
# Change this to extract the coverage percentage (without the percent sign) for your language into COVERAGE.
7680
# Here we are using a 'coverage.out' file generated by 'go test -coverprofile=coverage.out ./...'
77-
# You may also generate a HTML report and place at 'badges/${BRANCH}/coverage.html'.
81+
# You may also generate a HTML report and place at 'coverage/${BRANCH}/report.html'.
7882
run: |
79-
echo "COVERAGE=$(go tool cover -func=coverage.out | grep total | tr -s '\t' | cut -f 3 | rev | cut -c2- | rev)" >> $GITHUB_OUTPUT
80-
go tool cover -html=coverage.out -o=badges/${BRANCH}/coverage.html
83+
echo "COVERAGE=$(go tool cover -func=coverage.out | tail -n 1 | tr -s '\t' | cut -f 3 | rev | cut -c2- | rev)" >> $GITHUB_OUTPUT
84+
go tool cover -html=coverage.out -o=coverage/${BRANCH}/report.html
8185
- name: Generate the badge SVG image
8286
uses: emibcn/badge-action@v2.0.3
8387
with:
8488
label: 'coverage'
8589
status: ${{ steps.coverage.outputs.coverage }}%
86-
path: badges/${{ steps.extract_branch.outputs.branch }}/badge.svg
90+
path: coverage/${{ steps.extract_branch.outputs.branch }}/badge.svg
8791
color: ${{
88-
steps.coverage.outputs.coverage > 90 && 'green' ||
92+
steps.coverage.outputs.coverage > 95 && 'green' ||
93+
steps.coverage.outputs.coverage > 90 && 'yellow,green,green' ||
8994
steps.coverage.outputs.coverage > 80 && 'yellow,green' ||
9095
steps.coverage.outputs.coverage > 70 && 'yellow' ||
9196
steps.coverage.outputs.coverage > 60 && 'orange,yellow' ||
@@ -98,11 +103,11 @@ jobs:
98103
env:
99104
BRANCH: ${{ steps.extract_branch.outputs.branch }}
100105
run: |
101-
pushd badges
106+
pushd coverage
102107
git config --local user.email "action@github.com"
103108
git config --local user.name "GitHub Action"
104109
test ! -f "${BRANCH}/badge.svg" || git add "${BRANCH}/badge.svg"
105-
test ! -f "${BRANCH}/coverage.html" || git add "${BRANCH}/coverage.html"
106-
test -z "$(git status --porcelain)" || git commit -m "update coverage"
110+
test ! -f "${BRANCH}/report.html" || git add "${BRANCH}/report.html"
111+
test -z "$(git status --porcelain)" || git commit -m "update"
107112
git push
108113
popd

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[![build](https://github.com/linkdata/deadlock/actions/workflows/go.yml/badge.svg)](https://github.com/linkdata/deadlock/actions/workflows/go.yml)
2-
[![coverage](https://github.com/linkdata/deadlock/blob/badges/main/badge.svg)](https://htmlpreview.github.io/?https://github.com/linkdata/deadlock/blob/badges/main/coverage.html)
2+
[![coverage](https://github.com/linkdata/deadlock/blob/coverage/main/badge.svg)](https://htmlpreview.github.io/?https://github.com/linkdata/deadlock/blob/coverage/main/report.html)
33
[![goreport](https://goreportcard.com/badge/github.com/linkdata/deadlock)](https://goreportcard.com/report/github.com/linkdata/deadlock)
44
[![Docs](https://godoc.org/github.com/linkdata/deadlock?status.svg)](https://godoc.org/github.com/linkdata/deadlock)
55

0 commit comments

Comments
 (0)