forked from tinkerbell/tink
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathci-checks.sh
More file actions
executable file
·39 lines (29 loc) · 834 Bytes
/
ci-checks.sh
File metadata and controls
executable file
·39 lines (29 loc) · 834 Bytes
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
#!/usr/bin/env nix-shell
#!nix-shell -i bash
# shellcheck shell=bash
set -eux
failed=0
# spell-checks only language files to avoid spell-checking checksums
if ! git ls-files '*.sh' '*.go' '*.md' | xargs codespell -q 3 -I .codespell-whitelist; then
failed=1
fi
# --check doesn't show what line number fails, so write the result to disk for the diff to catch
if ! git ls-files '*.yaml' '*.yml' '*.json' '*.md' | xargs prettier --list-different --write; then
failed=1
fi
if ! git ls-files '*.sh' | xargs shfmt -l -d; then
failed=1
fi
if ! git ls-files '*.sh' | xargs shellcheck; then
failed=1
fi
if ! nixfmt shell.nix; then
failed=1
fi
if ! git ls-files '*.go' | xargs -I% sh -c 'sed -i "/^import (/,/^)/ { /^\s*$/ d }" % && gofumpt -w -s %'; then
failed=1
fi
if ! git diff | (! grep .); then
failed=1
fi
exit "$failed"