Skip to content

Commit

Permalink
ci: Add linting and code coverage (#89)
Browse files Browse the repository at this point in the history
* ci: add config for golangci-lint

* chore: lint the codebase

* ci: add lint job

* ci: integrate coveralls

* ci: fix missing checkout step in test job

* docs: add coverage badge
  • Loading branch information
turtleDev authored Jul 18, 2024
1 parent 3e5bc0a commit b5c4d76
Show file tree
Hide file tree
Showing 32 changed files with 147 additions and 154 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/build.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions .github/workflows/integration-test-setup/action.yaml

This file was deleted.

42 changes: 0 additions & 42 deletions .github/workflows/integration-test.yaml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Lint

on:
- push
- pull_request

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v2
- name: setup go
uses: actions/setup-go@v3
with:
go-version: "1.22.4"
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.59.1
62 changes: 62 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Test

on:
- push
- pull_request

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Setup Docker
uses: docker-practice/actions-setup-docker@master
- name: Install Protoc
uses: arduino/setup-protoc@v1
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: "1.22.4"
- name: Checkout code
uses: actions/checkout@v2
- name: Initialise test config
run: cp .env.test .env
- name: Start raccoon
run: make docker-run
- name: Run tests
run: go test ./... -v -coverprofile=coverage.out
env:
INTEGTEST_BOOTSTRAP_SERVER: 'localhost:9094'
INTEGTEST_HOST: 'localhost:8080'
INTEGTEST_TOPIC_FORMAT: 'clickstream-%s-log'
GRPC_SERVER_ADDR: 'localhost:8081'
PUBSUB_EMULATOR_HOST: 'localhost:8085'
LOCALSTACK_HOST: 'http://localhost:4566'
- name: Upload coverage data
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
smoke-test:
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: "1.22.4"
- name: Install Protoc
uses: arduino/setup-protoc@v1
- uses: actions/checkout@v2
- name: Build
run: make build
benchmark:
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: "1.22.4"
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Invoking go bench test
run: make test-bench
30 changes: 30 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
run:
timeout: 5m
skip-dirs:
output:
formats:
- format: 'colored-line-number'
linters:
enable-all: false
disable-all: true
enable:
- govet
- goimports
- thelper
- tparallel
- unconvert
- wastedassign
- revive
- staticcheck
- unused
- gofmt
- whitespace
- misspell
linters-settings:
revive:
ignore-generated-header: true
severity: warning
issues:
fix: true
severity:
default-severity: error
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

![build workflow](https://github.com/raystack/raccoon/actions/workflows/build.yaml/badge.svg)
![package workflow](https://github.com/raystack/raccoon/actions/workflows/release.yaml/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/raystack/raccoon/badge.svg?branch=main)](https://coveralls.io/github/raystack/raccoon?branch=main)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?logo=apache)](LICENSE)
[![Version](https://img.shields.io/github/v/release/raystack/raccoon?logo=semantic-release)](Version)

Expand Down
3 changes: 1 addition & 2 deletions app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"syscall"
"time"


"github.com/raystack/raccoon/collector"
"github.com/raystack/raccoon/config"
"github.com/raystack/raccoon/logger"
Expand Down Expand Up @@ -57,7 +56,7 @@ func StartServer(ctx context.Context, cancel context.CancelFunc) {
}

func shutDownServer(ctx context.Context, cancel context.CancelFunc, httpServices services.Services, bufferChannel chan collector.CollectRequest, workerPool *worker.Pool, pub Publisher) {
signalChan := make(chan os.Signal)
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
for {
sig := <-signalChan
Expand Down
1 change: 0 additions & 1 deletion config/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func TestServerWsConfig(t *testing.T) {
assert.Equal(t, "8080", ServerWs.AppPort)
assert.Equal(t, time.Duration(1)*time.Millisecond, ServerWs.PingInterval)
assert.Equal(t, time.Duration(1)*time.Millisecond, ServerWs.PongWaitInterval)

}

func TestGRPCServerConfig(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions config/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,9 @@ func publisherKinesisLoader() {
DefaultShards: uint32(util.MustGetInt(envStreamDefaultShards)),
PublishTimeout: util.MustGetDuration(envPublishTimeout, time.Millisecond),
}

}

func publisherConfigLoader() {

viper.SetDefault("PUBLISHER_TYPE", "kafka")

Publisher = util.MustGetString("PUBLISHER_TYPE")
Expand Down
1 change: 0 additions & 1 deletion config/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ func serverWsConfigLoader() {
}

func serverGRPCConfigLoader() {

viper.SetDefault("SERVER_GRPC_PORT", "8081")
ServerGRPC = serverGRPC{
Port: util.MustGetString("SERVER_GRPC_PORT"),
Expand Down
1 change: 0 additions & 1 deletion config/util/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,4 @@ func Contains(key string, slice []string) bool {
}

return false

}
1 change: 0 additions & 1 deletion deserialization/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ func DeserializeProto(b []byte, i interface{}) error {
return ErrInvalidProtoMessage
}
return proto.Unmarshal(b, msg)

}
Loading

0 comments on commit b5c4d76

Please sign in to comment.