mirror of
https://github.com/noandrea/geo2tz.git
synced 2025-12-22 10:47:07 +00:00
chore: update build setup
This commit is contained in:
282
.github/.golangci.yaml
vendored
Normal file
282
.github/.golangci.yaml
vendored
Normal file
@@ -0,0 +1,282 @@
|
||||
run:
|
||||
# Timeout for analysis, e.g. 30s, 5m.
|
||||
# Default: 1m
|
||||
timeout: 3m
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
## enabled by default
|
||||
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
|
||||
- gosimple # Linter for Go source code that specializes in simplifying a code
|
||||
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
|
||||
- ineffassign # Detects when assignments to existing variables are not used
|
||||
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
|
||||
# - structcheck # Finds unused struct fields TODO disabled for lack of support of generics
|
||||
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
|
||||
- unused # Checks Go code for unused constants, variables, functions and types
|
||||
## disabled by default
|
||||
- asasalint # Check for pass []any as any in variadic func(...any)
|
||||
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
|
||||
- bidichk # Checks for dangerous unicode character sequences
|
||||
- bodyclose # checks whether HTTP response body is closed successfully
|
||||
# - contextcheck # check the function whether use a non-inherited context TODO disabled for lack of support of generics
|
||||
- cyclop # checks function and package cyclomatic complexity
|
||||
- dupl # Tool for code clone detection
|
||||
- durationcheck # check for two durations multiplied together
|
||||
- errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error.
|
||||
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
|
||||
- execinquery # execinquery is a linter about query string checker in Query function which reads your Go src files and warning it finds
|
||||
- exhaustive # check exhaustiveness of enum switch statements
|
||||
- exportloopref # checks for pointers to enclosing loop variables
|
||||
# - forbidigo # Forbids identifiers
|
||||
- funlen # Tool for detection of long functions
|
||||
# - gochecknoglobals # check that no global variables exist
|
||||
- gochecknoinits # Checks that no init functions are present in Go code
|
||||
- gocognit # Computes and checks the cognitive complexity of functions
|
||||
- goconst # Finds repeated strings that could be replaced by a constant
|
||||
- gocritic # Provides diagnostics that check for bugs, performance and style issues.
|
||||
- gocyclo # Computes and checks the cyclomatic complexity of functions
|
||||
- godot # Check if comments end in a period
|
||||
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt.
|
||||
- gomnd # An analyzer to detect magic numbers.
|
||||
- gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
|
||||
- gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.
|
||||
- goprintffuncname # Checks that printf-like functions are named with f at the end
|
||||
- gosec # Inspects source code for security problems
|
||||
- lll # Reports long lines
|
||||
- makezero # Finds slice declarations with non-zero initial length
|
||||
# - nakedret # Finds naked returns in functions greater than a specified function length
|
||||
- nestif # Reports deeply nested if statements
|
||||
- nilerr # Finds the code that returns nil even if it checks that the error is not nil.
|
||||
- nilnil # Checks that there is no simultaneous return of nil error and an invalid value.
|
||||
- noctx # noctx finds sending http request without context.Context
|
||||
- nolintlint # Reports ill-formed or insufficient nolint directives
|
||||
# - nonamedreturns # Reports all named returns
|
||||
- nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL.
|
||||
- predeclared # find code that shadows one of Go's predeclared identifiers
|
||||
- promlinter # Check Prometheus metrics naming via promlint
|
||||
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
|
||||
# - rowserrcheck # checks whether Err of rows is checked successfully TODO disabled for lack of support of generics
|
||||
# - sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed. TODO disabled for lack of support of generics
|
||||
- stylecheck # Stylecheck is a replacement for golint
|
||||
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
|
||||
- testpackage # linter that makes you use a separate _test package
|
||||
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
|
||||
- unconvert # Remove unnecessary type conversions
|
||||
- unparam # Reports unused function parameters
|
||||
- usestdlibvars # detect the possibility to use variables/constants from the Go standard library
|
||||
# - wastedassign # wastedassign finds wasted assignment statements. TODO disabled for lack of support of generics
|
||||
- whitespace # Tool for detection of leading and trailing whitespace
|
||||
## you may want to enable
|
||||
#- decorder # check declaration order and count of types, constants, variables and functions
|
||||
#- exhaustruct # Checks if all structure fields are initialized
|
||||
#- goheader # Checks is file header matches to pattern
|
||||
#- ireturn # Accept Interfaces, Return Concrete Types
|
||||
#- prealloc # [premature optimization, but can be used in some cases] Finds slice declarations that could potentially be preallocated
|
||||
#- varnamelen # [great idea, but too many false positives] checks that the length of a variable's name matches its scope
|
||||
#- wrapcheck # Checks that errors returned from external packages are wrapped
|
||||
## disabled
|
||||
#- containedctx # containedctx is a linter that detects struct contained context.Context field
|
||||
#- depguard # [replaced by gomodguard] Go linter that checks if package imports are in a list of acceptable packages
|
||||
#- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
|
||||
#- errchkjson # [don't see profit + I'm against of omitting errors like in the first example https://github.com/breml/errchkjson] Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted.
|
||||
#- forcetypeassert # [replaced by errcheck] finds forced type assertions
|
||||
#- gci # Gci controls golang package import order and makes it always deterministic.
|
||||
#- godox # Tool for detection of FIXME, TODO and other comment keywords
|
||||
#- goerr113 # [too strict] Golang linter to check the errors handling expressions
|
||||
#- gofmt # [replaced by goimports] Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
|
||||
#- gofumpt # [replaced by goimports, gofumports is not available yet] Gofumpt checks whether code was gofumpt-ed.
|
||||
#- grouper # An analyzer to analyze expression groups.
|
||||
#- importas # Enforces consistent import aliases
|
||||
#- maintidx # maintidx measures the maintainability index of each function.
|
||||
#- misspell # [useless] Finds commonly misspelled English words in comments
|
||||
#- nlreturn # [too strict and mostly code is not more readable] nlreturn checks for a new line before return and branch statements to increase code clarity
|
||||
#- nosnakecase # Detects snake case of variable naming and function name. # TODO: maybe enable after https://github.com/sivchari/nosnakecase/issues/14
|
||||
#- paralleltest # [too many false positives] paralleltest detects missing usage of t.Parallel() method in your Go test
|
||||
#- tagliatelle # Checks the struct tags.
|
||||
#- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers
|
||||
#- wsl # [too strict and mostly code is not more readable] Whitespace Linter - Forces you to use empty lines!
|
||||
## deprecated
|
||||
#- exhaustivestruct # [deprecated, replaced by exhaustruct] Checks if all struct's fields are initialized
|
||||
#- golint # [deprecated, replaced by revive] Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes
|
||||
#- ifshort # [deprecated, by the owner] Checks that your code uses short syntax for if-statements whenever possible
|
||||
#- interfacer # [deprecated] Linter that suggests narrower interface types
|
||||
#- maligned # [deprecated, replaced by govet fieldalignment] Tool to detect Go structs that would take less memory if their fields were sorted
|
||||
#- scopelint # [deprecated, replaced by exportloopref] Scopelint checks for unpinned variables in go programs
|
||||
|
||||
# This file contains only configs which differ from defaults.
|
||||
# All possible options can be found here https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml
|
||||
linters-settings:
|
||||
cyclop:
|
||||
# The maximal code complexity to report.
|
||||
# Default: 10
|
||||
max-complexity: 30
|
||||
# The maximal average package complexity.
|
||||
# If it's higher than 0.0 (float) the check is enabled
|
||||
# Default: 0.0
|
||||
package-average: 10.0
|
||||
|
||||
errcheck:
|
||||
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
|
||||
# Such cases aren't reported by default.
|
||||
# Default: false
|
||||
check-type-assertions: true
|
||||
|
||||
funlen:
|
||||
# Checks the number of lines in a function.
|
||||
# If lower than 0, disable the check.
|
||||
# Default: 60
|
||||
lines: 100
|
||||
# Checks the number of statements in a function.
|
||||
# If lower than 0, disable the check.
|
||||
# Default: 40
|
||||
statements: 50
|
||||
|
||||
gocognit:
|
||||
# Minimal code complexity to report
|
||||
# Default: 30 (but we recommend 10-20)
|
||||
min-complexity: 20
|
||||
|
||||
gocritic:
|
||||
# Settings passed to gocritic.
|
||||
# The settings key is the name of a supported gocritic checker.
|
||||
# The list of supported checkers can be find in https://go-critic.github.io/overview.
|
||||
settings:
|
||||
captLocal:
|
||||
# Whether to restrict checker to params only.
|
||||
# Default: true
|
||||
paramsOnly: false
|
||||
underef:
|
||||
# Whether to skip (*x).method() calls where x is a pointer receiver.
|
||||
# Default: true
|
||||
skipRecvDeref: false
|
||||
|
||||
gomnd:
|
||||
# List of function patterns to exclude from analysis.
|
||||
# Values always ignored: `time.Date`
|
||||
# Default: []
|
||||
ignored-functions:
|
||||
- os.Chmod
|
||||
- os.Mkdir
|
||||
- os.MkdirAll
|
||||
- os.OpenFile
|
||||
- os.WriteFile
|
||||
- prometheus.ExponentialBuckets
|
||||
- prometheus.ExponentialBucketsRange
|
||||
- prometheus.LinearBuckets
|
||||
- strconv.FormatFloat
|
||||
- strconv.FormatInt
|
||||
- strconv.FormatUint
|
||||
- strconv.ParseFloat
|
||||
- strconv.ParseInt
|
||||
- strconv.ParseUint
|
||||
|
||||
gomoddirectives:
|
||||
# Allow local `replace` directives.
|
||||
# Default: false
|
||||
replace-local: false
|
||||
# List of allowed `replace` directives.
|
||||
# Default: []
|
||||
replace-allow-list:
|
||||
- github.com/gogo/protobuf
|
||||
- github.com/keybase/go-keychain
|
||||
- google.golang.org/grpc
|
||||
# Allow to not explain why the version has been retracted in the `retract` directives.
|
||||
# Default: false
|
||||
retract-allow-no-explanation: false
|
||||
# Forbid the use of the `exclude` directives.
|
||||
# Default: false
|
||||
exclude-forbidden: false
|
||||
|
||||
gomodguard:
|
||||
blocked:
|
||||
# List of blocked modules.
|
||||
# Default: []
|
||||
modules:
|
||||
- github.com/golang/protobuf:
|
||||
recommendations:
|
||||
- google.golang.org/protobuf
|
||||
reason: "see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules"
|
||||
- github.com/satori/go.uuid:
|
||||
recommendations:
|
||||
- github.com/google/uuid
|
||||
reason: "satori's package is not maintained"
|
||||
- github.com/gofrs/uuid:
|
||||
recommendations:
|
||||
- github.com/google/uuid
|
||||
reason: "see recommendation from dev-infra team: https://confluence.gtforge.com/x/gQI6Aw"
|
||||
|
||||
govet:
|
||||
# Enable all analyzers.
|
||||
# Default: false
|
||||
enable-all: true
|
||||
# Disable analyzers by name.
|
||||
# Run `go tool vet help` to see all analyzers.
|
||||
# Default: []
|
||||
disable:
|
||||
- fieldalignment # too strict
|
||||
# Settings per analyzer.
|
||||
settings:
|
||||
shadow:
|
||||
# Whether to be strict about shadowing; can be noisy.
|
||||
# Default: false
|
||||
strict: true
|
||||
|
||||
nakedret:
|
||||
# Make an issue if func has more lines of code than this setting, and it has naked returns.
|
||||
# Default: 30
|
||||
max-func-lines: 0
|
||||
|
||||
nolintlint:
|
||||
# Exclude following linters from requiring an explanation.
|
||||
# Default: []
|
||||
allow-no-explanation: [funlen, gocognit, lll]
|
||||
# Enable to require an explanation of nonzero length after each nolint directive.
|
||||
# Default: false
|
||||
require-explanation: true
|
||||
# Enable to require nolint directives to mention the specific linter being suppressed.
|
||||
# Default: false
|
||||
require-specific: true
|
||||
|
||||
rowserrcheck:
|
||||
# database/sql is always checked
|
||||
# Default: []
|
||||
packages:
|
||||
- github.com/jmoiron/sqlx
|
||||
|
||||
tenv:
|
||||
# The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.
|
||||
# Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked.
|
||||
# Default: false
|
||||
all: true
|
||||
|
||||
varcheck:
|
||||
# Check usage of exported fields and variables.
|
||||
# Default: false
|
||||
exported-fields: false # default false # TODO: enable after fixing false positives
|
||||
|
||||
issues:
|
||||
# Maximum count of issues with the same text.
|
||||
# Set to 0 to disable.
|
||||
# Default: 3
|
||||
max-same-issues: 50
|
||||
|
||||
exclude-rules:
|
||||
- source: "^//\\s*go:generate\\s"
|
||||
linters: [lll]
|
||||
- source: "(noinspection|TODO)"
|
||||
linters: [godot]
|
||||
- source: "//noinspection"
|
||||
linters: [gocritic]
|
||||
- source: "^\\s+if _, ok := err\\.\\([^.]+\\.InternalError\\); ok {"
|
||||
linters: [errorlint]
|
||||
- path: "_test\\.go"
|
||||
linters:
|
||||
- bodyclose
|
||||
- dupl
|
||||
- funlen
|
||||
- goconst
|
||||
- gosec
|
||||
- noctx
|
||||
- wrapcheck
|
||||
91
.github/.goreleaser.yaml
vendored
Normal file
91
.github/.goreleaser.yaml
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
project_name: geo2tz
|
||||
before:
|
||||
hooks:
|
||||
- go mod tidy
|
||||
signs:
|
||||
- artifacts: checksum
|
||||
args:
|
||||
[
|
||||
"--batch",
|
||||
"-u",
|
||||
"{{ .Env.GPG_FINGERPRINT }}",
|
||||
"--output",
|
||||
"${signature}",
|
||||
"--detach-sign",
|
||||
"${artifact}",
|
||||
]
|
||||
builds:
|
||||
- id: "geo2tz"
|
||||
main: ./main.go
|
||||
binary: geo2tz
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- linux
|
||||
- darwin
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
changelog:
|
||||
skip: false
|
||||
use: git
|
||||
groups:
|
||||
- title: Features
|
||||
regexp: "^.*feat[(\\w)]*:+.*$"
|
||||
order: 0
|
||||
- title: "Bug fixes"
|
||||
regexp: "^.*fix[(\\w)]*:+.*$"
|
||||
order: 1
|
||||
- title: Others
|
||||
order: 999
|
||||
filters:
|
||||
exclude:
|
||||
- "^docs:"
|
||||
- "^chore:"
|
||||
dockers:
|
||||
- use: buildx
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
image_templates:
|
||||
- "ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Version }}-amd64"
|
||||
build_flag_templates:
|
||||
- "--pull"
|
||||
- "--platform=linux/amd64"
|
||||
- "--label=org.opencontainers.image.created={{.Date}}"
|
||||
- "--label=org.opencontainers.image.title={{.ProjectName}}"
|
||||
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
|
||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||
- use: buildx
|
||||
goos: linux
|
||||
goarch: arm64
|
||||
image_templates:
|
||||
- "ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Version }}-arm64v8"
|
||||
build_flag_templates:
|
||||
- "--pull"
|
||||
- "--platform=linux/arm64"
|
||||
- "--label=org.opencontainers.image.created={{.Date}}"
|
||||
- "--label=org.opencontainers.image.title={{.ProjectName}}"
|
||||
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
|
||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||
docker_manifests:
|
||||
- name_template: ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Version }}
|
||||
image_templates:
|
||||
- ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Version }}-amd64
|
||||
- ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Version }}-arm64v8
|
||||
nfpms:
|
||||
- id: packages
|
||||
# Formats to be generated.
|
||||
formats:
|
||||
- deb
|
||||
- rpm
|
||||
- archlinux # Since: v1.13
|
||||
# contents:
|
||||
# # for updstart
|
||||
# - src: path/to/local/bar.conf
|
||||
# dst: /etc/bar.conf
|
||||
# type: "config|noreplace"
|
||||
# # for logging
|
||||
# - dst: /some/dir
|
||||
# type: dir
|
||||
# file_info:
|
||||
# mode: 0700
|
||||
@@ -1,54 +0,0 @@
|
||||
name: Create and publish a Docker image
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- ".gitignore"
|
||||
- "README.md"
|
||||
- "LICENSE"
|
||||
- "docs"
|
||||
- "Makefile"
|
||||
branches:
|
||||
- "main"
|
||||
tags:
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
build-and-push-image:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=edge,branch=$repo.default_branch
|
||||
type=semver,pattern={{version}}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
file: ./Dockerfile
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
78
.github/workflows/release.yml
vendored
Normal file
78
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
name: Create and publish a Docker image
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- ".gitignore"
|
||||
- "README.md"
|
||||
- "LICENSE"
|
||||
- "docs"
|
||||
- "Makefile"
|
||||
branches:
|
||||
- "main"
|
||||
tags:
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
packages: write
|
||||
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- id: release-please
|
||||
name: Release Please
|
||||
uses: google-github-actions/release-please-action@v3
|
||||
with:
|
||||
release-type: go
|
||||
package-name: authex
|
||||
changelog-types: >-
|
||||
[
|
||||
{"type":"feat","section":"Features","hidden":false},
|
||||
{"type":"fix","section":"Bug Fixes","hidden":false},
|
||||
{"type":"chore","section":"Miscellaneous","hidden":true}
|
||||
]
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
if: steps.release-please.outputs.release_created
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
if: steps.release-please.outputs.release_created
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
if: steps.release-please.outputs.release_created
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
if: steps.release-please.outputs.release_created
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@v2
|
||||
if: steps.release-please.outputs.release_created
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
name: Import GPG key
|
||||
id: import_gpg
|
||||
uses: crazy-max/ghaction-import-gpg@v4
|
||||
with:
|
||||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||
passphrase: ${{ secrets.PASSPHRASE }}
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v4
|
||||
if: steps.release-please.outputs.release_created
|
||||
with:
|
||||
args: release --clean --config .github/.goreleaser.yaml
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_ORG : ${{ github.repository_owner }}
|
||||
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
||||
@@ -1,79 +0,0 @@
|
||||
run:
|
||||
skip-dirs:
|
||||
- contrib
|
||||
- proto
|
||||
|
||||
tests: false
|
||||
|
||||
timeout: 5m
|
||||
|
||||
skip-files:
|
||||
- ".*\\.pb\\.go$"
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
presets:
|
||||
- bugs
|
||||
- unused
|
||||
- import
|
||||
# - error to be enabled next
|
||||
enable:
|
||||
- misspell
|
||||
- revive
|
||||
|
||||
linters-settings:
|
||||
unused:
|
||||
go: "1.18"
|
||||
dupl:
|
||||
threshold: 100
|
||||
funlen:
|
||||
lines: 100
|
||||
statements: 50
|
||||
gci:
|
||||
local-prefixes: github.com/noandrea/geo2tz
|
||||
goimports:
|
||||
local-prefixes: github.com/noandrea/geo2tz
|
||||
goconst:
|
||||
min-len: 2
|
||||
min-occurrences: 2
|
||||
gocritic:
|
||||
enabled-tags:
|
||||
- diagnostic
|
||||
- experimental
|
||||
- opinionated
|
||||
- performance
|
||||
- style
|
||||
disabled-checks:
|
||||
- dupImport # https://github.com/go-critic/go-critic/issues/845
|
||||
- ifElseChain
|
||||
- octalLiteral
|
||||
- whyNoLint
|
||||
- wrapperFunc
|
||||
gocyclo:
|
||||
min-complexity: 15
|
||||
|
||||
gomnd:
|
||||
settings:
|
||||
mnd:
|
||||
# don't include the "operation" and "assign"
|
||||
checks: argument,case,condition,return
|
||||
govet:
|
||||
check-shadowing: true
|
||||
settings:
|
||||
printf:
|
||||
funcs:
|
||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
|
||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
|
||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
|
||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
|
||||
lll:
|
||||
line-length: 140
|
||||
maligned:
|
||||
suggest-new: true
|
||||
misspell:
|
||||
locale: US
|
||||
nolintlint:
|
||||
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
|
||||
allow-unused: false # report any unused nolint directives
|
||||
require-explanation: false # don't require an explanation for nolint directives
|
||||
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
|
||||
@@ -1,12 +1,14 @@
|
||||
repos:
|
||||
- repo: https://github.com/golangci/golangci-lint
|
||||
rev: v1.46.2
|
||||
hooks:
|
||||
- id: golangci-lint
|
||||
# commit msg check
|
||||
- repo: https://github.com/compilerla/conventional-pre-commit
|
||||
rev: v1.0.0
|
||||
hooks:
|
||||
- id: conventional-pre-commit
|
||||
stages: [commit-msg]
|
||||
args: [] # optional: list of Conventional Commits types to allow
|
||||
[]
|
||||
# - repo: https://github.com/golangci/golangci-lint
|
||||
# rev: v1.46.2
|
||||
# hooks:
|
||||
# - id: golangci-lint
|
||||
# args: ["--config", ".github/.golangci.yaml"]
|
||||
# # commit msg check
|
||||
# - repo: https:q//github.com/compilerla/conventional-pre-commit
|
||||
# rev: v2.3.0
|
||||
# hooks:
|
||||
# - id: conventional-pre-commit
|
||||
# stages: [commit-msg]
|
||||
# args: [] # optional: list of Conventional Commits types to allow
|
||||
|
||||
84
Makefile
84
Makefile
@@ -1,19 +1,5 @@
|
||||
GOFILES = $(shell find . -name '*.go' -not -path './vendor/*')
|
||||
GOPACKAGES = $(shell go list ./... | grep -v /vendor/)
|
||||
APP_VERSION = $(shell git describe --tags --always)
|
||||
APP=geo2tz
|
||||
# build output folder
|
||||
OUTPUTFOLDER = dist
|
||||
RELEASEFOLDER = release
|
||||
# docker image
|
||||
DOCKER_REGISTRY = docker.pkg.github.com/noandrea/geo2tz
|
||||
DOCKER_IMAGE = geo2tz
|
||||
# build paramters
|
||||
OS = linux
|
||||
ARCH = amd64
|
||||
# K8S
|
||||
K8S_NAMESPACE = geo
|
||||
K8S_DEPLOYMENT = geo2tz
|
||||
|
||||
.PHONY: list
|
||||
list:
|
||||
@@ -27,10 +13,8 @@ workdir:
|
||||
build: build-dist
|
||||
|
||||
build-dist: $(GOFILES)
|
||||
@echo build binary to $(OUTPUTFOLDER)
|
||||
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags '-s -w -extldflags "-static" -X main.Version=$(APP_VERSION)' -o $(OUTPUTFOLDER)/$(APP) .
|
||||
@echo copy resources
|
||||
cp -r README.md LICENSE $(OUTPUTFOLDER)
|
||||
@echo build binary
|
||||
goreleaser build --single-target --config .github/.goreleaser.yaml --snapshot --clean
|
||||
@echo done
|
||||
|
||||
|
||||
@@ -53,36 +37,14 @@ bench: bench-all
|
||||
bench-all:
|
||||
@go test -bench -v $(GOPACKAGES)
|
||||
|
||||
lint: lint-all
|
||||
go.sum: go.mod
|
||||
@echo "--> Ensure dependencies have not been modified"
|
||||
GO111MODULE=on go mod verify
|
||||
|
||||
lint-all:
|
||||
@echo running linters
|
||||
staticcheck $(GOPACKAGES)
|
||||
golint -set_exit_status $(GOPACKAGES)
|
||||
@echo done
|
||||
|
||||
clean:
|
||||
@echo remove $(OUTPUTFOLDER) folder
|
||||
rm -rf $(OUTPUTFOLDER)
|
||||
@echo remove $(RELEASEFOLDER) folder
|
||||
rm -rf $(RELEASEFOLDER)
|
||||
@echo done
|
||||
|
||||
docker: docker-build
|
||||
|
||||
docker-build: _check_version
|
||||
@echo copy resources
|
||||
docker build --build-arg DOCKER_TAG='$(APP_VERSION)' -t $(DOCKER_IMAGE) .
|
||||
@echo done
|
||||
|
||||
docker-push: _check_version
|
||||
@echo push image
|
||||
docker tag $(DOCKER_IMAGE):latest $(DOCKER_REGISTRY)/$(DOCKER_IMAGE):$(APP_VERSION)
|
||||
docker push $(DOCKER_REGISTRY)/$(DOCKER_IMAGE):$(APP_VERSION)
|
||||
@echo done
|
||||
|
||||
docker-run:
|
||||
docker run -p 2004:2004 $(DOCKER_IMAGE):latest
|
||||
lint:
|
||||
@echo "--> Running linter"
|
||||
@golangci-lint run --config .github/.golangci.yaml
|
||||
@go mod verify
|
||||
|
||||
debug-start:
|
||||
@go run main.go start
|
||||
@@ -97,28 +59,10 @@ k8s-rollback:
|
||||
kubectl -n $(K8S_NAMESPACE) rollout undo deployment/$(K8S_DEPLOYMENT)
|
||||
@echo done
|
||||
|
||||
changelog:
|
||||
git-chglog --sort semver --output CHANGELOG.md
|
||||
|
||||
|
||||
release-prepare: _check_version
|
||||
@echo making release $(APP_VERSION)
|
||||
git tag $(APP_VERSION)
|
||||
git-chglog --sort semver --output CHANGELOG.md
|
||||
git tag $(APP_VERSION) --delete
|
||||
git add CHANGELOG.md && git commit -m "chore: update changelog for $(APP_VERSION)"
|
||||
@echo release complete
|
||||
|
||||
git-tag: _check_version
|
||||
ifneq ($(shell git rev-parse --abbrev-ref HEAD),main)
|
||||
$(error you are not on the main branch. aborting)
|
||||
endif
|
||||
git tag -s -a "$(APP_VERSION)" -m "Changelog: https://github.com/noandrea/geo2tz/blob/main/CHANGELOG.md"
|
||||
|
||||
gh-publish-release: _check_version clean build
|
||||
@echo publish release
|
||||
mkdir -p $(RELEASEFOLDER)
|
||||
zip -rmT $(RELEASEFOLDER)/$(APP)-$(APP_VERSION).zip $(OUTPUTFOLDER)/
|
||||
sha256sum $(RELEASEFOLDER)/$(APP)-$(APP_VERSION).zip | tee $(RELEASEFOLDER)/$(APP)-$(APP_VERSION).zip.checksum
|
||||
gh release create $(APP_VERSION) $(RELEASEFOLDER)/* -t $(APP_VERSION) -F CHANGELOG.md
|
||||
update-tzdata:
|
||||
@echo "--> Updating timzaone data"
|
||||
@echo build binary
|
||||
goreleaser build --single-target --config .github/.goreleaser.yaml --snapshot --clean -o dist/geo2tz
|
||||
./scripts/update-tzdata.sh
|
||||
@echo done
|
||||
|
||||
Reference in New Issue
Block a user