Skip to content

Commit 7dc7c49

Browse files
committed
update TaskFile for build
1 parent 188bd5e commit 7dc7c49

File tree

4 files changed

+180
-2
lines changed

4 files changed

+180
-2
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
monolize
33
go.sum
44
spark
5+
spark_*
56
__pycache__/
67
**/__pycache__/
78
.github-task-workflow.active-issue
89
node_modules/
910
site/
10-
package-lock.json
11+
package-lock.json
12+
.task/
13+
spark.exe

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ GO=go
55
GINKGO=$(GO) run github.com/onsi/ginkgo/v2/ginkgo
66

77
# Install directory
8-
INSTALL_DIR=/Users/patrick/.local/bin
8+
INSTALL_DIR=~/.local/bin
99

1010
# Detect OS
1111
ifeq ($(OS),Windows_NT)

Taskfile.yml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
version: '3'
2+
3+
vars:
4+
BINARY_NAME: spark
5+
GO: go
6+
7+
env:
8+
CGO_ENABLED: 0
9+
10+
tasks:
11+
default:
12+
cmds:
13+
- task: build
14+
15+
build:
16+
desc: Build for current OS and install
17+
cmds:
18+
- task: clean
19+
- '{{.GO}} build -ldflags="-s -w" -o {{.BINARY_NAME}}{{exeExt}} main.go'
20+
- cmd: powershell -Command "New-Item -ItemType Directory -Force -Path \"$HOME\\.local\\bin\" | Out-Null; Copy-Item -Force spark.exe \"$HOME\\.local\\bin\\spark\""
21+
platforms: [windows]
22+
- cmd: 'mkdir -p ~/.local/bin && cp {{.BINARY_NAME}}{{exeExt}} ~/.local/bin/{{.BINARY_NAME}}'
23+
platforms: [linux, darwin]
24+
- echo 'Installed {{.BINARY_NAME}} to ~/.local/bin'
25+
sources:
26+
- '**/*.go'
27+
- go.mod
28+
generates:
29+
- '{{.BINARY_NAME}}{{exeExt}}'
30+
31+
build:linux:
32+
desc: Cross-compile for Linux (amd64)
33+
cmds:
34+
- task: cross-build
35+
vars:
36+
GOOS: linux
37+
GOARCH: amd64
38+
OUTPUT: '{{.BINARY_NAME}}_linux'
39+
40+
build:linux:arm64:
41+
desc: Cross-compile for Linux (arm64)
42+
cmds:
43+
- task: cross-build
44+
vars:
45+
GOOS: linux
46+
GOARCH: arm64
47+
OUTPUT: '{{.BINARY_NAME}}_linux_arm64'
48+
49+
build:darwin:
50+
desc: Cross-compile for macOS (amd64)
51+
cmds:
52+
- task: cross-build
53+
vars:
54+
GOOS: darwin
55+
GOARCH: amd64
56+
OUTPUT: '{{.BINARY_NAME}}_darwin'
57+
58+
build:darwin:arm64:
59+
desc: Cross-compile for macOS (arm64/Apple Silicon)
60+
cmds:
61+
- task: cross-build
62+
vars:
63+
GOOS: darwin
64+
GOARCH: arm64
65+
OUTPUT: '{{.BINARY_NAME}}_darwin_arm64'
66+
67+
build:windows:
68+
desc: Cross-compile for Windows (amd64)
69+
cmds:
70+
- task: cross-build
71+
vars:
72+
GOOS: windows
73+
GOARCH: amd64
74+
OUTPUT: '{{.BINARY_NAME}}_windows.exe'
75+
76+
build:windows:arm64:
77+
desc: Cross-compile for Windows (arm64)
78+
cmds:
79+
- task: cross-build
80+
vars:
81+
GOOS: windows
82+
GOARCH: arm64
83+
OUTPUT: '{{.BINARY_NAME}}_windows_arm64.exe'
84+
85+
build:all:
86+
desc: Cross-compile for all platforms
87+
cmds:
88+
- task: build:linux
89+
- task: build:linux:arm64
90+
- task: build:darwin
91+
- task: build:darwin:arm64
92+
- task: build:windows
93+
- task: build:windows:arm64
94+
95+
test:
96+
desc: Run all tests
97+
cmds:
98+
- '{{.GO}} test ./... -v'
99+
100+
test-bdd:
101+
desc: Run BDD tests with Ginkgo
102+
cmds:
103+
- '{{.GO}} run github.com/onsi/ginkgo/v2/ginkgo -v ./internal/...'
104+
105+
lint:
106+
desc: Run go vet
107+
cmds:
108+
- '{{.GO}} vet ./...'
109+
110+
clean:
111+
desc: Remove build artifacts
112+
cmds:
113+
- cmd: powershell -Command "Remove-Item -Force -ErrorAction SilentlyContinue spark.exe,spark_windows.exe,spark_windows_arm64.exe,spark_linux,spark_linux_arm64,spark_darwin,spark_darwin_arm64; exit 0"
114+
platforms: [windows]
115+
- cmd: 'rm -f {{.BINARY_NAME}} {{.BINARY_NAME}}.exe {{.BINARY_NAME}}_linux {{.BINARY_NAME}}_linux_arm64 {{.BINARY_NAME}}_darwin {{.BINARY_NAME}}_darwin_arm64 {{.BINARY_NAME}}_windows.exe {{.BINARY_NAME}}_windows_arm64.exe'
116+
platforms: [linux, darwin]
117+
- '{{.GO}} clean'
118+
119+
install:
120+
desc: Build and install to ~/.local/bin
121+
cmds:
122+
- task: build
123+
124+
run:
125+
desc: Build and run
126+
cmds:
127+
- task: build
128+
- './{{.BINARY_NAME}}{{exeExt}} --help'
129+
130+
cross-build:
131+
internal: true
132+
requires:
133+
vars: [GOOS, GOARCH, OUTPUT]
134+
cmds:
135+
- cmd: '{{.GO}} build -ldflags="-s -w" -o {{.OUTPUT}} main.go'
136+
env:
137+
GOOS: '{{.GOOS}}'
138+
GOARCH: '{{.GOARCH}}'

