Skip to content

Commit

Permalink
Add coverage to github action
Browse files Browse the repository at this point in the history
  • Loading branch information
ryukinix committed Jul 24, 2020
1 parent cfbdac6 commit f03426c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
52 changes: 46 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
on: [push, pull_request]
name: test
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v1
with:
go-version: 1.13.x
- name: Checkout code
uses: actions/checkout@v1
- name: Install golangci-lint
run: |
go get github.com/golangci/golangci-lint/cmd/golangci-lint
- name: Run linters
run: |
export PATH=$PATH:$(go env GOPATH)/bin
golangci-lint -E bodyclose,misspell,gocyclo,dupl,gofmt,golint,unconvert,goimports,depguard,gocritic,funlen,interfacer run
test:
strategy:
matrix:
Expand All @@ -9,12 +25,36 @@ jobs:
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v2
if: success()
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Build code
run: go build
- name: Test
run: go test ./...
uses: actions/checkout@v1
- name: Run tests
run: go test -v -covermode=count

coverage:
runs-on: ubuntu-latest
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v1
with:
go-version: 1.13.x
- name: Checkout code
uses: actions/checkout@v1
- name: Calc coverage
run: |
export PATH=$PATH:$(go env GOPATH)/bin
go test -v -covermode=count -coverprofile=coverage.out
- name: Convert coverage to lcov
uses: jandelgado/gcov2lcov-action@v1.0.0
with:
infile: coverage.out
outfile: coverage.lcov
- name: Coveralls
uses: coverallsapp/github-action@v1.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coverage.lcov
2 changes: 1 addition & 1 deletion troll_shield.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func kickTroll(bot TrollShieldBot, update *telegram.Update, user telegram.User,
telegram.KickChatMemberConfig{ChatMemberConfig: chatMember},
)

if resp.Ok == false || err != nil {
if !resp.Ok || err != nil {
log.Printf(
"[!] Kicking %q did not work, error code %v: %v",
user.FirstName, resp.ErrorCode, resp.Description,
Expand Down
2 changes: 1 addition & 1 deletion troll_shield_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func TestKickTroll(t *testing.T) {
kickTroll(&botnilson, &update, user, "@trollhouse")
}

func testWelcomeMessage(t *testing.T) {
func TestWelcomeMessage(t *testing.T) {
botnilson := BotMockup{}
update := telegram.Update{}
message := telegram.Message{}
Expand Down

0 comments on commit f03426c

Please sign in to comment.