-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathMakefile
More file actions
171 lines (151 loc) · 4.39 KB
/
Makefile
File metadata and controls
171 lines (151 loc) · 4.39 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File generated by cdo from CONTRIBUTING.md; DO NOT EDIT.
SHELL=bash
.SHELLFLAGS=-e -o pipefail -c
.PHONY: __help__
__help__:
@echo 'Usage: make [target]'
@echo ''
@echo 'Targets:'
@echo ' all Run all'
@echo ' build Build custom k6 with extension'
@echo ' clean Clean the working directory'
@echo ' cli Build the k6-web-dashboard CLI'
@echo ' coverage View the test coverage report'
@echo ' doc Update documentation'
@echo ' exif Update image metadata'
@echo ' format Format the go source codes'
@echo ' gen Generate code'
@echo ' lint Run the linter'
@echo ' makefile Generate the Makefile'
@echo ' replay Replay test from recorded JSON file'
@echo ' run Run test script'
@echo ' schema Convert the schema to JSON'
@echo ' security Run security and vulnerability checks'
@echo ' test Run the tests'
@echo ' testdata Record test results for testing'
# Run all
.PHONY: all
all: clean lint security test build cli doc makefile
# Build custom k6 with extension
.PHONY: build
build:
@(\
xk6 build --with github.com/grafana/xk6-dashboard=.;\
)
# Clean the working directory
.PHONY: clean
clean:
@(\
rm -rf ./k6 ./coverage.txt ./build ./dashboard/assets/node_modules ./bun.lockb;\
)
# Build the k6-web-dashboard CLI
.PHONY: cli
cli:
@(\
goreleaser build --snapshot --clean --single-target;\
)
# View the test coverage report
.PHONY: coverage
coverage: test
@(\
go tool cover -html=coverage.txt;\
)
# Update documentation
.PHONY: doc
doc:
@(\
mdcode update;\
# See tools/docsme/main.txt;\
# go run -tags docsme ./tools/docsme -r cli -o cmd/k6-web-dashboard/README.md;\
)
# Update image metadata
.PHONY: exif
exif:
@(\
exiftool -all= -overwrite_original -ext png screenshot;\
exiftool -ext png -overwrite_original -XMP:Subject="k6 dashboard xk6" -Title="k6 dashboard screenshot" -Description="Screenshot of xk6-dashboard extension that enables creating web based metrics dashboard for k6." -Author="Raintank, Inc. dba Grafana Labs" screenshot;\
exiftool -all= -overwrite_original -ext png .github;\
exiftool -ext png -overwrite_original -XMP:Subject+="k6 dashboard xk6" -Title="k6 dashboard screenshot" -Description="Screenshot of xk6-dashboard extension that enables creating web based metrics dashboard for k6." -Author="Raintank, Inc. dba Grafana Labs" .github;\
exiftool -all= -overwrite_original -ext pdf screenshot;\
exiftool -ext pdf -overwrite_original -Subject="k6 dashboard report" -Title="k6 dashboard report" -Description="Example report of xk6-dashboard extension that enables creating web based metrics dashboard for k6." -Author="Raintank, Inc. dba Grafana Labs" screenshot;\
)
# Format the go source codes
.PHONY: format
format:
@(\
go fmt ./...;\
)
# Generate code
.PHONY: gen
gen:
@(\
go generate ./...;\
yarn --silent --cwd dashboard/assets install;\
yarn --silent --cwd dashboard/assets build;\
)
# Run the linter
.PHONY: lint
lint:
@(\
golangci-lint run ./...;\
)
# Generate the Makefile
.PHONY: makefile
makefile:
@(\
cdo --makefile Makefile;\
)
# Replay test from recorded JSON file
.PHONY: replay
replay:
@(\
SLUG=$${1//\//-};\
RECORD="build/$${SLUG}-record.ndjson.gz";\
go run ./cmd/k6-web-dashboard replay $$RECORD;\
)
# Run test script
.PHONY: run
run:
@(\
SLUG=$${1//\//-};\
REPORT="build/$${SLUG}-report.html";\
RECORD="build/$${SLUG}-record.ndjson.gz";\
RESULT="build/$${SLUG}-result.json.gz";\
xk6 run -- $${1:-} \;\
--quiet --no-summary --no-usage-report \;\
--out "dashboard=export=$${REPORT}&record=$${RECORD}" \;\
--out json="$${RESULT}";\
)
# Convert the schema to JSON
.PHONY: schema
schema:
@(\
yq -o=json -P docs/dashboard.schema.yaml > docs/dashboard.schema.json;\
)
# Run security and vulnerability checks
.PHONY: security
security:
@(\
gosec ./...;\
govulncheck ./...;\
)
# Run the tests
.PHONY: test
test:
@(\
go test -count 1 -p 4 -race -coverprofile=coverage.txt -timeout 60s ./...;\
)
# Record test results for testing
.PHONY: testdata
testdata:
@(\
JSON=dashboard/testdata/result.json;\
JSON_GZ="$${JSON}.gz";\
NDJSON=dashboard/testdata/result.ndjson;\
NDJSON_GZ="$${NDJSON}.gz";\
xk6 run -- scripts/test.js \;\
--quiet --no-summary --no-usage-report \;\
--out json=$$JSON --out json=$$JSON_GZ \;\
--out "dashboard=port=-1&period=2s&record=$${NDJSON}" \;\
--out "dashboard=port=-1&period=2s&record=$${NDJSON_GZ}" \;\
)