tasks/features/ci/cicd.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# CI/CD Config
2+
3+
## Support Windows ,Linux,Mac Build
4+
5+
1. current build/make script doesn't support windows build.
6+
2. fix it to support build in windows
7+
3. Use [task](https://taskfile.dev/docs) to support build in windows,and other platforms include Mac,Linux
8+
9+
## Status: Done
10+
11+
### Changes
12+
13+
- Created `Taskfile.yml` using [Taskfile](https://taskfile.dev) (v3) as the cross-platform build system
14+
- Supports Windows, Linux, and macOS builds with platform-specific commands
15+
- Uses `platforms` key to conditionally run commands per OS
16+
- Uses `env` key for cross-compilation (avoids `VAR=val command` which doesn't work on Windows)
17+
- Added `.task/` and `spark_*` to `.gitignore`
18+
- Installed `task` v3.49.1 via `go install`
19+
20+
### Available Tasks
21+
22+
```
23+
task build # Build for current OS and install
24+
task build:all # Cross-compile all platforms
25+
task build:linux # Cross-compile Linux amd64
26+
task build:linux:arm64
27+
task build:darwin # Cross-compile macOS amd64
28+
task build:darwin:arm64
29+
task build:windows # Cross-compile Windows amd64
30+
task build:windows:arm64
31+
task test # Run all tests
32+
task test-bdd # Run BDD tests
33+
task lint # Run go vet
34+
task clean # Remove build artifacts
35+
task install # Build and install
36+
task run # Build and run
37+
```

0 commit comments

Comments
 (0)