-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
158 lines (131 loc) · 5.13 KB
/
Copy pathTaskfile.yaml
File metadata and controls
158 lines (131 loc) · 5.13 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# See: https://taskfile.dev/docs/getting-started
version: '3'
env:
GOBIN: '{{.TASKFILE_DIR}}/bin'
tasks:
generate:
cmd: go generate github.com/detro/spelunk/v2/... github.com/detro/spelunk/plugin/... github.com/detro/spelunk/examples/...
build:
deps: [generate]
cmd: go build github.com/detro/spelunk/v2/... github.com/detro/spelunk/plugin/... github.com/detro/spelunk/examples/...
test:
deps: [test.full]
test.short:
cmd: |
{{if .CLI_ARGS}}
go test -v -race -cover -short {{.CLI_ARGS}}
{{else}}
go test -v -race -cover -short github.com/detro/spelunk/v2/... github.com/detro/spelunk/plugin/...
{{end}}
test.full:
cmd: |
{{if .CLI_ARGS}}
go test -v -race -cover {{.CLI_ARGS}}
{{else}}
go test -v -race -cover github.com/detro/spelunk/v2/... github.com/detro/spelunk/plugin/...
{{end}}
test.ci:
cmd: |
{{if .CLI_ARGS}}
go test -v -race -coverprofile=coverage.out -covermode=atomic {{.CLI_ARGS}}
{{else}}
go test -v -race -coverprofile=coverage.out -covermode=atomic github.com/detro/spelunk/v2/... github.com/detro/spelunk/plugin/...
{{end}}
lint:
cmd: |
golangci-lint run --allow-parallel-runners --verbose
find plugin -name go.mod -exec dirname {} \; | xargs -I {} -P 8 sh -c 'echo "Linting in {}..." && cd {} && golangci-lint run --allow-parallel-runners --verbose'
vuln:
desc: Run govulncheck for vulnerability scanning
cmd: |
govulncheck ./...
find plugin examples -name go.mod -exec dirname {} \; | xargs -I {} -P 8 sh -c 'echo "Scanning vulnerabilities in {}..." && cd {} && govulncheck ./...'
lint-fix:
cmd: |
golangci-lint run --fix --allow-parallel-runners --verbose
find plugin -name go.mod -exec dirname {} \; | xargs -I {} -P 8 sh -c 'echo "Fixing linter issues in {}..." && cd {} && golangci-lint run --fix --allow-parallel-runners --verbose'
fmt:
cmd: |
golangci-lint fmt -v
find plugin -name go.mod -exec dirname {} \; | xargs -I {} -P 8 sh -c 'echo "Formatting in {}..." && cd {} && golangci-lint fmt -v'
run:
cmd: go run . {{.CLI_ARGS}}
mod.update:
cmd: |
echo "Updating root module..."
go get -t -u ./...
find plugin examples -name go.mod -exec dirname {} \; | xargs -I {} -P 8 sh -c 'echo "Updating dependencies in {}..." && cd {} && go get -t -u ./...'
mod.tidy:
cmd: |
echo "Tidying root module..."
go mod tidy -v
find plugin examples -name go.mod -exec dirname {} \; | xargs -I {} -P 8 sh -c 'echo "Tidying module in {}..." && cd {} && go mod tidy -v'
dependencies.update:
deps:
- mod.update
- mod.tidy
tag:
desc: Create release tags for the root module and submodules
cmd: |
# Check if version was provided
if [ -z "{{.CLI_ARGS}}" ]; then
echo "Error: You must provide a version tag (e.g. task tag -- v2.0.0)"
exit 1
fi
# Parse arguments
set -- {{.CLI_ARGS}}
TAG_VER="$1"
SUBMOD_PATH="$2"
# Validate version starts with 'v'
if [[ ! "$TAG_VER" =~ ^v[0-9] ]]; then
echo "Error: Version must start with 'v' followed by a number (e.g. v2.0.0), got '$TAG_VER'"
exit 1
fi
if [ -n "$SUBMOD_PATH" ]; then
# Trim leading/trailing slashes from path
SUBMOD_PATH="${SUBMOD_PATH#/}"
SUBMOD_PATH="${SUBMOD_PATH%/}"
# Verify that sub-module exists and contains a go.mod
if [ ! -f "$SUBMOD_PATH/go.mod" ]; then
echo "Error: Submodule directory '$SUBMOD_PATH' does not exist or does not contain a go.mod file"
exit 1
fi
echo "Tagging submodule '$SUBMOD_PATH' with tag: $SUBMOD_PATH/$TAG_VER"
git tag "$SUBMOD_PATH/$TAG_VER"
else
echo "Tagging root module with tag: $TAG_VER"
git tag "$TAG_VER"
find plugin -name go.mod -exec dirname {} \; | while read -r dir; do
echo "Tagging submodule '$dir' with tag: $dir/$TAG_VER"
git tag "$dir/$TAG_VER"
done
fi
echo "Tags created successfully. To push tags, run: git push origin --tags"
tools.plugins:
desc: Install all necessary asdf plugins
cmd: |
# Install all plugins listed in .tool-versions (will fail but continue for out-of-registry ones)
cut -d' ' -f1 .tool-versions | while read -r plugin; do
asdf plugin add "$plugin" || true
done
# Install out-of-registry plugins
asdf plugin add govulncheck https://github.com/wizzardich/asdf-govulncheck.git
tools.update:
desc: Update all tools in .tool-versions to latest available versions via asdf
deps:
- tools.plugins
cmd: |
cut -d' ' -f1 .tool-versions | while read -r plugin; do
asdf set "$plugin" latest || true
done
tools.install:
desc: Install all tools in .tool-versions via asdf
deps:
- tools.plugins
cmd: asdf install
doc.serve:
cmds:
- go install golang.org/x/pkgsite/cmd/pkgsite@latest
- echo "Opening http://localhost:8080/github.com/detro/spelunk/v2"
- sleep 2 && open http://localhost:8080/github.com/detro/spelunk/v2 &
- bin/pkgsite