Skip to content

Commit

Permalink
Merge pull request #207 from evrone/deps-updates
Browse files Browse the repository at this point in the history
Global package updates
  • Loading branch information
soltanoff authored Feb 26, 2025
2 parents f0a48d7 + fb607a8 commit 4d68405
Show file tree
Hide file tree
Showing 20 changed files with 353 additions and 1,631 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ jobs:
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.23'
cache: false
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
uses: golangci/golangci-lint-action@v6
with:
args: --timeout=15m

yamllint:
name: runner / yamllint
Expand Down Expand Up @@ -46,7 +52,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v2
- uses: actions/setup-go@v4
- name: WriteGoList
run: go list -json -m all > go.list
- name: Nancy
Expand All @@ -58,9 +64,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v2
- uses: actions/setup-go@v4
with:
go-version: 1.17
go-version: 1.23

- name: Unit Tests
run: "go test \
Expand All @@ -73,7 +79,7 @@ jobs:
run: bash <(curl -s https://codecov.io/bash)

- name: Integration tests
run: "docker-compose up \
run: "docker compose up \
--build \
--abort-on-container-exit \
--exit-code-from integration"
28 changes: 4 additions & 24 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
linters-settings:
gci:
local-prefixes: github.com/evrone/go-clean-template
dupl:
threshold: 100
errorlint:
Expand Down Expand Up @@ -33,17 +31,6 @@ linters-settings:
- unnecessaryBlock
gofumpt:
extra-rules: true
gomnd:
settings:
mnd:
checks:
- argument
- case
- condition
- operation
- return
govet:
check-shadowing: true
misspell:
locale: US
nestif:
Expand All @@ -58,15 +45,13 @@ linters:
- asciicheck
- bodyclose
- cyclop
- deadcode
- depguard
- unused
- dogsled
- dupl
- durationcheck
- errcheck
- errorlint
- exhaustive
- exportloopref
- forbidigo
- funlen
- gci
Expand All @@ -78,11 +63,11 @@ linters:
- gocyclo
- godot
- godox
- goerr113
- err113
- gofmt
- gofumpt
- goimports
- gomnd
- mnd
- gomodguard
- goprintffuncname
- gosec
Expand All @@ -102,17 +87,16 @@ linters:
- rowserrcheck
- sqlclosecheck
- staticcheck
- structcheck
- stylecheck
- tparallel
- thelper
- typecheck
- unconvert
- unparam
- unused
- varcheck
- wsl
- whitespace
- copyloopvar

# disable:
# - exhaustivestruct
Expand All @@ -131,7 +115,3 @@ issues:
- path: internal/controller/http
linters:
- godot

run:
skip-dirs:
- docs
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Step 1: Modules caching
FROM golang:1.17.1-alpine3.14 as modules
FROM golang:1.23.6-alpine3.21 as modules
COPY go.mod go.sum /modules/
WORKDIR /modules
RUN go mod download

# Step 2: Builder
FROM golang:1.17.1-alpine3.14 as builder
FROM golang:1.23.6-alpine3.21 as builder
COPY --from=modules /go/pkg /go/pkg
COPY . /app
WORKDIR /app
Expand Down
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,27 @@ PATH:=$(LOCAL_BIN):$(PATH)
help: ## Display this help screen
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

compose-up: ### Run docker-compose
docker-compose up --build -d postgres rabbitmq && docker-compose logs -f
compose-up: ### Run docker compose
docker compose up --build -d postgres rabbitmq && docker compose logs -f
.PHONY: compose-up

compose-up-integration-test: ### Run docker-compose with integration test
docker-compose up --build --abort-on-container-exit --exit-code-from integration
compose-up-integration-test: ### Run docker compose with integration test
docker compose up --build --abort-on-container-exit --exit-code-from integration
.PHONY: compose-up-integration-test

compose-down: ### Down docker-compose
docker-compose down --remove-orphans
compose-down: ### Down docker compose
docker compose down --remove-orphans
.PHONY: compose-down

swag-v1: ### swag init
swag init -g internal/controller/http/v1/router.go
.PHONY: swag-v1

format:
gofumpt -l -w .
gci write . --skip-generated -s standard -s default
.PHONY: format

run: swag-v1 ### swag run
go mod tidy && go mod download && \
DISABLE_SWAGGER_HTTP_HANDLER='' GIN_MODE=debug CGO_ENABLED=0 go run -tags migrate ./cmd/app
Expand Down
74 changes: 15 additions & 59 deletions docs/docs.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag
// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs

import (
"bytes"
"encoding/json"
"strings"
"text/template"
import "github.com/swaggo/swag"

"github.com/swaggo/swag"
)

var doc = `{
const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
Expand Down Expand Up @@ -168,56 +160,20 @@ var doc = `{
}
}`

type swaggerInfo struct {
Version string
Host string
BasePath string
Schemes []string
Title string
Description string
}

// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = swaggerInfo{
Version: "1.0",
Host: "localhost:8080",
BasePath: "/v1",
Schemes: []string{},
Title: "Go Clean Template API",
Description: "Using a translation service as an example",
}

type s struct{}

func (s *s) ReadDoc() string {
sInfo := SwaggerInfo
sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1)

t, err := template.New("swagger_info").Funcs(template.FuncMap{
"marshal": func(v interface{}) string {
a, _ := json.Marshal(v)
return string(a)
},
"escape": func(v interface{}) string {
// escape tabs
str := strings.Replace(v.(string), "\t", "\\t", -1)
// replace " with \", and if that results in \\", replace that with \\\"
str = strings.Replace(str, "\"", "\\\"", -1)
return strings.Replace(str, "\\\\\"", "\\\\\\\"", -1)
},
}).Parse(doc)
if err != nil {
return doc
}

var tpl bytes.Buffer
if err := t.Execute(&tpl, sInfo); err != nil {
return doc
}

return tpl.String()
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "localhost:8080",
BasePath: "/v1",
Schemes: []string{},
Title: "Go Clean Template API",
Description: "Using a translation service as an example",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}

func init() {
swag.Register(swag.Name, &s{})
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
30 changes: 15 additions & 15 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ definitions:
example: auto
type: string
required:
- destination
- original
- source
- destination
- original
- source
type: object
v1.historyResponse:
properties:
Expand All @@ -54,18 +54,18 @@ paths:
/translation/do-translate:
post:
consumes:
- application/json
- application/json
description: Translate a text
operationId: do-translate
parameters:
- description: Set up translation
in: body
name: request
required: true
schema:
$ref: '#/definitions/v1.doTranslateRequest'
- description: Set up translation
in: body
name: request
required: true
schema:
$ref: '#/definitions/v1.doTranslateRequest'
produces:
- application/json
- application/json
responses:
"200":
description: OK
Expand All @@ -81,15 +81,15 @@ paths:
$ref: '#/definitions/v1.response'
summary: Translate
tags:
- translation
- translation
/translation/history:
get:
consumes:
- application/json
- application/json
description: Show all translation history
operationId: history
produces:
- application/json
- application/json
responses:
"200":
description: OK
Expand All @@ -101,5 +101,5 @@ paths:
$ref: '#/definitions/v1.response'
summary: Show history
tags:
- translation
- translation
swagger: "2.0"
Loading

0 comments on commit 4d68405

Please sign in to comment.