Skip to content

Commit 52517b2

Browse files
authored
Select binary within a github release archive when multiple present (#74)
* filter multiple bins by configured binary name Signed-off-by: Alex Goodman <[email protected]> * update tools Signed-off-by: Alex Goodman <[email protected]> * update linter Signed-off-by: Alex Goodman <[email protected]> * update docs Signed-off-by: Alex Goodman <[email protected]> * fix lint Signed-off-by: Alex Goodman <[email protected]> * account for windows ext Signed-off-by: Alex Goodman <[email protected]> * use filepath for path parsing Signed-off-by: Alex Goodman <[email protected]> --------- Signed-off-by: Alex Goodman <[email protected]>
1 parent 6ac3cc0 commit 52517b2

File tree

23 files changed

+257
-112
lines changed

23 files changed

+257
-112
lines changed

.binny.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ tools:
1717

1818
- name: gh
1919
version:
20-
want: v2.35.0
20+
want: v2.67.0
2121
method: github-release
2222
with:
2323
repo: cli/cli
2424

2525
- name: quill
2626
version:
27-
want: v0.4.1
27+
want: v0.5.1
2828
method: github-release
2929
with:
3030
repo: anchore/quill
@@ -45,21 +45,21 @@ tools:
4545

4646
- name: glow
4747
version:
48-
want: v1.5.1
48+
want: v2.1.0
4949
method: github-release
5050
with:
5151
repo: charmbracelet/glow
5252

5353
- name: goreleaser
5454
version:
55-
want: v1.21.1
55+
want: v2.7.0
5656
method: github-release
5757
with:
5858
repo: goreleaser/goreleaser
5959

6060
- name: golangci-lint
6161
version:
62-
want: v1.54.2
62+
want: v1.64.6
6363
method: github-release
6464
with:
6565
repo: golangci/golangci-lint
@@ -73,14 +73,14 @@ tools:
7373

7474
- name: task
7575
version:
76-
want: v3.30.1
76+
want: v3.41.0
7777
method: github-release
7878
with:
7979
repo: go-task/task
8080

8181
- name: syft
8282
version:
83-
want: v0.91.0
83+
want: v1.20.0
8484
method: github-release
8585
with:
8686
repo: anchore/syft

.github/actions/bootstrap/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ inputs:
44
go-version:
55
description: "Go version to install"
66
required: true
7-
default: "1.21.x"
7+
default: "1.24.x"
88
cache-key-prefix:
99
description: "Prefix all cache keys with this value"
1010
required: true

.golangci.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
issues:
22
max-same-issues: 25
3+
uniq-by-line: false
34

4-
# TODO: enable this when we have coverage on docstring comments
5+
# TODO: enable this when we have coverage on docstring comments
56
# # The list of ids of default excludes to include or disable.
67
# include:
78
# - EXC0002 # disable excluding of issues about comments from golint
@@ -12,10 +13,10 @@ linters:
1213
enable:
1314
- asciicheck
1415
- bodyclose
16+
- copyloopvar
1517
- dogsled
1618
- dupl
1719
- errcheck
18-
- exportloopref
1920
- funlen
2021
- gocognit
2122
- goconst
@@ -30,6 +31,7 @@ linters:
3031
- ineffassign
3132
- misspell
3233
- nakedret
34+
- nolintlint
3335
- revive
3436
- staticcheck
3537
- stylecheck
@@ -49,10 +51,12 @@ linters-settings:
4951
# If lower than 0, disable the check.
5052
# Default: 40
5153
statements: 50
52-
output:
53-
uniq-by-line: false
54+
gosec:
55+
excludes:
56+
- G115
5457
run:
5558
timeout: 10m
59+
tests: false
5660

5761
# do not enable...
5862
# - deadcode # The owner seems to have abandoned the linter. Replaced by "unused".
@@ -72,7 +76,6 @@ run:
7276
# - lll # without a way to specify per-line exception cases, this is not usable
7377
# - maligned # this is an excellent linter, but tricky to optimize and we are not sensitive to memory layout optimizations
7478
# - nestif
75-
# - nolintlint # as of go1.19 this conflicts with the behavior of gofmt, which is a deal-breaker (lint-fix will still fail when running lint)
7679
# - prealloc # following this rule isn't consistently a good idea, as it sometimes forces unnecessary allocations that result in less idiomatic code
7780
# - rowserrcheck # not in a repo with sql, so this is not useful
7881
# - scopelint # deprecated

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,10 @@ The `version.want` option allows a special entry:
196196

197197
The `github-release` version method uses the GitHub Releases API to determine the latest release of a tool. It requires the following configuration options:
198198

199-
| Option | Description |
200-
|--------|-------------------------------------------------------------------------------------------------|
201-
| `repo` | The GitHub repository to reference releases from. This should be in the format `<owner>/<repo>` |
199+
| Option | Description |
200+
|----------|-------------------------------------------------------------------------------------------------|
201+
| `binary` | Binary to select if there are multiple within the release archive (defaults to the tool name) |
202+
| `repo` | The GitHub repository to reference releases from. This should be in the format `<owner>/<repo>` |
202203

203204
The `version.want` option allows a special entry:
204205
- `latest`: don't pin to a version, use the latest available

Taskfile.yaml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,37 @@ tasks:
5959
tools:
6060
desc: Install all tools needed for CI and local development
6161
deps: [binny]
62+
aliases:
63+
- bootstrap
6264
generates:
63-
- "{{ .TOOL_DIR }}/binny"
64-
- "{{ .TOOL_DIR }}/goreleaser"
65-
- "{{ .TOOL_DIR }}/chronicle"
66-
- "{{ .TOOL_DIR }}/glow"
67-
- "{{ .TOOL_DIR }}/golangci-lint"
68-
- "{{ .TOOL_DIR }}/gosimports"
69-
- "{{ .TOOL_DIR }}/bouncer"
70-
- "{{ .TOOL_DIR }}/task"
65+
- ".binny.yaml"
66+
- "{{ .TOOL_DIR }}/*"
7167
status:
7268
- "{{ .TOOL_DIR }}/binny check -v"
7369
cmd: "{{ .TOOL_DIR }}/binny install -v"
7470
silent: true
7571

72+
update-tools:
73+
desc: Update pinned versions of all tools to their latest available versions
74+
deps: [binny]
75+
generates:
76+
- ".binny.yaml"
77+
- "{{ .TOOL_DIR }}/*"
78+
cmd: "{{ .TOOL_DIR }}/binny update -v"
79+
silent: true
80+
81+
list-tools:
82+
desc: List all tools needed for CI and local development
83+
deps: [binny]
84+
cmd: "{{ .TOOL_DIR }}/binny list"
85+
silent: true
86+
87+
list-tool-updates:
88+
desc: List all tools that are not up to date relative to the binny config
89+
deps: [binny]
90+
cmd: "{{ .TOOL_DIR }}/binny list --updates"
91+
silent: true
92+
7693

7794
## Static analysis tasks #################################
7895

@@ -129,7 +146,7 @@ tasks:
129146
sh: "python ./scripts/list_units.py anchore binny"
130147

131148
# unit test coverage threshold (in % coverage)
132-
COVERAGE_THRESHOLD: '{{if eq OS "windows"}} 43 {{else}} 45 {{end}}'
149+
COVERAGE_THRESHOLD: 35
133150
cmds:
134151
- cmd: "{{ .MAKEDIR_P }} {{ .TMP_DIR }}"
135152
silent: true

cmd/binny/cli/command/add_github_release.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ func AddGithubRelease(app clio.Application) *cobra.Command {
3030
Use: "github-release OWNER/REPO@VERSION",
3131
Short: "Add a new tool configuration that sources binaries from GitHub releases",
3232
Args: cobra.ExactArgs(1),
33-
PreRunE: func(cmd *cobra.Command, args []string) error {
33+
PreRunE: func(_ *cobra.Command, args []string) error {
3434
if !strings.Contains(args[0], "/") {
3535
return fmt.Errorf("invalid 'owner/project@version' format: %q", args[0])
3636
}
3737
return nil
3838
},
39-
RunE: func(cmd *cobra.Command, args []string) error {
39+
RunE: func(_ *cobra.Command, args []string) error {
4040
return runGithubReleaseConfig(*cfg, args[0])
4141
},
4242
}, cfg)

cmd/binny/cli/command/add_go_install.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ func AddGoInstall(app clio.Application) *cobra.Command {
3535
Use: "go-install NAME@VERSION --module GOMODULE [--entrypoint PATH] [--ldflags FLAGS]",
3636
Short: "Add a new tool configuration from 'go install ...' invocations",
3737
Args: cobra.ExactArgs(1),
38-
PreRunE: func(cmd *cobra.Command, args []string) error {
38+
PreRunE: func(_ *cobra.Command, _ []string) error {
3939
if cfg.Install.GoInstall.Module == "" {
4040
return fmt.Errorf("go-install configuration requires '--module' option")
4141
}
4242
return nil
4343
},
44-
RunE: func(cmd *cobra.Command, args []string) error {
44+
RunE: func(_ *cobra.Command, args []string) error {
4545
return runAddGoInstallConfig(*cfg, args[0])
4646
},
4747
}, cfg)

cmd/binny/cli/command/check.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ func Check(app clio.Application) *cobra.Command {
3333
Use: "check",
3434
Short: "Verify tool are installed at the configured version",
3535
Args: cobra.ArbitraryArgs,
36-
PreRunE: func(cmd *cobra.Command, args []string) error {
36+
PreRunE: func(_ *cobra.Command, args []string) error {
3737
names = args
3838
return nil
3939
},
40-
RunE: func(cmd *cobra.Command, args []string) error {
40+
RunE: func(_ *cobra.Command, _ []string) error {
4141
return runCheck(*cfg, names)
4242
},
4343
}, cfg)

cmd/binny/cli/command/install.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,17 @@ func Install(app clio.Application) *cobra.Command {
3939
Use: "install",
4040
Short: "Install tools",
4141
Args: cobra.ArbitraryArgs,
42-
PreRunE: func(cmd *cobra.Command, args []string) error {
42+
PreRunE: func(_ *cobra.Command, args []string) error {
4343
names = args
4444
return nil
4545
},
46-
RunE: func(cmd *cobra.Command, args []string) error {
46+
RunE: func(_ *cobra.Command, _ []string) error {
4747
return runInstall(*cfg, names)
4848
},
4949
}, cfg)
5050
}
5151

52-
// nolint: funlen
53-
func runInstall(cmdCfg InstallConfig, names []string) error {
52+
func runInstall(cmdCfg InstallConfig, names []string) error { //nolint: funlen
5453
names, toolOpts := selectNamesAndConfigs(cmdCfg.Core, names)
5554

5655
if len(toolOpts) == 0 {
@@ -115,7 +114,7 @@ func runInstall(cmdCfg InstallConfig, names []string) error {
115114
}
116115

117116
// note: we can ignore the error here because we are tracking the error through the multierror object
118-
g.Wait() // nolint: errcheck
117+
g.Wait() //nolint: errcheck
119118

120119
alreadyInstalled = len(alreadyInstalledTools) > 0 && len(alreadyInstalledTools) == len(toolOpts)
121120

cmd/binny/cli/command/list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ func List(app clio.Application) *cobra.Command {
4444
"ls",
4545
},
4646
Args: cobra.ArbitraryArgs,
47-
PreRunE: func(cmd *cobra.Command, args []string) error {
47+
PreRunE: func(_ *cobra.Command, args []string) error {
4848
if cfg.Format.JQCommand != "" && cfg.Format.Output != "json" {
4949
return fmt.Errorf("--jq can only be used when --output format is 'json'")
5050
}
5151
cfg.IncludeFilter = args
5252
return nil
5353
},
54-
RunE: func(cmd *cobra.Command, args []string) error {
54+
RunE: func(_ *cobra.Command, _ []string) error {
5555
return runList(*cfg)
5656
},
5757
}, cfg)

0 commit comments

Comments
 (0)