-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
73 lines (61 loc) · 1.86 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
NIX_FILES = $(shell git ls-files '*.nix' 'nix/*.nix')
SHELL_FILES = $(shell git ls-files '*.sh')
CHANGED_SHELL_FILES = $(shell git diff --diff-filter=d --name-only `git merge-base HEAD origin/main` | grep '.*\.sh$$')
NIX_FMT = nixpkgs-fmt
# Run Shellcheck with access to any file that's sourced, relative to the script's own directory
SHELLCHECK = shellcheck --external-sources --source-path=SCRIPTDIR
.PHONY: format-ml
## format-ml: auto-format Ocaml source code using `ocp-indent`
format-ml:
@echo "running ocp-indent"
@fd --glob '*.ml' --exec ocp-indent --inplace {}
.PHONY: format-nix
## format-nix: auto-format Nix source code using `nixpkgs-fmt`
format-nix:
@if command -v $(NIX_FMT) > /dev/null; then \
echo "running $(NIX_FMT)"; \
$(NIX_FMT) $(NIX_FILES); \
else \
echo "$(NIX_FMT) is not installed; skipping"; \
fi
.PHONY: format
## format: apply all auto-formatting commands
format: format-ml format-nix
.PHONY: check-format-nix
## check-format-nix: check Nix source code using `nixpkgs-fmt`
check-format-nix:
@if command -v $(NIX_FMT) > /dev/null; then \
echo "running $(NIX_FMT) --check"; \
$(NIX_FMT) --check $(NIX_FILES); \
else \
echo "$(NIX_FMT) is not installed; skipping"; \
fi
.PHONY: lint-shell
## lint-shell: lint shell scripts using `shellcheck`
lint-shell:
@echo running shellcheck
@$(SHELLCHECK) $(SHELL_FILES)
.PHONY: lint-shell-changed
## lint-shell-changed: lint shell scripts using `shellcheck` (changed files only)
lint-shell-changed:
@echo running shellcheck
@if [ -n "$(CHANGED_SHELL_FILES)" ]; then \
$(SHELLCHECK) $(CHANGED_SHELL_FILES); \
fi
.PHONY: build
## build: build polytt
build:
dune build
.PHONY: clean
## clean: erase build artifacts
clean:
dune clean
.PHONY: test
## test: run polytt test suite
test:
dune clean
dune test
.PHONY: snapshot
## snapshot: update golden testing snapshot
snapshot:
dune runtest; dune promote