Skip to content

Commit 6c32984

Browse files
authored
Add coverage report to pull requests (#864)
The coverage job is failing because there is no coverage data for past runs. Once we merge the PR, we can have previous coverage data for comparison.
1 parent f8bf96f commit 6c32984

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

.github/workflows/build.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,18 @@ jobs:
5656
go-version-file: 'go.mod'
5757

5858
- name: Run tests
59-
run: go test ./...
59+
run: go test -cover -coverprofile=coverage.out ./...
6060
env:
6161
POSTGRES_VERSION: ${{ matrix.pgVersion }}
6262
PGROLL_TEST_SCHEMA: ${{ matrix.testSchema }}
6363

64+
- name: Archive code coverage results
65+
uses: actions/upload-artifact@v4
66+
if: matrix.pgVersion == 'latest' && matrix.testSchema == 'public'
67+
with:
68+
name: code-coverage
69+
path: coverage.out
70+
6471
lint:
6572
name: lint
6673
runs-on: ubuntu-24.04
@@ -124,6 +131,21 @@ jobs:
124131
exit 1
125132
fi
126133
134+
coverage:
135+
if: github.event_name == 'pull_request'
136+
runs-on: ubuntu-latest
137+
needs: test
138+
permissions:
139+
contents: read
140+
actions: read
141+
pull-requests: write
142+
steps:
143+
- uses: fgrosse/go-coverage-report@v1.2.0
144+
with:
145+
coverage-artifact-name: "code-coverage"
146+
coverage-file-name: "coverage.out"
147+
root-package: "github.com/xataio/pgroll"
148+
127149
code-generation:
128150
name: code generation
129151
runs-on: ubuntu-24.04

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ bin/license-header-checker
44
.DS_Store
55
.env
66
pgroll
7+
coverage.out
78

89
dist/

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ examples: ledger
3636
@go clean
3737

3838
test:
39-
go test ./...
39+
go test -coverprofile=coverage.out -cover ./...
4040

4141
bench:
4242
go test ./internal/benchmarks -v -benchtime=1x -bench .

0 commit comments

Comments
 (0)