From 22ec243673811e222e8e62b8a028d0bbe8ea5757 Mon Sep 17 00:00:00 2001 From: Dusan Borovcanin Date: Tue, 26 Nov 2024 21:38:44 +0100 Subject: [PATCH] Update CI scripts Signed-off-by: Dusan Borovcanin --- .github/workflows/{go.yml => ci.yml} | 20 +++++--- .github/workflows/dependabot.yml | 8 +++ .golangci.yml | 75 ++++++++++++++++++++++++++++ go.mod | 2 +- go.sum | 4 +- senml.go | 5 +- senml_test.go | 5 +- 7 files changed, 107 insertions(+), 12 deletions(-) rename .github/workflows/{go.yml => ci.yml} (58%) create mode 100644 .golangci.yml diff --git a/.github/workflows/go.yml b/.github/workflows/ci.yml similarity index 58% rename from .github/workflows/go.yml rename to .github/workflows/ci.yml index c1675d4..1f0b5fe 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/ci.yml @@ -1,3 +1,6 @@ +# Copyright (c) Abstract Machines +# SPDX-License-Identifier: Apache-2.0 + name: Go on: [push] jobs: @@ -6,22 +9,25 @@ jobs: runs-on: ubuntu-latest steps: - - name: Set up Go 1.22.5 + - name: Set up Go 1.23.x uses: actions/setup-go@v1 with: - go-version: 1.22.5 + go-version: 1.23.x id: go + - name: Check out code into the Go module directory uses: actions/checkout@v1 + - name: Lint - run: | - export GOBIN=$HOME/go/bin - export PATH=$PATH:$(go env GOBIN) - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOBIN) v1.59.1 - golangci-lint run --no-config --disable-all --enable gosimple --enable govet --enable unused --timeout 3m + uses: golangci/golangci-lint-action@v6 + with: + version: v1.60.3 + args: --config .golangci.yml + - name: Test run: | go test -v -race -tags test -coverprofile=profile.out -covermode=atomic ./... + - name: Upload coverage uses: codecov/codecov-action@v4.0.1 with: diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index 81c28f0..2cb80e5 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -7,8 +7,16 @@ updates: directory: "./.github/workflows" schedule: interval: "weekly" + day: "monday" + timezone: "Europe/Paris" + groups: + gh-dependency: + patterns: + - "*" - package-ecosystem: "gomod" directory: "/" schedule: interval: "weekly" + day: "monday" + timezone: "Europe/Paris" diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..7c681ed --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,75 @@ +# Copyright (c) Abstract Machines +# SPDX-License-Identifier: Apache-2.0 + +run: + timeout: 3m + +issues: + max-issues-per-linter: 100 + max-same-issues: 100 + + gocritic: + enabled-checks: + - importShadow + - httpNoBody + - paramTypeCombine + - emptyStringTest + - builtinShadow + - exposedSyncMutex + disabled-checks: + - appendAssign + enabled-tags: + - diagnostic + disabled-tags: + - performance + - style + - experimental + - opinionated + misspell: + ignore-words: + - "mosquitto" + stylecheck: + checks: ["-ST1000", "-ST1003", "-ST1020", "-ST1021", "-ST1022"] + goheader: + template: |- + Copyright (c) Abstract Machines + SPDX-License-Identifier: Apache-2.0 + +linters: + disable-all: true + enable: + - gocritic + - gosimple + - errcheck + - govet + - unused + - goconst + - godot + - godox + - ineffassign + - misspell + - stylecheck + - whitespace + - gci + - gofmt + - goimports + - loggercheck + - goheader + - asasalint + - asciicheck + - bidichk + - contextcheck + - decorder + - dogsled + - errchkjson + - errname + - copyloopvar + - ginkgolinter + - gocheckcompilerdirectives + - gofumpt + - goprintffuncname + - importas + - makezero + - mirror + - nakedret + - dupword diff --git a/go.mod b/go.mod index ea38910..b3a9653 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22.5 require ( github.com/fxamacker/cbor/v2 v2.7.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.10.0 ) require ( diff --git a/go.sum b/go.sum index 3918af2..3ceb4d5 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/senml.go b/senml.go index d842090..b022fef 100644 --- a/senml.go +++ b/senml.go @@ -1,3 +1,6 @@ +// Copyright (c) Abstract Machines +// SPDX-License-Identifier: Apache-2.0 + package senml import ( @@ -47,7 +50,7 @@ var ( // Record represents one senML record. type Record struct { XMLName *bool `json:"-" xml:"senml" cbor:"-"` - Link string `json:"l,omitempty" xml:"l,attr,omitempty" cbor:"-"` + Link string `json:"l,omitempty" xml:"l,attr,omitempty" cbor:"-"` BaseName string `json:"bn,omitempty" xml:"bn,attr,omitempty" cbor:"-2,keyasint,omitempty"` BaseTime float64 `json:"bt,omitempty" xml:"bt,attr,omitempty" cbor:"-3,keyasint,omitempty"` BaseUnit string `json:"bu,omitempty" xml:"bu,attr,omitempty" cbor:"-4,keyasint,omitempty"` diff --git a/senml_test.go b/senml_test.go index 4c0a4d0..211db62 100644 --- a/senml_test.go +++ b/senml_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Abstract Machines +// SPDX-License-Identifier: Apache-2.0 + package senml_test import ( @@ -269,7 +272,7 @@ func TestNormalize(t *testing.T) { r0.BaseName = "" r0.Time = r0.BaseTime + r0.Time r0.BaseTime = 0 - *r0.Value = *r0.Value + r0.BaseValue + *r0.Value += r0.BaseValue r0.BaseValue = 0 r0.Unit = r0.BaseUnit r0.BaseUnit = ""