Skip to content

Commit 05dfbee

Browse files
committed
feat: self-host coverage badge
1 parent 52a41c6 commit 05dfbee

10 files changed

Lines changed: 33 additions & 27 deletions

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
pull_request:
44
branches:
55
- main
6-
permissions: read-all
6+
permissions: {}
77
jobs:
88
build-snapshot:
99
permissions:

.github/workflows/codeql-analysis.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ on:
66
pull_request:
77
branches:
88
- main
9-
permissions:
10-
contents: read
9+
permissions: {}
1110
jobs:
1211
analyze:
1312
permissions:

.github/workflows/coverage.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@ on:
33
push:
44
branches:
55
- main
6-
permissions:
7-
contents: read
6+
permissions: {}
87
jobs:
98
coverage:
9+
permissions:
10+
contents: write
1011
runs-on: ubuntu-latest
1112
steps:
1213
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
13-
- name: Configure git
14-
run: |
15-
git config --global user.name "$GITHUB_ACTOR"
16-
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
1714
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
1815
with:
1916
go-version: stable
2017
- name: Calculate coverage
2118
run: |
22-
go test -v -covermode=count -coverprofile=coverage.out.raw -coverpkg=./... ./...
23-
grep -v mock_ coverage.out.raw > coverage.out
24-
- name: Convert coverage to lcov
25-
uses: jandelgado/gcov2lcov-action@c680c0f7c7442485f1749eb2a13e54a686e76eb5 # v1.0.9
26-
- name: Upload coverage to Coveralls
27-
uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949 # v2.2.3
19+
go test -v -covermode=count -coverprofile=cover.out.raw -coverpkg=./... ./...
20+
# remove mocks from coverage calculation
21+
grep -v mock_ cover.out.raw > cover.out
22+
- name: Generage coverage badge
23+
uses: vladopajic/go-test-coverage@v2
2824
with:
29-
github-token: ${{ secrets.github_token }}
25+
profile: cover.out
26+
local-prefix: github.com/smlx/go-cli-github
27+
git-token: ${{ secrets.GITHUB_TOKEN }}
28+
# orphan branch for storing badges
29+
git-branch: badges

.github/workflows/dependabot-automerge.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ on:
44
pull_request:
55
branches:
66
- main
7-
permissions:
8-
contents: read
7+
permissions: {}
98
jobs:
109
dependabot-automerge:
1110
permissions:

.github/workflows/dependency-review.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ on:
33
pull_request:
44
branches:
55
- main
6-
permissions:
7-
contents: read
6+
permissions: {}
87
jobs:
98
dependency-review:
9+
permissions:
10+
contents: read
1011
runs-on: ubuntu-latest
1112
steps:
1213
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

.github/workflows/lint.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ on:
33
pull_request:
44
branches:
55
- main
6-
permissions:
7-
contents: read
6+
permissions: {}
87
jobs:
98
lint-go:
9+
permissions:
10+
contents: read
1011
runs-on: ubuntu-latest
1112
steps:
1213
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
@@ -17,13 +18,17 @@ jobs:
1718
with:
1819
args: --timeout=180s
1920
lint-commits:
21+
permissions:
22+
contents: read
2023
runs-on: ubuntu-latest
2124
steps:
2225
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2326
with:
2427
fetch-depth: 0
2528
- uses: wagoid/commitlint-github-action@0d749a1a91d4770e983a7b8f83d4a3f0e7e0874e # v5.4.4
2629
lint-actions:
30+
permissions:
31+
contents: read
2732
runs-on: ubuntu-latest
2833
steps:
2934
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

.github/workflows/ossf-analysis.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ on:
33
push:
44
branches:
55
- main
6-
permissions: read-all
6+
permissions: {}
77
jobs:
88
ossf-scorecard-analysis:
99
runs-on: ubuntu-latest
1010
permissions:
11+
contents: read
1112
# Needed if using Code scanning alerts
1213
security-events: write
1314
# Needed for GitHub OIDC token if publish_results is true

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
push:
44
branches:
55
- main
6-
permissions: read-all
6+
permissions: {}
77
jobs:
88
release-tag:
99
permissions:

.github/workflows/test.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ on:
33
pull_request:
44
branches:
55
- main
6-
permissions:
7-
contents: read
6+
permissions: {}
87
jobs:
98
test-go:
9+
permissions:
10+
contents: read
1011
runs-on: ubuntu-latest
1112
steps:
1213
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Release](https://github.com/smlx/go-cli-github/actions/workflows/release.yaml/badge.svg)](https://github.com/smlx/go-cli-github/actions/workflows/release.yaml)
44
[![Go Reference](https://pkg.go.dev/badge/github.com/smlx/go-cli-github.svg)](https://pkg.go.dev/github.com/smlx/go-cli-github)
5-
[![Coverage](https://coveralls.io/repos/github/smlx/go-cli-github/badge.svg?branch=main)](https://coveralls.io/github/smlx/go-cli-github?branch=main)
5+
![coverage](https://raw.githubusercontent.com/smlx/go-cli-github/badges/.badges/main/coverage.svg)
66
[![Go Report Card](https://goreportcard.com/badge/github.com/smlx/go-cli-github)](https://goreportcard.com/report/github.com/smlx/go-cli-github)
77
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/smlx/go-cli-github/badge)](https://securityscorecards.dev/viewer/?uri=github.com/smlx/go-cli-github)
88
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8168/badge)](https://www.bestpractices.dev/projects/8168)

0 commit comments

Comments
 (0)