Skip to content

Commit f03426c

Browse files
committed
Add coverage to github action
1 parent cfbdac6 commit f03426c

File tree

3 files changed

+48
-8
lines changed

3 files changed

+48
-8
lines changed

.github/workflows/test.yml

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
on: [push, pull_request]
22
name: test
33
jobs:
4+
lint:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- name: Install Go
8+
uses: actions/setup-go@v1
9+
with:
10+
go-version: 1.13.x
11+
- name: Checkout code
12+
uses: actions/checkout@v1
13+
- name: Install golangci-lint
14+
run: |
15+
go get github.com/golangci/golangci-lint/cmd/golangci-lint
16+
- name: Run linters
17+
run: |
18+
export PATH=$PATH:$(go env GOPATH)/bin
19+
golangci-lint -E bodyclose,misspell,gocyclo,dupl,gofmt,golint,unconvert,goimports,depguard,gocritic,funlen,interfacer run
420
test:
521
strategy:
622
matrix:
@@ -9,12 +25,36 @@ jobs:
925
runs-on: ${{ matrix.platform }}
1026
steps:
1127
- name: Install Go
12-
uses: actions/setup-go@v2
28+
if: success()
29+
uses: actions/setup-go@v1
1330
with:
1431
go-version: ${{ matrix.go-version }}
1532
- name: Checkout code
16-
uses: actions/checkout@v2
17-
- name: Build code
18-
run: go build
19-
- name: Test
20-
run: go test ./...
33+
uses: actions/checkout@v1
34+
- name: Run tests
35+
run: go test -v -covermode=count
36+
37+
coverage:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Install Go
41+
if: success()
42+
uses: actions/setup-go@v1
43+
with:
44+
go-version: 1.13.x
45+
- name: Checkout code
46+
uses: actions/checkout@v1
47+
- name: Calc coverage
48+
run: |
49+
export PATH=$PATH:$(go env GOPATH)/bin
50+
go test -v -covermode=count -coverprofile=coverage.out
51+
- name: Convert coverage to lcov
52+
uses: jandelgado/[email protected]
53+
with:
54+
infile: coverage.out
55+
outfile: coverage.lcov
56+
- name: Coveralls
57+
uses: coverallsapp/[email protected]
58+
with:
59+
github-token: ${{ secrets.GITHUB_TOKEN }}
60+
path-to-lcov: coverage.lcov

troll_shield.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func kickTroll(bot TrollShieldBot, update *telegram.Update, user telegram.User,
145145
telegram.KickChatMemberConfig{ChatMemberConfig: chatMember},
146146
)
147147

148-
if resp.Ok == false || err != nil {
148+
if !resp.Ok || err != nil {
149149
log.Printf(
150150
"[!] Kicking %q did not work, error code %v: %v",
151151
user.FirstName, resp.ErrorCode, resp.Description,

troll_shield_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func TestKickTroll(t *testing.T) {
125125
kickTroll(&botnilson, &update, user, "@trollhouse")
126126
}
127127

128-
func testWelcomeMessage(t *testing.T) {
128+
func TestWelcomeMessage(t *testing.T) {
129129
botnilson := BotMockup{}
130130
update := telegram.Update{}
131131
message := telegram.Message{}

0 commit comments

Comments
 (0)