Repository navigation
Expand file tree
/
Copy pathtaskfile-tools.yml
More file actions
66 lines (59 loc) · 2.32 KB
/
Copy pathtaskfile-tools.yml
File metadata and controls
66 lines (59 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Dev tool management for go-region-share.
#
# Each tool is pinned to a version and installed into ./tmp/<name>/<version>/
# so local and CI runs are reproducible and isolated from the global GOBIN.
# Tasks expose a <TOOL>_BIN var pointing at the installed binary.
version: '3'
vars:
# Pinned tool versions.
GOFUMPT_VERSION: v0.9.2
GOFUMPT_URL: mvdan.cc/gofumpt
GOFUMPT_NAME: gofumpt
STATICCHECK_VERSION: v0.7.0
STATICCHECK_URL: honnef.co/go/tools/cmd/staticcheck
STATICCHECK_NAME: staticcheck
GOVULNCHECK_VERSION: v1.1.4
GOVULNCHECK_URL: golang.org/x/vuln/cmd/govulncheck
GOVULNCHECK_NAME: govulncheck
# Absolute path to the installed binary for each tool (Windows: .exe).
GOFUMPT_BIN: '{{.ROOT_DIR}}/{{.TMP}}/{{.GOFUMPT_NAME}}/{{.GOFUMPT_VERSION}}/{{.GOFUMPT_NAME}}.exe'
STATICCHECK_BIN: '{{.ROOT_DIR}}/{{.TMP}}/{{.STATICCHECK_NAME}}/{{.STATICCHECK_VERSION}}/{{.STATICCHECK_NAME}}.exe'
GOVULNCHECK_BIN: '{{.ROOT_DIR}}/{{.TMP}}/{{.GOVULNCHECK_NAME}}/{{.GOVULNCHECK_VERSION}}/{{.GOVULNCHECK_NAME}}.exe'
tasks:
go-install:
internal: true
silent: true
# GOBIN is set via Task's own env block (not inline shell syntax) so it
# works identically under Task's built-in shell on CI and locally.
env:
GOBIN: '{{.TARGET_DIR}}'
cmds:
- go install {{.PACKAGE}}
check-go-tool:
desc: 'install a pinned go tool if missing (pass TOOL=GOFUMPT|STATICCHECK|GOVULNCHECK)'
internal: true
silent: true
vars:
NAME: '{{index . (print .TOOL "_NAME")}}'
VERSION: '{{index . (print .TOOL "_VERSION")}}'
URL: '{{index . (print .TOOL "_URL")}}'
TARGET_DIR: '{{.ROOT_DIR}}/{{.TMP}}/{{index . (print .TOOL "_NAME")}}/{{index . (print .TOOL "_VERSION")}}'
# Skip installing when the binary already exists. Task's built-in shell
# supports POSIX `test`, which is cross-platform here.
status:
- test -f "{{.TARGET_DIR}}/{{.NAME}}.exe"
cmds:
- echo installing {{.NAME}} {{.VERSION}} ...
- task: go-install
vars:
PACKAGE: '{{.URL}}@{{.VERSION}}'
TARGET_DIR: '{{.TARGET_DIR}}'
tools-install:
desc: 'install all pinned dev tools into ./tmp'
cmds:
- task: check-go-tool
vars: {TOOL: GOFUMPT}
- task: check-go-tool
vars: {TOOL: STATICCHECK}
- task: check-go-tool
vars: {TOOL: GOVULNCHECK}