From 813d3f9f780b25f99abbf176b7dcb5f81d428db9 Mon Sep 17 00:00:00 2001 From: kobayashi-m42 Date: Wed, 4 Jan 2023 11:10:20 +0900 Subject: [PATCH 1/5] =?UTF-8?q?go=201.19=20=E3=81=AB=E3=83=90=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=83=A7=E3=83=B3=E3=82=A2=E3=83=83=E3=83=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 4 ++-- Dockerfile | 2 +- go.mod | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3625e7b..b067fc9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: steps: - uses: actions/setup-go@v2 with: - go-version: '1.16' + go-version: '1.19' - uses: actions/checkout@v2 - name: golangci-lint uses: golangci/golangci-lint-action@v3 @@ -39,7 +39,7 @@ jobs: steps: - uses: actions/setup-go@v2 with: - go-version: '1.16' + go-version: '1.19' - name: checkout uses: actions/checkout@v3 - name: checkout migration repo diff --git a/Dockerfile b/Dockerfile index fb56e8c..0721f0e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax = docker/dockerfile:1.3 -FROM golang:1.16-alpine3.15 as base +FROM golang:1.19-alpine3.15 as base LABEL maintainer="https://github.com/nekochans" WORKDIR /go/app ENV CGO_ENABLED=0 diff --git a/go.mod b/go.mod index 2920f42..bcf4f26 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/nekochans/lgtm-cat-api -go 1.16 +go 1.19 require ( github.com/aws/aws-lambda-go v1.24.0 @@ -16,3 +16,18 @@ require ( github.com/google/uuid v1.3.0 go.uber.org/zap v1.17.0 ) + +require ( + github.com/aws/aws-sdk-go-v2/credentials v1.2.1 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.1.1 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.0.0 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.1.0 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.1.1 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.4.0 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.2.1 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.4.1 // indirect + github.com/aws/smithy-go v1.4.0 // indirect + github.com/jmespath/go-jmespath v0.4.0 // indirect + go.uber.org/atomic v1.7.0 // indirect + go.uber.org/multierr v1.6.0 // indirect +) From 4629e78b50732e12bf02af98ecd9e156b8af1b1c Mon Sep 17 00:00:00 2001 From: kobayashi-m42 Date: Wed, 4 Jan 2023 12:22:38 +0900 Subject: [PATCH 2/5] =?UTF-8?q?Go=20=E3=81=AE=E3=83=90=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E3=82=A2=E3=83=83=E3=83=97=E3=81=AB=E3=82=88?= =?UTF-8?q?=E3=82=8A=20golangci-lint=20=E3=81=A7=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=81=8C=E7=99=BA=E7=94=9F=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=9F=E3=81=AE=E3=81=A7?= =?UTF-8?q?=20golangci-lint=20=E3=82=92=E6=9C=80=E6=96=B0=E3=83=90?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 2 +- Makefile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b067fc9..b75a273 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.44.2 + version: v1.50.1 test: name: test runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index 254fb46..7e54354 100644 --- a/Makefile +++ b/Makefile @@ -4,11 +4,11 @@ sqlc-generate: .PHONY: lint lint: - docker run --rm -v `pwd`:/app -w /app golangci/golangci-lint:v1.44.2 golangci-lint run -v + docker run --rm -v `pwd`:/app -w /app golangci/golangci-lint:v1.50.1 golangci-lint run -v .PHONY: format format: - docker run --rm -v `pwd`:/app -w /app golangci/golangci-lint:v1.44.2 golangci-lint run -v --fix + docker run --rm -v `pwd`:/app -w /app golangci/golangci-lint:v1.50.1 golangci-lint run -v --fix .PHONY: run-normal-build run-normal-build: From 73d16927d4ef4e02afdf3d71ba878d82a598d6c1 Mon Sep 17 00:00:00 2001 From: kobayashi-m42 Date: Wed, 4 Jan 2023 12:24:00 +0900 Subject: [PATCH 3/5] =?UTF-8?q?golangci-lint=20format=20=E5=AE=9F=E8=A1=8C?= =?UTF-8?q?=E3=81=97=E3=80=81=E4=B8=8D=E8=A6=81=E3=81=AB=E3=81=AA=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92=E5=89=8A?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usecase/fetchlgtmimages/usecase_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/usecase/fetchlgtmimages/usecase_test.go b/usecase/fetchlgtmimages/usecase_test.go index 96d4f6d..7069649 100644 --- a/usecase/fetchlgtmimages/usecase_test.go +++ b/usecase/fetchlgtmimages/usecase_test.go @@ -40,8 +40,6 @@ var cdnDomain = "lgtm-images.lgtmeow.com" var testDb *sql.DB -// Go1.15 から TestMain には os.Exit() のコールが不要になったのでlintのルールを無効化 -//nolint:staticcheck func TestMain(m *testing.M) { dbCreator := &test.DbCreator{} var err error From 6a46ca225b3d733f8f9d77359c60c5cd6ae129ec Mon Sep 17 00:00:00 2001 From: kobayashi-m42 Date: Wed, 4 Jan 2023 12:37:45 +0900 Subject: [PATCH 4/5] =?UTF-8?q?golangci-lint=20=E3=81=A7=E6=8C=87=E6=91=98?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=9F=E3=82=A8=E3=83=A9=E3=83=BC=E3=82=92?= =?UTF-8?q?=E5=9B=9E=E9=81=BF=E3=81=99=E3=82=8B=E3=81=9F=E3=82=81=E3=81=AB?= =?UTF-8?q?=20ReadHeaderTimeout=20=E3=82=92=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cmd/local/main.go:24:9: G114: Use of net/http serve function that has no support for setting timeouts (gosec) err := http.ListenAndServe(":3333", r) --- cmd/local/main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/local/main.go b/cmd/local/main.go index 1b0d363..9b80fe4 100644 --- a/cmd/local/main.go +++ b/cmd/local/main.go @@ -3,6 +3,7 @@ package main import ( "log" "net/http" + "time" "github.com/aws/aws-sdk-go-v2/feature/s3/manager" _ "github.com/go-sql-driver/mysql" @@ -21,7 +22,14 @@ func main() { logger = infrastructure.NewLogger() r := handler.NewRouter(uploader, queries, logger) - err := http.ListenAndServe(":3333", r) + + const timeoutSecond = 10 + server := &http.Server{ + Addr: ":3333", + Handler: r, + ReadHeaderTimeout: timeoutSecond * time.Second, + } + err := server.ListenAndServe() if err != nil { log.Println(err) return From 7324f5e8b32a77e9df790864bc8d007229dea96a Mon Sep 17 00:00:00 2001 From: kobayashi-m42 Date: Wed, 4 Jan 2023 12:47:15 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=92?= =?UTF-8?q?=E3=83=A9=E3=83=B3=E3=83=80=E3=83=A0=E3=81=AB=E5=AE=9F=E8=A1=8C?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=81=9F=E3=82=81=E3=81=AB=20shuffle=20?= =?UTF-8?q?=E3=82=AA=E3=83=97=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92=E6=8C=87?= =?UTF-8?q?=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b75a273..9563195 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,7 @@ jobs: run: | go mod download - name: run unit tests - run: go test -v -race -coverprofile coverage.out -covermode atomic $(go list ./... | grep -v /lgtm-cat-migration/) + run: go test -shuffle=on -v -race -coverprofile coverage.out -covermode atomic $(go list ./... | grep -v /lgtm-cat-migration/) - name: upload coverage to Codecov uses: codecov/codecov-action@v2 - name: run go mod tidy diff --git a/docker-compose.yml b/docker-compose.yml index 5d81bd4..dcc002e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,7 +26,7 @@ services: target: unit-test volumes: - ./:/go/app - command: go test -v ./... + command: go test -shuffle=on -v ./... environment: TEST_DB_HOST: ${TEST_DB_HOST} TEST_DB_USER: ${TEST_DB_USER}