Skip to content

Commit 3a7572d

Browse files
authored
feat: Add comprehensive test coverage improving from 41.4% to 95.7% (#2)
* update readme, add test coverage * update workflow * fix windows parse bug * fix windows workflow ... again * still fighting windows * no code coverage for windows
1 parent 64f520a commit 3a7572d

File tree

21 files changed

+1677
-50
lines changed

21 files changed

+1677
-50
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# These are supported funding model platforms
22

3-
github: markbates
4-
patreon: buffalo
3+
github: gopherguides

.github/workflows/tests.yml

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,66 @@
11
name: Tests
2-
on: [push]
3-
jobs:
42

5-
tests-on:
6-
name: ${{matrix.go-version}} ${{matrix.os}}
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
test:
11+
name: Test Go ${{matrix.go-version}} on ${{matrix.os}}
712
runs-on: ${{ matrix.os }}
813
strategy:
914
matrix:
10-
go-version: [1.14.x, 1.15.x]
11-
os: [macos-latest, ubuntu-latest]
15+
go-version: ['1.24.x']
16+
os: [ubuntu-latest, macos-latest, windows-latest]
17+
1218
steps:
13-
- name: Checkout Code
14-
uses: actions/checkout@v1
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v5
1524
with:
16-
fetch-depth: 1
17-
- name: Test
25+
go-version: ${{ matrix.go-version }}
26+
cache-dependency-path: go.sum
27+
28+
- name: Verify Go version
29+
run: go version
30+
31+
- name: Download dependencies
32+
run: go mod download
33+
34+
- name: Verify dependencies
35+
run: go mod verify
36+
37+
- name: Run tests
38+
run: go test -race . ./cmd/remark ./cmd/retoc ./htm ./md
39+
40+
- name: Check formatting
1841
run: |
19-
go mod tidy -v
20-
go test -race ./...
42+
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
43+
echo "Code is not formatted. Please run 'gofmt -s -w .'"
44+
gofmt -s -l .
45+
exit 1
46+
fi
47+
if: runner.os != 'Windows'
48+
49+
- name: Run go vet
50+
run: go vet ./...
51+
52+
- name: Generate coverage report
53+
run: |
54+
mkdir -p .coverage
55+
go test -coverprofile=.coverage/coverage.out . ./cmd/remark ./cmd/retoc ./htm ./md
56+
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.24.x'
57+
58+
- name: Upload coverage to Codecov
59+
uses: codecov/codecov-action@v4
60+
with:
61+
file: ./.coverage/coverage.out
62+
flags: unittests
63+
name: codecov-umbrella
64+
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.24.x'
2165

2266

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ gin-bin
2424
.idea/
2525
.vscode
2626
cover.out
27+
coverage.out
28+
.coverage/

0 commit comments

Comments
 (0)