Skip to content

Commit 4d933e6

Browse files
authored
Update GitHub Actions workflows (#170)
* Update GitHub Actions workflows Versions have been broadly updated but releases are still being generated with the oldest supported Go version, not the latest. * Migrate golangci-lint config to v2 * Address golangci-lint feedback
1 parent 2187838 commit 4d933e6

File tree

9 files changed

+65
-52
lines changed

9 files changed

+65
-52
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@ permissions:
88

99
jobs:
1010
goreleaser:
11-
# we need ubuntu 20.04 because golines needs
12-
# to run on hosts with older glibc versions
13-
runs-on: ubuntu-20.04
11+
# using Ubuntu 22.04 should help maximize the
12+
# glibc compatibility since across the board
13+
# without using a too-old-to-support version
14+
# of Ubuntu.
15+
runs-on: ubuntu-22.04
1416
steps:
15-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v5
1618
with:
1719
fetch-depth: 0
1820
- uses: actions/setup-go@v5
1921
with:
20-
go-version: "1.21"
22+
go-version: "1.24"
2123
cache: false
2224
- name: build golines
23-
uses: goreleaser/goreleaser-action@v5
25+
uses: goreleaser/goreleaser-action@v6
2426
with:
2527
distribution: goreleaser
2628
version: latest

.github/workflows/lint.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@ permissions:
88
jobs:
99
golangci:
1010
name: golines lint
11-
# we need ubuntu 20.04 because golines needs
12-
# to run on hosts with older glibc versions
13-
runs-on: ubuntu-20.04
11+
runs-on: ubuntu-latest
1412
steps:
15-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v5
1614
- uses: actions/setup-go@v5
1715
with:
18-
go-version: "1.21"
16+
go-version: "1.24"
1917
cache: false
2018
- name: run golangci-lint
21-
uses: golangci/golangci-lint-action@v3
19+
uses: golangci/golangci-lint-action@v8
2220
with:
2321
version: latest
2422
install-mode: binary

.github/workflows/release.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ permissions:
1010

1111
jobs:
1212
goreleaser:
13-
# we need ubuntu 20.04 because golines needs
14-
# to run on hosts with older glibc versions
15-
runs-on: ubuntu-20.04
13+
# using Ubuntu 22.04 should help maximize the
14+
# glibc compatibility since across the board
15+
# without using a too-old-to-support version
16+
# of Ubuntu.
17+
runs-on: ubuntu-22.04
1618
steps:
17-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@v5
1820
with:
1921
fetch-depth: 0
2022
- uses: actions/setup-go@v5
2123
with:
22-
go-version: "1.21"
24+
go-version: "1.24"
2325
cache: false
2426
- name: release golines
2527
uses: goreleaser/goreleaser-action@v5

.github/workflows/test.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@ jobs:
88
fail-fast: false
99
matrix:
1010
os:
11-
# we need ubuntu 20.04 because golines needs
12-
# to run on hosts with older glibc versions
13-
- ubuntu-20.04
11+
- ubuntu-latest
1412
- macos-latest
1513
- windows-latest
1614
go:
17-
- "1.21"
18-
- "1.20"
15+
- "1.23"
16+
- "1.24"
17+
- "1.25"
1918
runs-on: ${{ matrix.os }}
2019
name: golines test (using go ${{ matrix.go }} on ${{ matrix.os }})
2120
steps:
22-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@v5
2322
- name: test golines
2423
uses: actions/setup-go@v5
2524
with:

.golangci.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1+
version: "2"
12
linters:
23
disable:
34
- errcheck
4-
5-
run:
6-
timeout: 5m
5+
exclusions:
6+
generated: lax
7+
presets:
8+
- comments
9+
- common-false-positives
10+
- legacy
11+
- std-error-handling
12+
paths:
13+
- third_party$
14+
- builtin$
15+
- examples$
16+
formatters:
17+
exclusions:
18+
generated: lax
19+
paths:
20+
- third_party$
21+
- builtin$
22+
- examples$

graph.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,7 @@ func WalkGraph(root *GraphNode) (string, error) {
5555
var currSeq int
5656

5757
// First, loop through the graph nodes to assign proper ids
58-
for {
59-
if len(toProcess) == 0 {
60-
break
61-
}
62-
58+
for len(toProcess) != 0 {
6359
currNode := toProcess[0]
6460

6561
if currNode.level > currLevel {

main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func processFile(shortener *Shortener, path string) ([]byte, []byte, error) {
212212
return nil, nil, nil
213213
}
214214

215-
log.Debugf("Processing file %s", path)
215+
log.Debugf("processing file %s", path)
216216

217217
contents, err := os.ReadFile(path)
218218
if err != nil {
@@ -239,7 +239,7 @@ func handleOutput(path string, contents []byte, result []byte) error {
239239
return nil
240240
} else if *writeOutput {
241241
if path == "" {
242-
return errors.New("No path to write out to")
242+
return errors.New("no path to write out to")
243243
}
244244

245245
info, err := os.Stat(path)
@@ -248,11 +248,11 @@ func handleOutput(path string, contents []byte, result []byte) error {
248248
}
249249

250250
if bytes.Equal(contents, result) {
251-
log.Debugf("Contents unchanged, skipping write")
251+
log.Debugf("contents unchanged, skipping write")
252252
return nil
253253
}
254254

255-
log.Debugf("Contents changed, writing output to %s", path)
255+
log.Debugf("contents changed, writing output to %s", path)
256256
return os.WriteFile(path, result, info.Mode())
257257
}
258258

shortener.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ func (s *Shortener) Shorten(contents []byte) ([]byte, error) {
101101
// Do initial, non-line-length-aware formatting
102102
contents, err = s.formatSrc(contents)
103103
if err != nil {
104-
return nil, fmt.Errorf("Error formatting source: %+v", err)
104+
return nil, fmt.Errorf("error formatting source: %+v", err)
105105
}
106106

107107
for {
108-
log.Debugf("Starting round %d", round)
108+
log.Debugf("starting round %d", round)
109109

110110
// Annotate all long lines
111111
lines := strings.Split(string(contents), "\n")
@@ -125,7 +125,7 @@ func (s *Shortener) Shorten(contents []byte) ([]byte, error) {
125125
}
126126

127127
if stop {
128-
log.Debug("Nothing more to shorten or reformat, stopping")
128+
log.Debug("nothing more to shorten or reformat, stopping")
129129
break
130130
}
131131

@@ -144,7 +144,7 @@ func (s *Shortener) Shorten(contents []byte) ([]byte, error) {
144144
}
145145
defer dotFile.Close()
146146

147-
log.Debugf("Writing dot file output to %s", s.config.DotFile)
147+
log.Debugf("writing dot file output to %s", s.config.DotFile)
148148
err = CreateDot(result, dotFile)
149149
if err != nil {
150150
return nil, err
@@ -160,14 +160,14 @@ func (s *Shortener) Shorten(contents []byte) ([]byte, error) {
160160
output := bytes.NewBuffer([]byte{})
161161
err = decorator.Fprint(output, result)
162162
if err != nil {
163-
return nil, fmt.Errorf("Error parsing source: %+v", err)
163+
return nil, fmt.Errorf("error parsing source: %+v", err)
164164
}
165165
contents = output.Bytes()
166166

167167
round++
168168

169169
if round > maxRounds {
170-
log.Debugf("Hit max rounds, stopping")
170+
log.Debugf("hit max rounds, stopping")
171171
break
172172
}
173173
}
@@ -182,7 +182,7 @@ func (s *Shortener) Shorten(contents []byte) ([]byte, error) {
182182
// Do final round of non-line-length-aware formatting after we've fixed up the comments
183183
contents, err = s.formatSrc(contents)
184184
if err != nil {
185-
return nil, fmt.Errorf("Error formatting source: %+v", err)
185+
return nil, fmt.Errorf("error formatting source: %+v", err)
186186
}
187187

188188
return contents, nil
@@ -357,20 +357,20 @@ func (s *Shortener) isGoDirective(line string) bool {
357357
func (s *Shortener) formatNode(node dst.Node) {
358358
switch n := node.(type) {
359359
case dst.Decl:
360-
log.Debugf("Processing declaration: %+v", n)
360+
log.Debugf("processing declaration: %+v", n)
361361
s.formatDecl(n)
362362
case dst.Expr:
363-
log.Debugf("Processing expression: %+v", n)
363+
log.Debugf("processing expression: %+v", n)
364364
s.formatExpr(n, false, false)
365365
case dst.Stmt:
366-
log.Debugf("Processing statement: %+v", n)
366+
log.Debugf("processing statement: %+v", n)
367367
s.formatStmt(n)
368368
case dst.Spec:
369-
log.Debugf("Processing spec: %+v", n)
369+
log.Debugf("processing spec: %+v", n)
370370
s.formatSpec(n, false)
371371
default:
372372
log.Debugf(
373-
"Got a node type that can't be shortened: %+v",
373+
"got a node type that can't be shortened: %+v",
374374
reflect.TypeOf(n),
375375
)
376376
}
@@ -393,7 +393,7 @@ func (s *Shortener) formatDecl(decl dst.Decl) {
393393
}
394394
default:
395395
log.Debugf(
396-
"Got a declaration type that can't be shortened: %+v",
396+
"got a declaration type that can't be shortened: %+v",
397397
reflect.TypeOf(d),
398398
)
399399
}
@@ -473,7 +473,7 @@ func (s *Shortener) formatStmt(stmt dst.Stmt) {
473473
default:
474474
if shouldShorten {
475475
log.Debugf(
476-
"Got a statement type that can't be shortened: %+v",
476+
"got a statement type that can't be shortened: %+v",
477477
reflect.TypeOf(st),
478478
)
479479
}
@@ -565,7 +565,7 @@ func (s *Shortener) formatExpr(expr dst.Expr, force bool, isChain bool) {
565565
default:
566566
if shouldShorten {
567567
log.Debugf(
568-
"Got an expression type that can't be shortened: %+v",
568+
"got an expression type that can't be shortened: %+v",
569569
reflect.TypeOf(e),
570570
)
571571
}
@@ -585,7 +585,7 @@ func (s *Shortener) formatSpec(spec dst.Spec, force bool) {
585585
default:
586586
if shouldShorten {
587587
log.Debugf(
588-
"Got a spec type that can't be shortened: %+v",
588+
"got a spec type that can't be shortened: %+v",
589589
reflect.TypeOf(sp),
590590
)
591591
}

tags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,5 +213,5 @@ func getWidth(node dst.Node) (int, error) {
213213
return 1 + xWidth, nil
214214
}
215215

216-
return 0, fmt.Errorf("Could not get width of node %+v", node)
216+
return 0, fmt.Errorf("could not get width of node %+v", node)
217217
}

0 commit comments

Comments
 (0)