Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

golangci-lintを導入 #211

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
38 changes: 38 additions & 0 deletions .github/workflows/test-go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Lint and Test golang

on:
pull_request:
push:
branches:
- main
- develop

jobs:
# golangci:
# name: lint
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-go@v4
# with:
# go-version: '1.21'
# cache: false
# - name: golangci-lint
# uses: golangci/golangci-lint-action@v3
# with:
# version: v1.54
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Test
run: |
go test -v ./...
- name: Build State manager
run: |
go build backend/state-manager/cmd/main.go

16 changes: 16 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
linters:
disable-all: true
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
- gosec
- godot
- forbidigo
- gocritic
- revive
- gofmt
20 changes: 10 additions & 10 deletions backend/state-manager/pkg/db/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ func Test_ConnectDB(t *testing.T) {
Open()
}

func Test_SetPoint(t *testing.T) {
func Test_UpdatePoint(t *testing.T) {
defer C()
err := godotenv.Load("../../cmd/.env")
if err != nil {
panic(err)
}
Open()
SetPoint(&statev1.PointAndState{
UpdatePoint(&statev1.PointAndState{
Id: "test",
State: statev1.PointStateEnum_POINT_STATE_REVERSE,
})
Expand All @@ -36,14 +36,14 @@ func Test_SetPoint(t *testing.T) {
}
}

func Test_SetStop(t *testing.T) {
func Test_UpdateStop(t *testing.T) {
defer C()
err := godotenv.Load("../../cmd/.env")
if err != nil {
panic(err)
}
Open()
SetStop(&statev1.StopAndState{
UpdateStop(&statev1.StopAndState{
Id: "test",
State: statev1.StopStateEnum_STOP_STATE_GO,
})
Expand All @@ -63,11 +63,11 @@ func Test_GetPoints(t *testing.T) {
panic(err)
}
Open()
SetPoint(&statev1.PointAndState{
UpdatePoint(&statev1.PointAndState{
Id: "test",
State: statev1.PointStateEnum_POINT_STATE_REVERSE,
})
SetPoint(&statev1.PointAndState{
UpdatePoint(&statev1.PointAndState{
Id: "test2",
State: statev1.PointStateEnum_POINT_STATE_NORMAL,
})
Expand All @@ -84,11 +84,11 @@ func Test_GetStops(t *testing.T) {
panic(err)
}
Open()
SetStop(&statev1.StopAndState{
UpdateStop(&statev1.StopAndState{
Id: "test",
State: statev1.StopStateEnum_STOP_STATE_GO,
})
SetStop(&statev1.StopAndState{
UpdateStop(&statev1.StopAndState{
Id: "test2",
State: statev1.StopStateEnum_STOP_STATE_STOP,
})
Expand All @@ -105,14 +105,14 @@ func Test_GetBlocks(t *testing.T) {
panic(err)
}
Open()
err = SetBlock(&statev1.BlockState{
err = UpdateBlock(&statev1.BlockState{
BlockId: "test",
State: statev1.BlockStateEnum_BLOCK_STATE_OPEN,
})
if err != nil {
t.Fatal("error")
}
err = SetBlock(&statev1.BlockState{
err = UpdateBlock(&statev1.BlockState{
BlockId: "test2",
State: statev1.BlockStateEnum_BLOCK_STATE_CLOSE,
})
Expand Down
Loading