Skip to content
Merged
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
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: ["1.22", "1.23"]
# TODO: In subsequent updates, compile for the current minor version defined in the go directive and the most recent minor version
# To avoid using unmaintained versions of Go, the Go directive should always use the minor version just before the most recent one, and the Toolchain directive should use the patch version just before the most recent one.
# Example: If last release version is 1.25.3, Go directive should be 1.24 and Toolchain directive, 1.25.2
go-version: ["1.25.1", "1.25.2"]

env:
AWS_ACCESS_KEY_ID: minioadmin
Expand Down Expand Up @@ -71,10 +74,10 @@ jobs:
- 80:80

steps:
- uses: actions/checkout@v3.5.2
- uses: actions/checkout@v5

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}

Expand Down
30 changes: 16 additions & 14 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,46 @@ on:
- master
pull_request:
permissions:
contents: read
contents: read # https://github.com/actions/setup-go#recommended-permissions
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read

env:
GOLANGCI_LINT_VERSION: v1.52.2
GOLANGCI_LINT_VERSION: v2.5.0

jobs:
analysis:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Checkout repo
uses: actions/checkout@v5
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v6
with:
go-version: 1.23
go-version-file: 'go.mod'
- name: Test
run: go test -v -coverprofile=coverage.txt -covermode=atomic `go list ./... | grep -v test/acceptance` -json > test-report.out
- name: Coverage to Codecov
uses: codecov/[email protected]

- name: Golangci increment
if: "!contains(github.ref, 'master')"
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin $GOLANGCI_LINT_VERSION
golangci-lint run -c .golangci.yml --timeout 5m --new-from-rev origin/master
if: ${{ !contains(github.ref, 'master') }}
uses: golangci/golangci-lint-action@v8
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
args: --timeout=5m --new-from-rev=origin/master
- name: Golangci main
if: contains(github.ref, 'master')
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin $GOLANGCI_LINT_VERSION
golangci-lint run -c .golangci.yml --timeout 5m
uses: golangci/golangci-lint-action@v8
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
args: --timeout=5m
- name: SonarQube Scan
if: always()
uses: sonarsource/sonarqube-scan-action@v3
uses: sonarsource/sonarqube-scan-action@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down
222 changes: 114 additions & 108 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,18 @@
linters-settings:
depguard:
list-type: blacklist
include-go-root: true
packages:
- log
packages-with-error-message:
- log: "use logrus"
dupl:
threshold: 100
funlen:
lines: 100
statements: 75
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
- wrapperFunc
- hugeParam
gocyclo:
min-complexity: 15
goimports:
local-prefixes: github.com/golangci/golangci-lint
golint:
min-confidence: 0
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: 100
maligned:
suggest-new: true
misspell:
locale: US
ignore-words:
- "marshalling"
- "unmarshalling"
- "marshalled"
- "unmarshalled"
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
# We intentionally use a limited set of linters.
# This configuration file is used with different version of golangci-lint to avoid regressions:
# the linters can change between version,
# their configuration may be not compatible or their reports can be different,
# and this can break some of our tests.
# Also, some linters are not relevant for the project (e.g. linters related to SQL).

version: "2"

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
# We intentionally use a limited set of linters.
# See the comment on top of this file.
default: none
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
Expand All @@ -83,28 +21,20 @@ linters:
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- revive
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret
- nolintlint
- rowserrcheck
- exportloopref
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace

# don't enable:
Expand All @@ -113,38 +43,114 @@ linters:
# - gocognit
# - godot
# - godox
# - gomnd
# - goerr113
# - maligned
# - mnd
# - err113
# - nestif
# - prealloc
# - testpackage
# - wsl

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- gomnd
- path: steps\.go
linters:
- funlen
- lll
# https://github.com/go-critic/go-critic/issues/926
- linters:
- gocritic
text: "unnecessaryDefer:"
settings:
depguard:
rules:
logger:
files:
- $all
allow:
- github.com/sirupsen/logrus
deny:
- pkg: log$
desc: use logrus
dupl:
threshold: 100
funlen:
lines: 100
statements: 75
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
- wrapperFunc
- hugeParam
gocyclo:
min-complexity: 15
mnd:
# don't include the "operation" and "assign"
checks:
- argument
- case
- condition
- return
govet:
enable:
- shadow
settings:
printf:
funcs:
- (github.com/golangci/golangci-lint/v2/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/v2/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/v2/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/v2/pkg/logutils.Log).Fatalf
lll:
line-length: 100
misspell:
locale: US
ignore-rules:
- "marshalling"
- "unmarshalling"
- "marshalled"
- "unmarshalled"
nolintlint:
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

exclusions:
# Excluding configuration per-path, per-linter, per-text and per-source
rules:
- path: '_test\.go'
linters:
- mnd
- path: 'steps\.go'
linters:
- funlen
- lll
# https://github.com/go-critic/go-critic/issues/926
- text: 'unnecessaryDefer:'
linters:
- gocritic
paths:
- internal/cache

formatters:
enable:
- gofmt
- goimports
settings:
goimports:
local-prefixes:
- github.com/golangci/golangci-lint
exclusions:
paths:
- internal/cache

run:
skip-dirs:
- internal/cache
output:
format: checkstyle:golangci-report.xml,colored-line-number,github-actions
formats:
checkstyle:
path: 'golangci-report.xml'
text:
path: stdout
colors: true

# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration
service:
golangci-lint-version: 1.44.x # use the fixed version to not introduce new linters unexpectedly
prepare:
- echo "here I can run custom commands, but no preparation needed for this repo"
run:
timeout: 5m
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23-alpine3.22
FROM golang:1.25-alpine3.22
RUN apk add build-base

WORKDIR /github.com/TelefonicaTC2Tech/golium
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ GO_PATH:=$(shell go env GOPATH)

LINTER_ARGS = run -c .golangci.yml --timeout 5m
GODOG_FORMAT = pretty
GOLANGCI_LINT_VERSION = v1.52.2
GOLANGCI_LINT_VERSION = v2.5.0

.PHONY: help
help: ## Show a list of available commands
Expand Down
Loading