Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: lint
on:
- pull_request
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ">=1.18.0"
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
15 changes: 15 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: test
on:
- pull_request
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ">=1.18.0"
- name: Run tests
run: make test
62 changes: 62 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
run:
timeout: 2m

linters:
enable:
- asciicheck
- bodyclose
- contextcheck
- deadcode
- dogsled
- durationcheck
- dupl
- errcheck
- errchkjson
- errname
- errorlint
- exhaustive
- exportloopref
- gocognit
- gocritic
- gofumpt
- goimports
- gomnd
- gomoddirectives
- gosec
- gosimple
- govet
- ifshort
- ineffassign
- importas
- misspell
- nilerr
- noctx
- prealloc
- predeclared
- revive
- staticcheck
- thelper
- tparallel
- unconvert
- unparam
- unused
- varcheck
- whitespace
- wrapcheck

linters-settings:
unparam:
check-exported: false
unused:
check-exported: false
gocognit:
min-complexity: 20
wrapcheck:
ignoreSigs:
- .Errorf(
- errors.New(
- status.Error(
- retry.Recoverable(
- retry.Unrecoverable(

modules-download-mode: readonly
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.PHONY: proto
proto:
cd api/proto && \
protoc \
--go_opt=Mmux.proto=github.com/bbralion/CTFloodBot/internal/genproto \
--go-grpc_opt=Mmux.proto=github.com/bbralion/CTFloodBot/internal/genproto \
--go_opt=paths=source_relative \
--go-grpc_opt=paths=source_relative \
--go_out=../../internal/genproto \
--go-grpc_out=../../internal/genproto \
mux.proto

.PHONY: mocks
mocks:
mockgen \
-package=mocks \
-destination=internal/mocks/mux_mock.go \
github.com/bbralion/CTFloodBot/internal/genproto MultiplexerServiceClient,MultiplexerService_RegisterHandlerClient
mockgen \
-package mocks \
-destination=internal/mocks/tgbotapi_mock.go \
--mock_names HttpClient=MockTGBotAPIHTTPClient \
github.com/go-telegram-bot-api/telegram-bot-api HttpClient

.PHONY: test
test:
go test -v -race -count=1 ./...

.PHONY: cover
cover:
go test -race -count=1 -covermode=atomic -coverprofile cover.tmp.out -coverpkg=./... -v ./... && \
grep -v 'genproto\|mocks' cover.tmp.out > cover.out
go tool cover -func cover.out && \
go tool cover -html cover.out -o cover.html && \
open cover.html && sleep 1 && \
rm -f cover.tmp.out cover.out cover.html

.PHONY: lint
lint:
golangci-lint run -v
27 changes: 27 additions & 0 deletions api/proto/mux.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
syntax = "proto3";
package mux;

// Config specifies the information clients require to connect to the proxy.
message Config {
string proxy_endpoint = 1;
}

// Update is a single update received by the proxy, passed as the actual stringified update object.
message Update {
string json = 1;
}

message ConfigRequest {}

message ConfigResponse {
Config config = 1;
}

message RegisterRequest {
repeated string matchers = 1;
}

service MultiplexerService {
rpc GetConfig(ConfigRequest) returns (ConfigResponse);
rpc RegisterHandler(RegisterRequest) returns (stream Update);
}
43 changes: 0 additions & 43 deletions cmd/aboba-handler/main.go

This file was deleted.

76 changes: 0 additions & 76 deletions cmd/core/main.go

This file was deleted.

29 changes: 0 additions & 29 deletions cmd/debug-handler/main.go

This file was deleted.

43 changes: 0 additions & 43 deletions cmd/shake-cat-handler/main.go

This file was deleted.

4 changes: 0 additions & 4 deletions config_core.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions config_handler.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions docker/docker-compose-redis-only.yml

This file was deleted.

Loading