-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
109 lines (92 loc) · 2.57 KB
/
Taskfile.yml
File metadata and controls
109 lines (92 loc) · 2.57 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
# https://taskfile.dev
version: '3'
vars:
BINARY: spin-erofs-snapshotter
VERSION:
sh: git describe --tags --always --dirty 2>/dev/null || echo "dev"
COMMIT:
sh: git rev-parse --short HEAD 2>/dev/null || echo "unknown"
BUILD_TIME:
sh: date -u '+%Y-%m-%d_%H:%M:%S'
LDFLAGS: -X main.version={{.VERSION}} -X main.commit={{.COMMIT}} -X main.buildTime={{.BUILD_TIME}}
BIN_DIR: bin
CMD_DIR: cmd/spin-erofs-snapshotter
tasks:
default:
desc: Build the binary
cmds:
- task: build
build:
desc: Build the binary
cmds:
- mkdir -p {{.BIN_DIR}}
- CGO_ENABLED=0 go build -trimpath -ldflags "{{.LDFLAGS}}" -o {{.BIN_DIR}}/{{.BINARY}} ./{{.CMD_DIR}}
sources:
- ./**/*.go
- go.mod
- go.sum
generates:
- '{{.BIN_DIR}}/{{.BINARY}}'
build-linux:
desc: Build for Linux (cross-compile)
cmds:
- mkdir -p {{.BIN_DIR}}
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -ldflags "{{.LDFLAGS}}" -o {{.BIN_DIR}}/{{.BINARY}} ./{{.CMD_DIR}}
test:
desc: Run tests
cmds:
- go test -race -count=1 ./...
test-root:
desc: Run tests as root (required for integration tests)
cmds:
- sudo env PATH="$PATH" GOPATH="$GOPATH" GOCACHE="$GOCACHE" go test -race -count=1 ./... -test.root
test-docker-build:
desc: Build the Docker test image
cmds:
- docker build -t erofs-snapshotter-test -f Dockerfile.test .
sources:
- Dockerfile.test
- scripts/build-erofs-utils.sh
test-docker:
desc: Run tests in Docker with required tools (mkfs.erofs, etc.)
deps: [test-docker-build]
cmds:
- |
docker run --privileged --rm \
-v "{{.ROOT_DIR}}:/workspace" \
-w /workspace \
erofs-snapshotter-test \
go test -race -v ./internal/... -test.root 2>&1
lint:
desc: Run linter
cmds:
- golangci-lint run ./...
fmt:
desc: Format code
cmds:
- go fmt ./...
- gofumpt -w .
vet:
desc: Run go vet
cmds:
- go vet ./...
tidy:
desc: Run go mod tidy
cmds:
- go mod tidy
clean:
desc: Clean build artifacts
cmds:
- rm -rf {{.BIN_DIR}}
integration-test:
desc: Run integration tests with containerd in Docker
cmds:
- ./scripts/run-integration-tests.sh
integration-test-build:
desc: Build integration test image and run tests
cmds:
- ./scripts/run-integration-tests.sh --build
integration-shell:
desc: Start interactive shell in integration test container
cmds:
- ./scripts/run-integration-tests.sh --shell