-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathJustfile
More file actions
112 lines (89 loc) · 3.35 KB
/
Justfile
File metadata and controls
112 lines (89 loc) · 3.35 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
HOME := "$HOME"
HS_FILES := "$(git ls-files '*.hs' '*.hs-boot')"
CHANGED_HS_FILES := '$(git diff --diff-filter=d --name-only `git merge-base HEAD origin/main` | grep ".*\.hs$")'
NIX_FILES := "$(git ls-files '*.nix' 'nix/*.nix')"
SHELL_FILES := "$(git ls-files '*.sh')"
CHANGED_SHELL_FILES := '$(git diff --diff-filter=d --name-only `git merge-base HEAD origin/main` | grep ".*\.sh$$")'
NIX_FMT := "nix fmt"
ORMOLU := "ormolu"
ORMOLU_VERSION := "$(" + ORMOLU + " --version | awk 'NR==1 { print $2 }')"
ORMOLU_CHECK_VERSION := "0.7.2.0"
# Run Shellcheck with access to any file that's sourced, relative to the script's own directory
SHELLCHECK := "$(shellcheck --external-sources --source-path=SCRIPTDIR)"
#-------------------------------------------------------------------------------
## Cabal
# Run the backend service
run:
cabal run exe:server
# Build all haskell packages.
build:
cabal build all --enable-tests --enable-benchmarks
# Delete all build artifacts.
clean:
cabal clean
# Run all test suites.
test:
cabal test all --test-show-details=direct --test-option=--format=specdoc
# Build docs
haddock:
cabal haddock
#-------------------------------------------------------------------------------
## Formatting
check-ormolu-version:
@if ! [ "{{ORMOLU_VERSION}}" = "{{ORMOLU_CHECK_VERSION}}" ]; then \
echo "WARNING: ormolu version mismatch, expected {{ORMOLU_CHECK_VERSION}} but got {{ORMOLU_VERSION}}"; \
fi
# Auto-format Haskell source code using ormolu.
format-hs: check-ormolu-version
@echo running {{ORMOLU}} --mode inplace
@{{ORMOLU}} --mode inplace {{HS_FILES}}
# Auto-format Haskell source code using ormolu (changed files only).
format-hs-changed:
@echo running {{ORMOLU}} --mode inplace
@if [ -n "{{CHANGED_HS_FILES}}" ]; then \
{{ORMOLU}} --mode inplace {{CHANGED_HS_FILES}}; \
fi
# Check Haskell source code formatting using ormolu.
check-format-hs: check-ormolu-version
@echo running {{ORMOLU}} --mode check
@{{ORMOLU}} --mode check {{HS_FILES}}
# Check Haskell source code formatting using ormolu (changed-files-only).
check-format-hs-changed: check-ormolu-version
@echo running {{ORMOLU}} --mode check
@if [ -n "{{CHANGED_HS_FILES}}" ]; then \
{{ORMOLU}} --mode check {{CHANGED_HS_FILES}}; \
fi
# 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
# 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
# Run all formatters.
format: format-hs format-nix
# Run all formatters on changed files.
format-changed: format-hs-changed format-nix
# Check formatting on all files.
check-format: check-format-hs check-format-nix
# Check formatting on all changed files.
check-format-changed: check-format-hs-changed check-format-nix
# Lint shell scripts using `shellcheck`.
lint-shell:
@echo running shellcheck
@{{SHELLCHECK}} {{SHELL_FILES}}
# 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