Skip to content
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
6 changes: 3 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
target: [linebot, screenshot]
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/cache@v4.0.2
- uses: actions/cache@v5.0.3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
target: [linebot, screenshot]
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/cache@v4.0.2
- uses: actions/cache@v5.0.3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
target: [linebot, screenshot]
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/cache@v4.0.2
- uses: actions/cache@v5.0.3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
golangci_lint_version:
type: string
required: false
default: "v1.58.1"
default: "v2.8.0"

jobs:
lint:
Expand All @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v6.0.2
with:
fetch-depth: 0
- uses: reviewdog/action-golangci-lint@v2.6.2
- uses: reviewdog/action-golangci-lint@v2.8.0
with:
go_version_file: go.mod
github_token: ${{ secrets.github_token }}
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
--health-retries 5
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/cache@v4.0.2
- uses: actions/cache@v5.0.3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test_and_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
matrix:
target: [firestore-emulator]
env:
GCLOUD_VERSION: "406.0.0"
GCLOUD_VERSION: "554.0.0"
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/cache@v4.0.2
- uses: actions/cache@v5.0.3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
contents: read
packages: read
checks: write
uses: ww24/linebot/.github/workflows/test.yaml@73705893378fa4d1f1bfa0bc76e55de0e7ad9283
uses: ww24/linebot/.github/workflows/test.yaml@014e186748c76fde2d0a7b5401f77a47062e940f

docker:
needs: [test]
Expand All @@ -67,7 +67,7 @@ jobs:
packages: write
id-token: write
security-events: write
uses: ww24/linebot/.github/workflows/docker.yml@73705893378fa4d1f1bfa0bc76e55de0e7ad9283
uses: ww24/linebot/.github/workflows/docker.yml@014e186748c76fde2d0a7b5401f77a47062e940f
with:
image_tag: latest
push: ${{ github.event_name == 'push' }}
Expand Down
171 changes: 87 additions & 84 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,112 +1,30 @@
version: "2"

run:
timeout: 3m

issues:
exclude-rules:
- linters:
- exhaustivestruct
- errcheck
- err113
- wrapcheck
- gochecknoglobals
- exhaustruct
- goconst
path: _test\.go$
- linters:
- gochecknoglobals
source: "Set = wire.NewSet"
- linters:
- gochecknoglobals
source: "var tracer = otel.Tracer"
- linters:
- mnd
source: "time."
- linters:
- mnd
source: "strconv.Parse"
- linters:
- wrapcheck
source: "code.With\\("
- linters:
- gocritic
text: "hugeParam:"
source: "slog.Record"

linters-settings:
gocyclo:
min-complexity: 15
gocritic:
enabled-checks:
- appendCombine
- boolExprSimplify
- builtinShadow
- commentedOutCode
- commentedOutImport
- docStub
- dupImport
- emptyFallthrough
- emptyStringTest
- equalFold
- hexLiteral
- hugeParam
- importShadow
- indexAlloc
- initClause
- methodExprCall
- nestingReduce
- nilValReturn
- octalLiteral
- paramTypeCombine
- ptrToRefParam
- rangeExprCopy
- rangeValCopy
- sloppyReassign
- stringXbytes
- typeAssertChain
- typeUnparen
- unnecessaryBlock
- weakCond
- yodaStyleExpr
gci:
sections:
- standard
- default
- prefix(github.com/ww24/linebot)
exhaustive:
default-signifies-exhaustive: true
exhaustruct:
include:
- "github.com/ww24/linebot/domain"

linters:
disable-all: true
enable:
- bodyclose
- errcheck
- errorlint
- exportloopref
- gochecknoglobals
- goconst
- gocritic
- gocyclo
- err113
- goimports
- gci
- mnd
- gosimple
- govet
- ineffassign
- misspell
- noctx
- staticcheck
- typecheck
- unconvert
- unparam
- unused
- nolintlint
- wrapcheck
- tparallel
- stylecheck
- prealloc
- exhaustive
- exhaustruct
Expand All @@ -116,3 +34,88 @@ linters:
- gosec
- nestif
- nakedret
settings:
gocyclo:
min-complexity: 15
gocritic:
enabled-checks:
- appendCombine
- boolExprSimplify
- builtinShadow
- commentedOutCode
- commentedOutImport
- docStub
- dupImport
- emptyFallthrough
- emptyStringTest
- equalFold
- hexLiteral
- hugeParam
- importShadow
- indexAlloc
- initClause
- methodExprCall
- nestingReduce
- nilValReturn
- octalLiteral
- paramTypeCombine
- ptrToRefParam
- rangeExprCopy
- rangeValCopy
- sloppyReassign
- stringXbytes
- typeAssertChain
- typeUnparen
- unnecessaryBlock
- weakCond
- yodaStyleExpr
exhaustive:
default-signifies-exhaustive: true
exhaustruct:
include:
- "github.com/ww24/linebot/domain"
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- exhaustivestruct
- errcheck
- err113
- wrapcheck
- gochecknoglobals
- exhaustruct
- goconst
path: _test\.go$
- linters:
- gochecknoglobals
source: "Set = wire.NewSet"
- linters:
- gochecknoglobals
source: "var tracer = otel.Tracer"
- linters:
- mnd
source: "time."
- linters:
- mnd
source: "strconv.Parse"
- linters:
- wrapcheck
source: "code.With\\("
- linters:
- gocritic
text: "hugeParam:"
source: "slog.Record"
formatters:
enable:
- gci
settings:
gci:
sections:
- standard
- default
- prefix(github.com/ww24/linebot)
13 changes: 2 additions & 11 deletions cmd/linebot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"time"

"cloud.google.com/go/profiler"
"go.uber.org/automaxprocs/maxprocs"
"google.golang.org/grpc/grpclog"

"github.com/ww24/linebot/internal/buildinfo"
Expand All @@ -37,7 +36,7 @@ func main() {

projectID, err := gcp.ProjectID()
if err != nil {
log.Printf("ERROR gcp.ProjectID: %+v", err)
panic(fmt.Errorf("ERROR gcp.ProjectID: %w", err))
}

if err := llog.SetOption(
Expand All @@ -47,18 +46,10 @@ func main() {
llog.RevisionID(buildinfo.Revision()),
llog.GCPProjectID(projectID),
); err != nil {
log.Printf("ERROR log.SetOption: %+v", err)
stop()
os.Exit(1)
panic(fmt.Errorf("ERROR log.SetOption: %w", err))
}
grpclog.SetLoggerV2(llog.NewGRPCLogger(slog.Default().Handler()))

// set GOMAXPROCS
infof := func(format string, args ...interface{}) { slog.Info(fmt.Sprintf(format, args...)) }
if _, err := maxprocs.Set(maxprocs.Logger(infof)); err != nil {
slog.WarnContext(ctx, "failed to set GOMAXPROCS", llog.Err(err))
}

bot, cleanup, err := register(ctx)
if err != nil {
slog.Error("main: register", llog.Err(err))
Expand Down
1 change: 0 additions & 1 deletion cmd/linebot/wire.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build wireinject
// +build wireinject

package main

Expand Down
Loading
Loading