Skip to content

Commit 047ab76

Browse files
committed
chore: Split lint and test workflows
feat: added code coverage reporting
1 parent eb348bd commit 047ab76

File tree

2 files changed

+45
-23
lines changed

2 files changed

+45
-23
lines changed

.github/workflows/lint.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: "Lint"
2+
on:
3+
pull_request:
4+
types: [ opened, synchronize ]
5+
paths-ignore:
6+
- '*.md'
7+
branches:
8+
- master
9+
10+
workflow_dispatch:
11+
12+
jobs:
13+
lint:
14+
name: "Run linter"
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- uses: reviewdog/action-setup@v1
22+
with:
23+
reviewdog_version: latest

.github/workflows/test.yaml

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,50 @@
1-
name: "Lint and test"
2-
1+
name: "Test"
32
on:
43
push:
54
branches:
65
- master
76
paths-ignore:
87
- '*.md'
8+
99
pull_request:
1010
types: [ opened, synchronize ]
1111
paths-ignore:
1212
- '*.md'
1313
branches:
1414
- master
1515

16-
jobs:
17-
lint:
18-
name: "Run linters"
19-
runs-on: ubuntu-latest
20-
21-
steps:
22-
- name: Checkout
23-
uses: actions/checkout@v4
24-
25-
- name: Setup Go
26-
uses: actions/setup-go@v5
27-
with:
28-
go-version: 1.22.1
29-
30-
- name: golangci-lint
31-
uses: golangci/golangci-lint-action@v6
32-
with:
33-
version: latest
16+
workflow_dispatch:
3417

18+
jobs:
3519
test:
3620
name: Run unit tests
3721
runs-on: ubuntu-latest
3822

3923
steps:
40-
- name: Checkout code
24+
- name: Checkout
4125
uses: actions/checkout@v4
4226

4327
- name: Setup Go
4428
uses: actions/setup-go@v5
4529
with:
46-
go-version: 1.22.1
30+
go-version: 1.23.0
4731

4832
- name: Install dependencies and run tests
4933
run: |
5034
go mod download
51-
go test -v ./...
35+
go test -v ./... -coverpkg=./... -short -coverprofile=unit_coverage.out
36+
37+
code_coverage:
38+
name: "Code coverage report"
39+
if: github.event_name == 'pull_request' # Do not run when workflow is triggered by push to main branch
40+
runs-on: ubuntu-latest
41+
needs: test
42+
permissions:
43+
contents: read
44+
actions: read # to download code coverage results from "test" job
45+
pull-requests: write # write permission needed to comment on PR
46+
steps:
47+
- uses: fgrosse/[email protected]
48+
with:
49+
coverage-artifact-name: "code-coverage" # can be omitted if you used this default value
50+
coverage-file-name: unit_coverage.out

0 commit comments

Comments
 (0)