Skip to content

Commit a52283a

Browse files
authored
go version bump to v1.22 (#64)
1 parent 807b756 commit a52283a

File tree

11 files changed

+22
-17
lines changed

11 files changed

+22
-17
lines changed

.github/.testcoverage.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ profile: cover.out
44
local-prefix: "github.com/vladopajic/go-test-coverage/v2"
55
threshold:
66
total: 90
7+
exclude:
8+
paths:
9+
- main\.go$

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ jobs:
1414
- name: golangci-lint
1515
uses: golangci/golangci-lint-action@v3
1616
with:
17-
version: v1.55.2
17+
version: v1.56.0
1818
- name: go mod tidy check
1919
uses: katexochen/go-tidy-check@v2

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# GO_VERSION: go version should match version in go.mod file
2-
FROM golang:1.21 as builder
2+
FROM golang:1.22 as builder
33
WORKDIR /workspace
44

55
COPY go.mod go.mod

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GO ?= go
22
GOBIN ?= $$($(GO) env GOPATH)/bin
33
GOLANGCI_LINT ?= $(GOBIN)/golangci-lint
4-
GOLANGCI_LINT_VERSION ?= v1.55.2
4+
GOLANGCI_LINT_VERSION ?= v1.56.0
55

66
.PHONY: get-golangcilint
77
get-golangcilint:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module github.com/vladopajic/go-test-coverage/v2
22

33
// GO_VERSION: when changing go version update version in other places
4-
go 1.21
4+
go 1.22
55

66
require (
77
github.com/alexflint/go-arg v1.4.3

pkg/testcoverage/badge/generate_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import (
99
. "github.com/vladopajic/go-test-coverage/v2/pkg/testcoverage/badge"
1010
)
1111

12+
//nolint:govet,paralleltest // false-positive
1213
func Test_Generate(t *testing.T) {
1314
t.Parallel()
1415

15-
for i := 0; i <= 100; i++ {
16-
i := i
16+
for i := range 100 {
1717
c := strconv.Itoa(i) + "%"
1818
t.Run("coverage "+c, func(t *testing.T) {
1919
t.Parallel()
@@ -46,7 +46,7 @@ func Test_Color(t *testing.T) {
4646
colors := make(map[string]struct{})
4747

4848
{ // Assert that there are 5 colors for coverage [0-101]
49-
for i := 0; i <= 101; i++ {
49+
for i := range 101 {
5050
color := Color(i)
5151
colors[color] = struct{}{}
5252
}

pkg/testcoverage/badgestorer/github.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (s *githubStorer) Store(data []byte) (bool, error) {
4141
git.Repository,
4242
git.FileName,
4343
&github.RepositoryContentFileOptions{
44-
Message: github.String(fmt.Sprintf("update badge %s", git.FileName)),
44+
Message: github.String("update badge " + git.FileName),
4545
Content: data,
4646
Branch: &git.Branch,
4747
SHA: sha,

pkg/testcoverage/check_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func TestCheck(t *testing.T) {
130130
})
131131
}
132132

133-
//nolint:paralleltest // must not be parallel because it uses env
133+
// must not be parallel because it uses env
134134
func TestCheckNoParallel(t *testing.T) {
135135
if testing.Short() {
136136
return

pkg/testcoverage/config.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package testcoverage
22

33
import (
4+
"errors"
45
"fmt"
56
"os"
67
"reflect"
@@ -13,11 +14,11 @@ import (
1314
)
1415

1516
var (
16-
ErrThresholdNotInRange = fmt.Errorf("threshold must be in range [0 - 100]")
17-
ErrCoverageProfileNotSpecified = fmt.Errorf("coverage profile file not specified")
18-
ErrRegExpNotValid = fmt.Errorf("regular expression is not valid")
19-
ErrCDNOptionNotSet = fmt.Errorf("CDN options are not valid")
20-
ErrGitOptionNotSet = fmt.Errorf("git options are not valid")
17+
ErrThresholdNotInRange = errors.New("threshold must be in range [0 - 100]")
18+
ErrCoverageProfileNotSpecified = errors.New("coverage profile file not specified")
19+
ErrRegExpNotValid = errors.New("regular expression is not valid")
20+
ErrCDNOptionNotSet = errors.New("CDN options are not valid")
21+
ErrGitOptionNotSet = errors.New("git options are not valid")
2122
)
2223

2324
type Config struct {
@@ -128,7 +129,7 @@ func (c Config) validateGit() error {
128129

129130
func hasNonEmptyFields(obj any) error {
130131
v := reflect.ValueOf(obj)
131-
for i := 0; i < v.NumField(); i++ {
132+
for i := range v.NumField() {
132133
f := v.Field(i)
133134

134135
if !f.IsZero() { // filed is set

pkg/testcoverage/helpers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func randStats(localPrefix string, minc, maxc int) []coverage.Stats {
3131
for {
3232
pkg := randPackageName(localPrefix)
3333

34-
for c := rand.Int31n(10); c >= 0; c-- {
34+
for range rand.Int31n(10) {
3535
total, covered := coverageGen()
3636
stat := coverage.Stats{
3737
Name: randFileName(pkg),

pkg/testcoverage/report_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ func Test_ReportForGithubAction(t *testing.T) {
122122

123123
t.Run("package coverage - pass", func(t *testing.T) {
124124
t.Parallel()
125+
125126
buf := &bytes.Buffer{}
126127
cfg := Config{Threshold: Threshold{Package: 10}}
127128
statsNoError := randStats(prefix, 10, 100)
@@ -165,7 +166,7 @@ func Test_ReportForGithubAction(t *testing.T) {
165166
})
166167
}
167168

168-
//nolint:paralleltest // must not be parallel because it uses env
169+
// must not be parallel because it uses env
169170
func Test_SetGithubActionOutput(t *testing.T) {
170171
if testing.Short() {
171172
return

0 commit comments

Comments
 (0)