-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
33 lines (28 loc) · 957 Bytes
/
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
NUM_OF_JOBS := 1
SPEC_FILES := $(shell find spec -name '*_spec.cr' -print | sort -n)
SPEC_TARGETS := $(shell seq -s " " -f "spec/%g" $(NUM_OF_JOBS))
SPEC_COMPLETION_FILES := $(shell find spec_completion -name '*_spec.cr' -print | sort -n)
.PHONY: spec
spec:
$(MAKE) spec/1
$(MAKE) spec_completion
spec/%:
crystal -v
crystal eval 'array = "$(SPEC_FILES)".split(" "); puts array.map_with_index{|e,i| {index: i, value: e}}.group_by{|e| e[:index] % ($(NUM_OF_JOBS))}[$* - 1].map(&.[](:value)).join("\n")' \
| xargs -n 1 -I{} /bin/sh -c 'echo "\n\n=========================\n{}"; crystal spec {}'
.PHONY: spec_completion
spec_completion: $(SPEC_COMPLETION_FILES)
.PHONY: $(SPEC_COMPLETION_FILES)
$(SPEC_COMPLETION_FILES):
ifeq ($(GITHUB_ACTIONS),true)
crystal -v
crystal spec $@
else
docker run \
--rm \
$(DOCKER_OPTIONS) \
-v $(PWD):/workdir \
-w /workdir \
crystallang/crystal:latest \
/bin/sh -c "crystal -v; crystal spec $@"
endif