Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
184 lines (162 loc) · 6.23 KB
/
Copy pathTaskfile.yml
File metadata and controls
184 lines (162 loc) · 6.23 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
version: '3'
vars:
BINARY_NAME: spark
BIN_DIR: bin
GO: go
VERSION:
sh: cat internal/witr/version/VERSION 2>/dev/null || echo dev
COMMIT:
sh: git rev-parse --short HEAD 2>/dev/null || echo unknown
BUILD_DATE:
sh: date -u +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || echo unknown
env:
CGO_ENABLED: '0'
tasks:
default:
cmds:
- task: build
prepare-bin:
internal: true
cmds:
- cmd: powershell -NoProfile -Command "New-Item -ItemType Directory -Force {{.BIN_DIR}} | Out-Null"
platforms: [windows]
- cmd: 'mkdir -p {{.BIN_DIR}}'
platforms: [linux, darwin]
build:
desc: Build for current OS into bin/, stamp version, install to ~/.local/bin
cmds:
- task: prepare-bin
- cmd: '{{.GO}} build -ldflags="-s -w -X spark/internal/witr/version.Version=v{{.VERSION}} -X spark/internal/witr/version.Commit={{.COMMIT}} -X spark/internal/witr/version.BuildDate={{.BUILD_DATE}}" -o {{.BIN_DIR}}/{{.BINARY_NAME}}{{exeExt}} main.go'
- cmd: powershell -NoProfile -ExecutionPolicy Bypass -File scripts/install-binary.ps1 -Source '{{.BIN_DIR}}/{{.BINARY_NAME}}.exe' -InstallDir $HOME/.local/bin
platforms: [windows]
- cmd: 'bash scripts/install-binary.sh {{.BIN_DIR}}/{{.BINARY_NAME}}{{exeExt}} $HOME/.local/bin'
platforms: [linux, darwin]
- cmd: powershell -NoProfile -ExecutionPolicy Bypass -File scripts/verify-install.ps1 -Source '{{.BIN_DIR}}/{{.BINARY_NAME}}.exe' -InstallDir $HOME/.local/bin
platforms: [windows]
- cmd: 'bash scripts/verify-install.sh {{.BIN_DIR}}/{{.BINARY_NAME}}{{exeExt}} $HOME/.local/bin'
platforms: [linux, darwin]
- echo 'Built {{.BIN_DIR}}/{{.BINARY_NAME}}{{exeExt}}, installed to ~/.local/bin'
build:linux:
desc: Cross-compile for Linux (amd64) into bin/
cmds:
- task: cross-build
vars:
GOOS: linux
GOARCH: amd64
OUTPUT: '{{.BIN_DIR}}/{{.BINARY_NAME}}_linux'
build:linux:arm64:
desc: Cross-compile for Linux (arm64) into bin/
cmds:
- task: cross-build
vars:
GOOS: linux
GOARCH: arm64
OUTPUT: '{{.BIN_DIR}}/{{.BINARY_NAME}}_linux_arm64'
build:darwin:
desc: Cross-compile for macOS (amd64) into bin/
cmds:
- task: cross-build
vars:
GOOS: darwin
GOARCH: amd64
OUTPUT: '{{.BIN_DIR}}/{{.BINARY_NAME}}_darwin'
build:darwin:arm64:
desc: Cross-compile for macOS (arm64/Apple Silicon) into bin/
cmds:
- task: cross-build
vars:
GOOS: darwin
GOARCH: arm64
OUTPUT: '{{.BIN_DIR}}/{{.BINARY_NAME}}_darwin_arm64'
build:windows:
desc: Cross-compile for Windows (amd64) into bin/
cmds:
- task: cross-build
vars:
GOOS: windows
GOARCH: amd64
OUTPUT: '{{.BIN_DIR}}/{{.BINARY_NAME}}_windows.exe'
build:windows:arm64:
desc: Cross-compile for Windows (arm64) into bin/
cmds:
- task: cross-build
vars:
GOOS: windows
GOARCH: arm64
OUTPUT: '{{.BIN_DIR}}/{{.BINARY_NAME}}_windows_arm64.exe'
build:all:
desc: Cross-compile for all platforms into bin/
cmds:
- task: build:linux
- task: build:linux:arm64
- task: build:darwin
- task: build:darwin:arm64
- task: build:windows
- task: build:windows:arm64
test:
desc: Run all tests
cmds:
- '{{.GO}} test ./... -v'
test-bdd:
desc: Run BDD tests with Ginkgo
cmds:
- '{{.GO}} run github.com/onsi/ginkgo/v2/ginkgo -v ./internal/...'
test-report:
desc: Run BDD tests and generate an HTML report at reports/test-report.html
cmds:
- cmd: powershell -NoProfile -Command "New-Item -ItemType Directory -Force reports | Out-Null"
platforms: [windows]
- cmd: 'mkdir -p reports'
platforms: [linux, darwin]
- cmd: '{{.GO}} run github.com/onsi/ginkgo/v2/ginkgo -v --keep-going --output-dir=reports --json-report=ginkgo-report.json ./...'
ignore_error: true
- '{{.GO}} run ./tools/testreport -in reports/ginkgo-report.json -out reports/test-report.html'
lint:
desc: Run go vet
cmds:
- '{{.GO}} vet ./...'
clean:
desc: Remove build artifacts (bin/)
cmds:
- cmd: powershell -NoProfile -Command "Remove-Item -Recurse -Force -ErrorAction SilentlyContinue {{.BIN_DIR}}; exit 0"
platforms: [windows]
- cmd: 'rm -rf {{.BIN_DIR}}'
platforms: [linux, darwin]
- '{{.GO}} clean'
install:
desc: Build into bin/ and install to ~/.local/bin
cmds:
- task: build
run:
desc: Build and run
cmds:
- task: build
- './{{.BIN_DIR}}/{{.BINARY_NAME}}{{exeExt}} --help'
install-binary:
desc: Copy the already-built binary from bin/ into ~/.local/bin (no rebuild)
cmds:
- cmd: powershell -NoProfile -ExecutionPolicy Bypass -File scripts/install-binary.ps1 -Source '{{.BIN_DIR}}/{{.BINARY_NAME}}.exe' -InstallDir $HOME/.local/bin
platforms: [windows]
- cmd: 'bash scripts/install-binary.sh {{.BIN_DIR}}/{{.BINARY_NAME}}{{exeExt}} $HOME/.local/bin'
platforms: [linux, darwin]
- cmd: powershell -NoProfile -ExecutionPolicy Bypass -File scripts/verify-install.ps1 -Source '{{.BIN_DIR}}/{{.BINARY_NAME}}.exe' -InstallDir $HOME/.local/bin
platforms: [windows]
- cmd: 'bash scripts/verify-install.sh {{.BIN_DIR}}/{{.BINARY_NAME}}{{exeExt}} $HOME/.local/bin'
platforms: [linux, darwin]
verify-install:
desc: Compare installed binary sha256 against bin/ source
cmds:
- cmd: powershell -NoProfile -ExecutionPolicy Bypass -File scripts/verify-install.ps1 -Source '{{.BIN_DIR}}/{{.BINARY_NAME}}.exe' -InstallDir $HOME/.local/bin
platforms: [windows]
- cmd: 'bash scripts/verify-install.sh {{.BIN_DIR}}/{{.BINARY_NAME}}{{exeExt}} $HOME/.local/bin'
platforms: [linux, darwin]
cross-build:
internal: true
requires:
vars: [GOOS, GOARCH, OUTPUT]
env:
GOOS: '{{.GOOS}}'
GOARCH: '{{.GOARCH}}'
cmds:
- task: prepare-bin
- '{{.GO}} build -ldflags="-s -w -X spark/internal/witr/version.Version=v{{.VERSION}} -X spark/internal/witr/version.Commit={{.COMMIT}} -X spark/internal/witr/version.BuildDate={{.BUILD_DATE}}" -o {{.OUTPUT}} main.go'