Skip to content

Commit 53cf8c7

Browse files
committed
add test.yml
1 parent ff515ba commit 53cf8c7

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Unit-Test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
types:
8+
- opened
9+
- synchronize
10+
- reopened
11+
- ready_for_review
12+
13+
push:
14+
branches:
15+
- main
16+
17+
release:
18+
types:
19+
- created
20+
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
unit-test-coverage:
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- uses: actions/setup-go@v6
31+
with:
32+
go-version: "1.25"
33+
34+
- uses: actions/checkout@v5
35+
36+
- name: Unit Tests
37+
run: |
38+
make test
39+
env:
40+
TEST_TARGET: "./x/..."
41+
TEST_ARGS: "-timeout 10m -coverprofile=./coverage.out -covermode=atomic -v"
42+
43+
- name: Filter out DONTCOVER
44+
run: |
45+
excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')"
46+
excludelist+=" $(find ./ -type f -name '*.pb.go')"
47+
excludelist+=" $(find ./ -type f -name '*.pb.gw.go')"
48+
for filename in ${excludelist}; do
49+
filename=$(echo $filename | sed 's/^.\///g')
50+
echo "Excluding ${filename} from coverage report..."
51+
sed -i "/$(echo $filename | sed 's/\//\\\//g')/d" ./coverage.out
52+
done
53+
54+
- name: Convert coverage to lcov
55+
uses: jandelgado/gcov2lcov-action@v1
56+
57+
- name: LCOV Minimum test coverage checker
58+
uses: terencetcf/github-actions-lcov-minimum-coverage-checker@v1
59+
with:
60+
coverage-file: coverage.lcov
61+
minimum-coverage: 30
62+
63+
- name: Code Coverage Report
64+
if: github.event_name == 'pull_request'
65+
uses: vebr/jest-lcov-reporter@v0.2.0
66+
with:
67+
github-token: ${{ secrets.GITHUB_TOKEN }}
68+
lcov-file: coverage.lcov
69+
update-comment: true

0 commit comments

Comments
 (0)