forked from coreos/butane
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest
More file actions
executable file
·54 lines (45 loc) · 1.53 KB
/
test
File metadata and controls
executable file
·54 lines (45 loc) · 1.53 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
#!/bin/bash
set -euo pipefail
SRC=$(find . -name '*.go' -not -path "./vendor/*")
echo "checking gofmt"
res=$(gofmt -d $SRC)
if [ -n "$res" ]; then
echo "$res"
exit 1
fi
echo "checking govet"
PKG_VET=$(go list ./... | grep --invert-match vendor)
# tests widely use unkeyed fields in composite literals. golangci-lint
# in CI does a more nuanced check.
go vet -composites=false $PKG_VET
source ./build
echo "Running tests"
go test ./... -cover
if [ "$(go env GOOS)" = linux ]; then
echo "Checking docs"
shopt -s nullglob
mkdir tmpdocs
trap 'rm -r tmpdocs' EXIT
# Create files-dir contents expected by configs
mkdir -p tmpdocs/files-dir/tree
touch tmpdocs/files-dir/{config.ign,ca.pem,file,file-epilogue,local-file3}
for doc in docs/*md
do
echo "Checking $doc"
# split each doc into a bunch of tmpfiles then run butane on them
sed -n '/^<!-- butane-config -->/,/^```$/ p' < ${doc} \
| csplit - '/<!-- butane-config -->/' '{*}' -z --prefix "tmpdocs/config_$(basename ${doc%.*})_" -q
for i in tmpdocs/config_*
do
echo "Checking $i"
cat "$i" | tail -n +3 | head -n -1 \
| ${BIN_PATH}/${NAME} --strict --files-dir tmpdocs/files-dir > /dev/null \
|| (cat -n "$i" && false)
done
rm -f tmpdocs/config_*
done
else
# Avoid dealing with presence/behavior of csplit
echo "skipping docs check on non-Linux"
fi
echo ok