-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
138 lines (110 loc) · 3.11 KB
/
Makefile
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
PACKAGE = adequate
# vet
vet\:check: # vet code syntax [synonym: check]
@cargo check --all --verbose
.PHONY: vet\:check
check: vet\:check
.PHONY: check
vet\:format: # vet format without changes [synonym: vet:fmt, format, fmt]
@cargo fmt --all -- --check
.PHONY: vet\:format
format: vet\:format
.PHONY: format
fmt: vet\:format
.PHONY: fmt
vet\:lint: # vet coding style using clippy [synonym: lint]
@cargo clippy --all-targets
.PHONY: vet\:lint
lint: vet\:lint
.PHONY: lint
vet\:all: vet\:check vet\:format vet\:lint # Check code using all vet targets
.PHONY: vet\:all
vet: vet\:check # Alias for vet:check
.PHONY: vet
# test
test\:doc: # Run only doc tests
@cargo test --doc
.PHONY: test\:doc
test\:lib: # Run unit tests
@cargo test --tests
.PHONY: test\:lib
test: test\:lib # Alias for test:lib
.PHONY: test
test\:all: test\:doc test\:lib # Run all tests
.PHONY: test\:all
# coverage
coverage\:lib: # Generate a coverage report of tests for library [synonym: cov:lib]
@set -uo pipefail; \
dir="$$(pwd)"; \
target_dir="$${dir}/target/coverage/lib"; \
cargo test --lib --no-run --target-dir=$${target_dir}; \
result=($${target_dir}/index.js*); \
if [ -f $${result}[0] ]; then \
rm "$${target_dir}/index.js*"; \
fi; \
file=($$target_dir/debug/deps/$(PACKAGE)-*); \
kcov --verify --include-path=$$dir/src $$target_dir $${file[0]}; \
grep 'index.html' $$target_dir/index.js* | \
grep --only-matching --extended-regexp \
'covered":"([0-9]*\.[0-9]*|[0-9]*)"' | sed -E 's/[a-z\:"]*//g'
.PHONY: coverage\:lib
cov\:lib: coverage\:lib
.PHONY: cov\:lib
coverage: coverage\:lib # Alias for coverage:lib [synonym: cov]
.PHONY: coverage
cov: coverage
.PHONY: cov
# documentation
document: # Generate documentation files [synonym: doc]
cargo doc --no-deps --package $(PACKAGE)
.PHONY: document
doc: document
.PHONY: doc
# }}}
# build
build\:debug: # Build in debug mode
cargo build
.PHONY: build\:debug
build: build\:debug # Alias for build:debug
.PHONY: build
build\:release: # Create release build
cargo build --release
.PHONY: build\:release
# utility
clean: # Clean up
@cargo clean
.PHONY: clean
# NOTE:
# This depends on environment variables from .env.ci, and requires
# the gitlab-runner command.
runner-%: # Run a CI job on local (on Docker)
@set -uo pipefail; \
job=$(subst runner-,,$@); \
opt=""; \
while read line; do \
opt+=" --env $$(echo $$line | sed -E 's/^export //')"; \
done < .env.ci; \
gitlab-runner exec docker \
--executor docker \
--cache-dir /cache \
--docker-volumes $$(pwd)/.cache/gitlab-runner:/cache \
--docker-volumes /var/run/docker.sock:/var/run/docker.sock \
$${opt} $${job}
.PHONY: runner
package: # Create package
@cargo package
.PHONY: package
publish: # Publish package
@cargo publish
.PHONY: publish
help: # Display this message
@grep --extended-regexp '^[0-9a-z\:\\\%]+: ' $(firstword $(MAKEFILE_LIST)) | \
grep --extended-regexp ' # ' | \
sed --expression='s/\([a-z0-9\-\:\ ]*\): \([a-z0-9\-\:\ ]*\) #/\1: #/g' | \
tr --delete \\\\ | \
awk 'BEGIN {FS = ": # "}; \
{printf "\033[38;05;222m%-14s\033[0m %s\n", $$1, $$2}' | \
sort
.PHONY: help
.DEFAULT_GOAL = test
default: test