ci: Test with Go 1.23 and 1.24 (#502)
In CI, test with Go 1.23 and 1.24, and upgrade the Hermit-managed Go and golangci-lint to latest versions. The new golangci-lint had a number of warnings and minor issues that were either fixed or opted-out of.
This commit is contained in:
@@ -13,7 +13,7 @@ jobs:
|
||||
matrix:
|
||||
# These are the release channels.
|
||||
# Hermit will handle installing the right patch.
|
||||
go: ["1.20", "1.21"]
|
||||
go: ["1.23", "1.24"]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
matrix:
|
||||
# These are versions for GitHub's setup-go.
|
||||
# '.x' will pick the latest patch release.
|
||||
go: ["1.20.x", "1.21.x"]
|
||||
go: ["1.23.x", "1.24.x"]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
+2
-2
@@ -12,7 +12,6 @@ linters:
|
||||
- wsl
|
||||
- funlen
|
||||
- gocognit
|
||||
- gomnd
|
||||
- goprintffuncname
|
||||
- paralleltest
|
||||
- nlreturn
|
||||
@@ -36,13 +35,14 @@ linters:
|
||||
- nilnil
|
||||
- depguard # nothing to guard against yet
|
||||
- tagalign # hurts readability of kong tags
|
||||
- tenv # deprecated since v1.64, but not removed yet
|
||||
- mnd
|
||||
- perfsprint
|
||||
- err113
|
||||
- copyloopvar
|
||||
- intrange
|
||||
- execinquery
|
||||
- nakedret
|
||||
- recvcheck # value receivers are intentionally used for copies
|
||||
|
||||
linters-settings:
|
||||
govet:
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
.golangci-lint-1.60.1.pkg
|
||||
.golangci-lint-1.64.5.pkg
|
||||
+6
-9
@@ -15,12 +15,10 @@ func TestMultipleConfigLoading(t *testing.T) {
|
||||
}
|
||||
|
||||
cli.Flag = "first"
|
||||
first, cleanFirst := makeConfig(t, &cli)
|
||||
defer cleanFirst()
|
||||
first := makeConfig(t, &cli)
|
||||
|
||||
cli.Flag = ""
|
||||
second, cleanSecond := makeConfig(t, &cli)
|
||||
defer cleanSecond()
|
||||
second := makeConfig(t, &cli)
|
||||
|
||||
p := mustNew(t, &cli, kong.Configuration(kong.JSON, first, second))
|
||||
_, err := p.Parse(nil)
|
||||
@@ -34,20 +32,19 @@ func TestConfigValidation(t *testing.T) {
|
||||
}
|
||||
|
||||
cli.Flag = "invalid"
|
||||
conf, cleanConf := makeConfig(t, &cli)
|
||||
defer cleanConf()
|
||||
conf := makeConfig(t, &cli)
|
||||
|
||||
p := mustNew(t, &cli, kong.Configuration(kong.JSON, conf))
|
||||
_, err := p.Parse(nil)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func makeConfig(t *testing.T, config any) (path string, cleanup func()) {
|
||||
func makeConfig(t *testing.T, config any) (path string) {
|
||||
t.Helper()
|
||||
w, err := os.CreateTemp("", "")
|
||||
w, err := os.CreateTemp(t.TempDir(), "")
|
||||
assert.NoError(t, err)
|
||||
defer w.Close()
|
||||
err = json.NewEncoder(w).Encode(config)
|
||||
assert.NoError(t, err)
|
||||
return w.Name(), func() { os.Remove(w.Name()) }
|
||||
return w.Name()
|
||||
}
|
||||
|
||||
@@ -415,7 +415,7 @@ func (h *helpWriter) Write(w io.Writer) error {
|
||||
|
||||
func (h *helpWriter) Wrap(text string) {
|
||||
w := bytes.NewBuffer(nil)
|
||||
doc.ToText(w, strings.TrimSpace(text), "", " ", h.width)
|
||||
doc.ToText(w, strings.TrimSpace(text), "", " ", h.width) //nolint:staticcheck // cross-package links not possible
|
||||
for _, line := range strings.Split(strings.TrimSpace(w.String()), "\n") {
|
||||
h.Print(line)
|
||||
}
|
||||
@@ -470,7 +470,7 @@ func writeTwoColumns(w *helpWriter, rows [][2]string) {
|
||||
|
||||
for _, row := range rows {
|
||||
buf := bytes.NewBuffer(nil)
|
||||
doc.ToText(buf, row[1], "", strings.Repeat(" ", defaultIndent), w.width-leftSize-defaultColumnPadding)
|
||||
doc.ToText(buf, row[1], "", strings.Repeat(" ", defaultIndent), w.width-leftSize-defaultColumnPadding) //nolint:staticcheck // cross-package links not possible
|
||||
lines := strings.Split(strings.TrimRight(buf.String(), "\n"), "\n")
|
||||
|
||||
line := fmt.Sprintf("%-*s", leftSize, row[0])
|
||||
|
||||
+5
-9
@@ -83,8 +83,7 @@ func TestHelp(t *testing.T) {
|
||||
|
||||
Three threeArg `arg help:"Sub-sub-arg."`
|
||||
|
||||
Four struct {
|
||||
} `cmd help:"Sub-sub-command."`
|
||||
Four struct{} `cmd help:"Sub-sub-command."`
|
||||
} `cmd help:"Another subcommand."`
|
||||
}
|
||||
|
||||
@@ -192,8 +191,7 @@ func TestFlagsLast(t *testing.T) {
|
||||
|
||||
Three threeArg `arg help:"Sub-sub-arg."`
|
||||
|
||||
Four struct {
|
||||
} `cmd help:"Sub-sub-command."`
|
||||
Four struct{} `cmd help:"Sub-sub-command."`
|
||||
} `cmd help:"Another subcommand."`
|
||||
}
|
||||
|
||||
@@ -296,8 +294,7 @@ func TestHelpTree(t *testing.T) {
|
||||
Two struct {
|
||||
Three threeArg `arg help:"Sub-sub-arg."`
|
||||
|
||||
Four struct {
|
||||
} `cmd help:"Sub-sub-command." aliases:"for,fore"`
|
||||
Four struct{} `cmd help:"Sub-sub-command." aliases:"for,fore"`
|
||||
} `cmd help:"Another subcommand."`
|
||||
}
|
||||
|
||||
@@ -390,8 +387,7 @@ func TestHelpCompactNoExpand(t *testing.T) {
|
||||
Two struct {
|
||||
Three threeArg `arg help:"Sub-sub-arg."`
|
||||
|
||||
Four struct {
|
||||
} `cmd help:"Sub-sub-command." aliases:"for,fore"`
|
||||
Four struct{} `cmd help:"Sub-sub-command." aliases:"for,fore"`
|
||||
} `cmd help:"Another subcommand."`
|
||||
}
|
||||
|
||||
@@ -603,7 +599,7 @@ func TestAutoGroup(t *testing.T) {
|
||||
if node, ok := parent.(*kong.Node); ok {
|
||||
return &kong.Group{
|
||||
Key: node.Name,
|
||||
Title: strings.Title(node.Name) + " flags:",
|
||||
Title: strings.Title(node.Name) + " flags:", //nolint:staticcheck // strings.Title in test is okay
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
+2
-4
@@ -268,9 +268,8 @@ func TestFileContentFlag(t *testing.T) {
|
||||
var cli struct {
|
||||
File kong.FileContentFlag
|
||||
}
|
||||
f, err := os.CreateTemp("", "")
|
||||
f, err := os.CreateTemp(t.TempDir(), "")
|
||||
assert.NoError(t, err)
|
||||
defer os.Remove(f.Name())
|
||||
fmt.Fprint(f, "hello world")
|
||||
f.Close()
|
||||
_, err = mustNew(t, &cli).Parse([]string{"--file", f.Name()})
|
||||
@@ -282,9 +281,8 @@ func TestNamedFileContentFlag(t *testing.T) {
|
||||
var cli struct {
|
||||
File kong.NamedFileContentFlag
|
||||
}
|
||||
f, err := os.CreateTemp("", "")
|
||||
f, err := os.CreateTemp(t.TempDir(), "")
|
||||
assert.NoError(t, err)
|
||||
defer os.Remove(f.Name())
|
||||
fmt.Fprint(f, "hello world")
|
||||
f.Close()
|
||||
_, err = mustNew(t, &cli).Parse([]string{"--file", f.Name()})
|
||||
|
||||
+1
-1
@@ -63,6 +63,6 @@ func JSON(r io.Reader) (Resolver, error) {
|
||||
}
|
||||
|
||||
func snakeCase(name string) string {
|
||||
name = strings.Join(strings.Split(strings.Title(name), "-"), "")
|
||||
name = strings.Join(strings.Split(strings.Title(name), "-"), "") //nolint:staticcheck // Unicode punctuation not an issue
|
||||
return strings.ToLower(name[:1]) + name[1:]
|
||||
}
|
||||
|
||||
+1
-2
@@ -16,9 +16,8 @@ func TestConfigFlag(t *testing.T) {
|
||||
Flag string
|
||||
}
|
||||
|
||||
w, err := os.CreateTemp("", "")
|
||||
w, err := os.CreateTemp(t.TempDir(), "")
|
||||
assert.NoError(t, err)
|
||||
defer os.Remove(w.Name())
|
||||
w.WriteString(`{"flag": "hello world"}`) //nolint: errcheck
|
||||
w.Close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user