-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathtest.sh
executable file
·48 lines (40 loc) · 1.04 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
#!/bin/bash
# export PS4='$(read time junk < /proc/$$/schedstat; echo "@@@ $time @@@ " )'
# set -x
errors=0
log_file=log.log
GREEN="\e[32m"
RED="\e[31m"
WHITE="\e[0m"
test ()
{
tmp=$({ $@ 2>&1; echo $? > /tmp/PIPESTATUS; } | tee $log_file)
rt=$(cat /tmp/PIPESTATUS)
if [[ $rt -ne 0 ]]; then
echo -e "[${RED}X${WHITE}] " "$@" ": " "$rt"
echo "$tmp"
((errors += 1))
return
fi
echo -e "[${GREEN}V${WHITE}] " "$@"
}
test docker-compose config -q
# testing docker-compose.yml files
file=$(mktemp)
docker-compose config > "$file" 2>$log_file
test diff test_config.yml "$file"
mv "$file" test_config.yml
# testing environment variables.
grep '${' ./**/docker-compose.*.yml \
| sed "s/.*\${\(.*\)}.*/\1/g" \
| cut -d":" -f 1 \
| sort -u \
| xargs -I % echo "%=" \
| sort \
>> .env.generated
test diff .env.default .env.generated
mv .env.generated .env.default
git diff | tee patch.patch
[ $errors -gt 0 ] && echo "There were $errors errors found" && exit 1
exit 0
# vim: set expandtab