Skip to content

Commit 00040b7

Browse files
authored
fix: workflow (#89)
* fix: workflow * fixing mistake * fix: new linter issues
1 parent df83813 commit 00040b7

9 files changed

Lines changed: 49 additions & 45 deletions

File tree

.github/workflows/main.yaml

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,34 @@ jobs:
1515
strategy:
1616
fail-fast: true
1717
matrix:
18-
go:
19-
- "1.24"
20-
- "1.25"
21-
- "1.26"
18+
go: [oldstable, stable]
2219

2320
steps:
24-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@v6
2522

2623
- name: Install Go
27-
uses: actions/setup-go@v5
24+
uses: actions/setup-go@v6
2825
with:
2926
go-version: ${{ matrix.go }}
3027

31-
- uses: actions/cache@v4
32-
if: ${{ !env.ACT }}
33-
with:
34-
path: ~/go/pkg/mod
35-
key: ${{ runner.os }}-go-${{ matrix.golang }}-${{ hashFiles('**/go.sum') }}
36-
restore-keys: |
37-
${{ runner.os }}-go-${{ matrix.golang }}-
38-
3928
- run: make build
4029
- run: make tests
4130

4231
- name: Install goveralls
43-
if: matrix.go == '1.26'
32+
if: matrix.go == 'stable'
4433
run: go install github.com/mattn/goveralls@latest
4534

4635
- name: Coverage - Sending Report to Coveral
47-
if: matrix.go == '1.26'
36+
if: matrix.go == 'stable'
4837
env:
4938
COVERALLS_TOKEN: ${{ secrets.github_token }}
5039
run: goveralls -coverprofile=coverage.cov -service=github
5140

52-
GolangCI_Linter:
41+
GolangCILinter:
5342
runs-on: ubuntu-latest
5443
steps:
55-
- uses: actions/checkout@v4
44+
- uses: actions/checkout@v6
5645
- name: lint
57-
uses: golangci/golangci-lint-action@v6.1.1
46+
uses: golangci/golangci-lint-action@v9
5847
with:
5948
version: latest
60-
skip-cache: true
61-
args: --exclude-dirs "^(cmd|testdata)"

.github/workflows/release.yaml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,22 @@ on:
55
tags:
66
- v*
77

8-
env:
9-
GO_VERSION: "1.25"
10-
118
jobs:
12-
GoReleaser:
9+
GoReeleaser:
1310
name: release
1411
runs-on: ubuntu-latest
1512
steps:
16-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v6
1714
with:
1815
fetch-depth: 0
1916

2017
- uses: actions/setup-go@v5
2118
with:
22-
go-version: ${{ env.GO_VERSION }}
23-
24-
- uses: actions/cache@v4
25-
if: ${{ !env.ACT }}
26-
with:
27-
path: ~/go/pkg/mod
28-
key: ${{ runner.os }}-go-${{ matrix.golang }}-${{ hashFiles('**/go.sum') }}
29-
restore-keys: |
30-
${{ runner.os }}-go-${{ matrix.golang }}-
19+
go-version: stable
3120

3221
- name: GoReleaser
3322
uses: goreleaser/goreleaser-action@v6
3423
with:
35-
version: latest
3624
args: release --clean
3725
env:
3826
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}

.golangci.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: "2"
2+
3+
linters:
4+
enable:
5+
- nolintlint
6+
- testifylint
7+
settings:
8+
nolintlint:
9+
require-specific: true
10+
allow-unused: false
11+
exclusions:
12+
presets:
13+
- comments
14+
- common-false-positives
15+
- std-error-handling
16+
17+
formatters:
18+
enable:
19+
- gci
20+
- gofumpt
21+
settings:
22+
gci:
23+
sections:
24+
- standard
25+
- default
26+
- prefix(github.com/butuzov/mirror)

analyzer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import (
55
"go/ast"
66
"strings"
77

8-
"github.com/butuzov/mirror/internal/checker"
9-
108
"golang.org/x/tools/go/analysis"
119
"golang.org/x/tools/go/analysis/passes/inspect"
1210
"golang.org/x/tools/go/ast/inspector"
11+
12+
"github.com/butuzov/mirror/internal/checker"
1313
)
1414

1515
func NewAnalyzer() *analysis.Analyzer {

cmd/internal/tests/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func main() {
3636
tests = append(tests, generateTests("regexp", mirror.RegexpFunctions)...)
3737
tests = append(tests, generateTests("regexp", mirror.RegexpRegexpMethods)...)
3838

39-
GenerateTestFile(filepath.Join(testdata, "regexp.go"), "regexp", tests)
39+
_ = GenerateTestFile(filepath.Join(testdata, "regexp.go"), "regexp", tests)
4040
}
4141

4242
{ // strings

cmd/internal/tests/support.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,19 @@ func generateTests(pkgName string, list []checker.Violation) []string {
158158
pkgInTest := pkg
159159
preCondition := test.Generate.PreCondition
160160
if test.Generate.PreCondition != "" {
161-
pkgInTest = strings.Trim(strings.Split(test.Generate.PreCondition, ":=")[0], " ")
161+
pkgInTest = strings.Trim(strings.Split(
162+
test.Generate.PreCondition, ":=")[0], " ")
162163

163164
alt := pkg + "."
164165
if strings.Trim(pkg, " ") == "" {
165166
alt = ""
166167
}
167168

168-
preCondition = strings.Replace(preCondition, pkgName+".", alt, -1)
169+
preCondition = strings.ReplaceAll(preCondition, pkgName+".", alt)
169170

170171
}
171172

172-
templates.ExecuteTemplate(&buf, "case.tmpl", TestCase{
173+
_ = templates.ExecuteTemplate(&buf, "case.tmpl", TestCase{
173174
Arguments: []string{},
174175
Returns: GenReturnElements(len(test.Generate.Returns)),
175176
Package: pkgInTest,

cmd/mirror/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package main
22

33
import (
4-
"github.com/butuzov/mirror"
54
"golang.org/x/tools/go/analysis/singlechecker"
5+
6+
"github.com/butuzov/mirror"
67
)
78

89
func main() {

internal/checker/checker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (c *Checker) callConverts(ce *ast.CallExpr) bool {
109109

110110
// register violations.
111111
func (c *Checker) register(violations []Violation) {
112-
for _, v := range violations { // nolint: gocritic
112+
for _, v := range violations { //nolint: gocritic
113113
c.Violations = append(c.Violations, v)
114114
if len(v.Struct) > 0 {
115115
c.registerIdxPer(v.Package + "." + v.Struct)

internal/checker/imports_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ func TestImports(t *testing.T) {
8282

8383
// assert
8484
if len(testImports["a.go"]) != test.importsLen {
85-
t.Errorf("Imports len not match: got(%d) vs want(%d)", len(testImports["a.go"]), test.importsLen)
85+
t.Errorf("Imports len not match: got(%d) vs want(%d)",
86+
len(testImports["a.go"]), test.importsLen)
8687
}
8788

8889
for k, v := range test.hasImports {

0 commit comments

Comments
 (0)