-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yml
More file actions
137 lines (119 loc) · 3.87 KB
/
Taskfile.yml
File metadata and controls
137 lines (119 loc) · 3.87 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
version: '3'
vars:
BINARY_NAME: sqlite-mcp
BUILD_DIR: build
MAIN_PACKAGE: ./cmd/server
VERSION:
sh: git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0-dev"
tasks:
default:
desc: Run tests and build the application
deps: [test, build]
build:
desc: Build the application
cmds:
- mkdir -p {{.BUILD_DIR}}
- go build -o {{.BUILD_DIR}}/{{.BINARY_NAME}} {{.MAIN_PACKAGE}}
run:
desc: Run the application with example database
deps: [build, create-example-db]
cmds:
- ./{{.BUILD_DIR}}/{{.BINARY_NAME}} -db testdata/example.db
run-rw:
desc: Run the application in read-write mode with example database
deps: [build, create-example-db]
cmds:
- ./{{.BUILD_DIR}}/{{.BINARY_NAME}} -db testdata/example.db -read-write
lint:
desc: Run linting tools
cmds:
- golangci-lint run --allow-parallel-runners ./...
- go vet ./...
lint-fix:
desc: Run linting tools, and apply fixes
cmds:
- golangci-lint run --allow-parallel-runners --fix ./...
test:
desc: Run tests
cmds:
- go test -v ./...
test-coverage:
desc: Run tests with coverage
cmds:
- go test -v -coverprofile=coverage.out ./...
- go tool cover -html=coverage.out -o coverage.html
clean:
desc: Clean the build directory and test artifacts
cmds:
- rm -rf {{.BUILD_DIR}}
- rm -f coverage.out coverage.html
- rm -f testdata/example.db
fmt:
desc: Format the code
cmds:
- go fmt ./...
- golangci-lint run --allow-parallel-runners --fix
deps:
desc: Update dependencies
cmds:
- go mod tidy
install:
desc: Install dependencies
cmds:
- go mod download
create-example-db:
desc: Create example SQLite database for testing
cmds:
- mkdir -p testdata
- |
sqlite3 testdata/example.db "
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
email TEXT UNIQUE,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS products (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
price REAL NOT NULL,
category TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
INSERT OR IGNORE INTO users (name, email) VALUES
('Alice Johnson', 'alice@example.com'),
('Bob Smith', 'bob@example.com'),
('Charlie Brown', 'charlie@example.com');
INSERT OR IGNORE INTO products (name, price, category) VALUES
('Laptop', 999.99, 'Electronics'),
('Coffee Mug', 12.99, 'Kitchen'),
('Notebook', 5.99, 'Office');
"
ko-build:
desc: Build container image with ko
env:
VERSION: "{{.VERSION}}"
KO_DOCKER_REPO: ghcr.io/stackloklabs/sqlite-mcp
cmds:
- ko build --local --bare --tags={{.VERSION}},latest ./cmd/server
ko-run:
desc: Run container with ko
deps: [create-example-db]
cmds:
- ko run ./cmd/server -- -db /app/testdata/example.db
ci:
desc: Run CI pipeline (lint, test, build)
cmds:
- task: deps
- task: lint
- task: test
- task: build
release:
desc: Build release binaries for multiple platforms
cmds:
- mkdir -p {{.BUILD_DIR}}/release
- GOOS=linux GOARCH=amd64 go build -o {{.BUILD_DIR}}/release/{{.BINARY_NAME}}-linux-amd64 {{.MAIN_PACKAGE}}
- GOOS=linux GOARCH=arm64 go build -o {{.BUILD_DIR}}/release/{{.BINARY_NAME}}-linux-arm64 {{.MAIN_PACKAGE}}
- GOOS=darwin GOARCH=amd64 go build -o {{.BUILD_DIR}}/release/{{.BINARY_NAME}}-darwin-amd64 {{.MAIN_PACKAGE}}
- GOOS=darwin GOARCH=arm64 go build -o {{.BUILD_DIR}}/release/{{.BINARY_NAME}}-darwin-arm64 {{.MAIN_PACKAGE}}
- GOOS=windows GOARCH=amd64 go build -o {{.BUILD_DIR}}/release/{{.BINARY_NAME}}-windows-amd64.exe {{.MAIN_PACKAGE}}