Skip to content

Commit 63a125c

Browse files
committed
chore: add justfile
Signed-off-by: Ayush <mail@ayuch.dev>
1 parent ab58e04 commit 63a125c

1 file changed

Lines changed: 98 additions & 0 deletions

File tree

justfile

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
binary_name := "gitx"
2+
cmd_path := "./cmd/gitx"
3+
build_path := "./build"
4+
app_version := `git describe --tags --abbrev=0 2>/dev/null || echo "dev"`
5+
ldflags := "-X main.version=" + app_version
6+
7+
default: build
8+
9+
# Syncs dependencies
10+
[group('core')]
11+
sync:
12+
@echo "Syncing dependencies..."
13+
@go mod tidy
14+
@echo "Dependencies synced."
15+
16+
# Builds the binary, runs sync first
17+
[group('core')]
18+
build: sync
19+
@echo "Building the application..."
20+
@mkdir -p {{ build_path }}
21+
@go build -ldflags "{{ ldflags }}" -o {{ build_path }}/{{ binary_name }} {{ cmd_path }}
22+
@echo "Binary available at {{ build_path }}/{{ binary_name }}"
23+
24+
# Runs the application, runs build first
25+
[group('core')]
26+
run: build
27+
@echo "Running {{ binary_name }}..."
28+
@{{ build_path }}/{{ binary_name }}
29+
30+
# Installs the binary to GOPATH/bin, runs build first
31+
[group('core')]
32+
install: build
33+
@echo "Installing {{ binary_name }}..."
34+
@go install {{ ldflags }} {{ cmd_path }}
35+
@echo "{{ binary_name }} installed successfully"
36+
37+
# Print help message, runs build first
38+
[group('core')]
39+
help: build
40+
@{{ build_path }}/{{ binary_name }} --help
41+
42+
# Runs all tests
43+
[group('dev')]
44+
test:
45+
@echo "Running tests..."
46+
@go test -v ./...
47+
48+
# Runs golangci-lint
49+
[group('dev')]
50+
ci:
51+
@echo "Running golangci-lint..."
52+
@golangci-lint run
53+
54+
# Format Go code
55+
[group('dev')]
56+
fmt:
57+
@echo "Formatting Go code..."
58+
@go fmt ./...
59+
60+
# Static analysis
61+
[group('dev')]
62+
vet:
63+
@echo "Running go vet..."
64+
@go vet ./...
65+
66+
# Test for any race conditions
67+
[group('dev')]
68+
test-race:
69+
@echo "Running race tests..."
70+
@go test -race ./...
71+
72+
# Coverage summary + artifact
73+
[group('dev')]
74+
cover:
75+
@echo "Running coverage..."
76+
@go test -coverprofile=coverage.out ./...
77+
@go tool cover -func=coverage.out
78+
79+
# Run all checks: fmt, vet, test, ci
80+
[group('dev')]
81+
check: fmt vet test ci
82+
@echo "All checks passed."
83+
84+
# Print binary version, runs build first
85+
[group('dev')]
86+
version:
87+
@{{ build_path }}/{{ binary_name }} --version
88+
89+
# Clean and rebuild the binary
90+
[group('maintenance')]
91+
rebuild: clean build
92+
93+
# Cleans the build directory
94+
[group('maintenance')]
95+
clean:
96+
@echo "Cleaning up..."
97+
@rm -rf {{ build_path }}
98+
@echo "Cleanup complete."

0 commit comments

Comments
 (0)