Skip to content

Commit d20c171

Browse files
authored
chore: Generate test coverage reports (#2299)
1 parent c1edab7 commit d20c171

File tree

4 files changed

+998
-2
lines changed

4 files changed

+998
-2
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Generate Coverage Report
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
- cron: "0 6 * * 1"
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
gen-coverage-report:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
id-token: write
19+
contents: write
20+
steps:
21+
- uses: actions/checkout@v5
22+
with:
23+
token: ${{ secrets.GH_CQ_BOT }}
24+
- name: Set up Go 1.x
25+
uses: actions/setup-go@v6
26+
with:
27+
go-version: "1.25"
28+
cache: false
29+
- name: Generate Coverage Report
30+
run: make coverage
31+
32+
- name: Create Pull Request
33+
uses: peter-evans/create-pull-request@v7
34+
with:
35+
# required so the PR triggers workflow runs
36+
token: ${{ secrets.GH_CQ_BOT }}
37+
branch: chore/update_coverage_report
38+
base: main
39+
title: "chore: Update coverage report"
40+
commit-message: "chore: Update coverage report"
41+
body: This PR was created by a scheduled workflow to update the coverage report
42+
author: cq-bot <[email protected]>
43+
labels: automerge

.github/workflows/lint_markdown.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Vale
2424
uses: errata-ai/vale-action@dcded780f1ff68e2558e802a165a484a4a3e2fb8
2525
with:
26-
vale_flags: "--glob=!{docs/testdata/*,CHANGELOG.md,.github/styles/proselint/README.md,examples/simple_plugin/docs/*.md}"
26+
vale_flags: "--glob=!{docs/testdata/*,CHANGELOG.md,.github/styles/proselint/README.md,examples/simple_plugin/docs/*.md,coverage.md}"
2727
filter_mode: nofilter
2828
version: '3.0.3'
2929
env:
@@ -39,4 +39,4 @@ jobs:
3939
with:
4040
files: .
4141
config_file: .markdownlint.yaml
42-
ignore_files: "{docs/testdata/*,CHANGELOG.md,examples/simple_plugin/docs/*.md}"
42+
ignore_files: "{docs/testdata/*,CHANGELOG.md,examples/simple_plugin/docs/*.md,coverage.md}"

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,18 @@ benchmark-ci:
1515
go install go.bobheadxi.dev/[email protected]
1616
go test -bench . -benchmem ./... -run="^$$" | grep -v 'BenchmarkWriterMemory/' | gobenchdata --json bench.json
1717
rm -rf .delta.* && go run scripts/benchmark-delta/main.go bench.json
18+
19+
.PHONY: coverage
20+
coverage:
21+
go test -timeout 15m -coverprofile=coverage.out.tmp ./...
22+
cat coverage.out.tmp | grep -vE "MockGen|codegen|mocks" > coverage.out
23+
rm coverage.out.tmp
24+
echo "| File | Function | Coverage |" > coverage.md
25+
echo "| --- | --- | --- |" >> coverage.md
26+
go tool cover -func=coverage.out | tail -n +2 | while read line; do \
27+
file=$$(echo $$line | awk '{print $$1}'); \
28+
func=$$(echo $$line | awk '{print $$2}'); \
29+
cov=$$(echo $$line | awk '{print $$3}'); \
30+
printf "| %s | %s | %s |\\n" "$$file" "$$func" "$$cov" >> coverage.md; \
31+
done
32+
rm coverage.out

0 commit comments

Comments
 (0)