-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
175 lines (157 loc) · 4.31 KB
/
Makefile
File metadata and controls
175 lines (157 loc) · 4.31 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
171
172
173
174
175
.DEFAULT_GOAL := help
## Show this help
help:
@awk -f build/makefile-doc.awk $(MAKEFILE_LIST)
##@ Housekeeping
## Nukes the zig-out dir
clean-zig-out:
rm -rf zig-out
## Nukes the local zig cache dir if its > 16gb
clean-zig-cache:
@if [ -d .zig-cache ]; then \
size_kb=$$(du -s .zig-cache | cut -f1); \
limit_kb=$$((16 * 1024 * 1024)); \
if [ $$size_kb -gt $$limit_kb ]; then \
echo "removing .zig-cache (size: $$size_kb KB > $$limit_kb KB)"; \
rm -rf .zig-cache; \
fi; \
fi
##@ Development
## Format all zig files
fmt:
zig fmt ./
## Lint all zig files
lint:
zig build lint
##@ Testing
## Run unit tests
test: fmt
zig build test \
-Doptimize=Debug \
--summary all
## Run integration tests
test-integration: fmt
zig build test \
-Doptimize=Debug \
-Dintegration-tests=true \
--summary all
## Run functional tests
test-functional: fmt
zig build test \
-Doptimize=Debug \
-Dfunctional-tests=true \
--summary all
## Run functional tests (w/ limited ci platforms);
## ensures TERM set, since this is normally unset in GH actions
test-functional-ci: fmt
TERM=screen-256color zig build test \
-Doptimize=Debug \
-Dfunctional-tests=true \
-Dci-functional-tests=true \
--summary all
##@ Testing Coverage
## Run integration tests plus coverage (goes to zig-out/cover)
test-coverage: fmt
rm -rf zig-out/cover || true
zig build test \
-Dintegration-tests=true \
-Dtest-coverage=true \
--summary all
## Open the generated coverage report
open-coverage:
open zig-out/cover/index.html
##@ Test Environment
## Runs the clab functional testing topo; uses the clab launcher to run nicely on darwin
run-clab:
rm -r .clab/* || true
docker network rm clab || true
docker network create \
--driver bridge \
--subnet=172.20.20.0/24 \
--gateway=172.20.20.1 \
--ipv6 \
--subnet=2001:172:20:20::/64 \
--gateway=2001:172:20:20::1 \
--opt com.docker.network.driver.mtu=65535 \
--label containerlab \
clab
docker run \
-d \
--rm \
--name clab-launcher \
--platform=linux/arm64 \
--privileged \
--pid=host \
--stop-signal=SIGINT \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /run/netns:/run/netns \
-v "$$(pwd):$$(pwd)" \
-e "WORKDIR=$$(pwd)/.clab" \
-e "HOST_ARCH=$$(uname -m)" \
ghcr.io/scrapli/scrapli_clab/launcher:0.0.7
## Runs the clab functional testing topo with the ci specific topology - omits ceos
run-clab-ci:
mkdir .clab || true
rm -r .clab/* || true
docker network rm clab || true
docker network create \
--driver bridge \
--subnet=172.20.20.0/24 \
--gateway=172.20.20.1 \
--ipv6 \
--subnet=2001:172:20:20::/64 \
--gateway=2001:172:20:20::1 \
--opt com.docker.network.driver.mtu=65535 \
--label containerlab \
clab
docker run \
-d \
--rm \
--name clab-launcher \
--privileged \
--pid=host \
--stop-signal=SIGINT \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /run/netns:/run/netns \
-v "$$(pwd):$$(pwd)" \
-e "WORKDIR=$$(pwd)/.clab" \
-e "HOST_ARCH=$$(uname -m)" \
-e "CLAB_TOPO=topo.ci.$$(uname -m).yaml" \
ghcr.io/scrapli/scrapli_clab/launcher:0.0.7
##@ Build
## Build the shared object for the local system w/ release optimization
build: fmt clean-zig-cache
zig build ffi \
-Doptimize=ReleaseSafe \
-freference-trace=4 \
-Ddependency-linkage=static \
--summary all
## Build all the shared objects w/ release optimization
build-release: fmt clean-zig-out clean-zig-cache
zig build ffi \
-Doptimize=ReleaseSafe \
-freference-trace=4 \
-Ddependency-linkage=static \
-Dall-targets=true \
--summary all
find zig-out -type f \
\( -name 'libscrapli.*.dylib' -o -name 'libscrapli.so.*' \) \
-exec sha256sum {} + \
> zig-out/checksums.txt
## Build the example binaries, uses Debug build so you get leak checking
build-examples: fmt clean-zig-cache
zig build examples \
-Doptimize=Debug \
-freference-trace=4 \
-Ddependency-linkage=static \
--summary all
## Build the "main" binary in repo root, uses Debug build so you get leak checking
build-main: fmt clean-zig-cache
zig build main \
-Doptimize=Debug \
-freference-trace=4 \
-Ddependency-linkage=static \
--summary all
## Build and run the "main" binary in repo root
run-main: fmt build-main
./zig-out/bin/scrapli