forked from matoski/services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·58 lines (48 loc) · 1.15 KB
/
test.sh
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
#!/bin/bash
# Ensure monorepo conforms to our requirements
#
# All services should include a README.md
# All services should include a main.go
# All services should include a go.mod
# No binaries should be present anywhere
set -e
function fatal {
PWD=`pwd`
echo $@ && exit 1
}
function checkFiles() {
# should exist
# only do this if directory contains main.go
if [ -f main.go ]; then
for file in README.md go.mod; do
if [ ! -f $file ]; then
fatal "$1 does not include $file"
fi
done
fi
# should NOT exist e.g binaries
for file in ${1} ${1}-srv; do
if [ -f $file ] && ! grep -Fxq $file .gitignore; then
fatal "$1 should not include $file"
fi
done
}
# Check the service repos
ls | while read service; do
if [ ! -d $service ]; then
continue
fi
echo "Checking $service"
# push into service repo
pushd $service &> /dev/null
# check the files
checkFiles $service
# exit the service
popd &>/dev/null
done
# Check for outlier binaries
find . -type f -not -name "*.js*" -size +2M | grep -v \.git | while read file; do
if ! grep $(basename -- $file) $(dirname -- $file)/.gitignore; then
fatal "$file is larger than 2M"
fi
done