-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjustfile
More file actions
122 lines (93 loc) · 3.02 KB
/
Copy pathjustfile
File metadata and controls
122 lines (93 loc) · 3.02 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
# Variables
export LOG_STYLE := "emoji"
logger := "scripts/lib/logger.sh"
# Go commands
go := "go"
goclean := go + " clean"
freeze := "freeze"
# Default - show help
default:
@just --list
# Clean the build directory and Go cache
clean:
@. {{ logger }} && log_info "Clean the build directory and Go cache"
rm -f coverage.out coverage.html
{{ goclean }} -cache
# === Code Quality ===
# Format code
fmt:
@. {{ logger }} && log_info "Running fmt"
{{ go }} fmt ./...
# Run go-modernize with auto-fix
modernize:
@. {{ logger }} && log_info "Running go-modernize"
modernize --fix ./...
# Run golangci-lint
lint:
@. {{ logger }} && log_info "Running golangci-lint"
golangci-lint run ./...
# Run goreportcard-cli
reportcard:
@. {{ logger }} && log_info "Running goreportcard-cli"
goreportcard-cli -v
# Run govulncheck
security-scan:
@. {{ logger }} && log_info "Running govulncheck"
govulncheck ./...
# Run modernize, lint, and reportcard
check: fmt modernize lint reportcard
# Run go mod tidy
tidy:
@. {{ logger }} && log_info "Running go mod tidy"
{{ go }} mod tidy
# Run go mod download
deps:
@. {{ logger }} && log_info "Running go mod download"
{{ go }} mod download
# === Test Recipes ===
# Run all tests and print code coverage value
test:
@. {{ logger }} && log_info "Run all tests"
{{ go }} test $({{ go }} list ./... | grep -Ev 'examples/') -coverprofile=coverage.txt
@. {{ logger }} && log_info "Total Coverage"
{{ go }} tool cover -func=coverage.txt | grep total | awk '{print $3}'
# Clean go tests cache and run all tests
test-force:
@. {{ logger }} && log_info "Clean go tests cache and run all tests"
{{ go }} clean -testcache
just test
# Run all tests and generate coverage report.
test-coverage:
@. {{ logger }} && log_info "Run all tests and generate coverage report"
{{ go }} test -count=1 -timeout 30s $({{ go }} list ./... | grep -Ev 'examples/') -covermode=atomic -coverprofile=coverage.txt
# Run all tests with race detector
test-race:
@. {{ logger }} && log_info "Running tests with race detector"
{{ go }} test -race $({{ go }} list ./... | grep -Ev 'examples/')
# Run modernize, lint, and tests
build: modernize lint test-force
# === Templ ===
# Run templ fmt in a given directory
[private]
templ-fmt dir=".":
@. {{ logger }} && log_info "Running templ fmt in {{ dir }}"
cd {{ dir }} && templ fmt .
# Run templ generate in a given directory
[private]
templ-gen dir=".":
@. {{ logger }} && log_info "Running templ generate in {{ dir }}"
cd {{ dir }} && templ generate
# === Demos ===
demos_pages_dir := "_demos/pages"
# Run templ fmt and templ generate commands on the demos
templ: (templ-fmt demos_pages_dir) (templ-gen demos_pages_dir)
# Run the demos server
dev: templ
@. {{ logger }} && log_info "Running the demo app"
{{ go }} run ./_demos
# === Utilities ===
# Update dependencies
deps-update:
@. {{ logger }} && log_info "Running go update deps"
{{ go }} get -u ./...
{{ go }} mod tidy