Skip to content

Commit 5243606

Browse files
committed
chore: Generate test coverage reports
1 parent c363695 commit 5243606

File tree

3 files changed

+1003
-0
lines changed

3 files changed

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

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 -race -timeout 3m -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)