Update building stuff
- Add a Makefile with common targets (binary, test, validate, ..) - Use docker to build it (isolated) And update circleci to work with the new Makefile.. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
fd835e1fcd
commit
0ea80582d2
14 changed files with 278 additions and 10 deletions
56
script/test-unit
Executable file
56
script/test-unit
Executable file
|
@ -0,0 +1,56 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
if ! test -e gen.go; then
|
||||
echo >&2 'error: generate must be run before binary'
|
||||
false
|
||||
fi
|
||||
|
||||
RED=$'\033[31m'
|
||||
GREEN=$'\033[32m'
|
||||
TEXTRESET=$'\033[0m' # reset the foreground colour
|
||||
|
||||
# This helper function walks the current directory looking for directories
|
||||
# holding certain files ($1 parameter), and prints their paths on standard
|
||||
# output, one per line.
|
||||
find_dirs() {
|
||||
find . -not \( \
|
||||
\( \
|
||||
-path './integration/*' \
|
||||
-o -path './.git/*' \
|
||||
\) \
|
||||
-prune \
|
||||
\) -name "$1" -print0 | xargs -0n1 dirname | sort -u
|
||||
}
|
||||
|
||||
TESTFLAGS="-cover -coverprofile=cover.out ${TESTFLAGS}"
|
||||
|
||||
if [ -z "$TESTDIRS" ]; then
|
||||
TESTDIRS=$(find_dirs '*_test.go')
|
||||
fi
|
||||
|
||||
TESTS_FAILED=()
|
||||
|
||||
for dir in $TESTDIRS; do
|
||||
echo '+ go test' $TESTFLAGS "${dir}"
|
||||
go test ${TESTFLAGS} ${dir}
|
||||
if [ $? != 0 ]; then
|
||||
TESTS_FAILED+=("$dir")
|
||||
echo
|
||||
echo "${RED}Tests failed: $dir${TEXTRESET}"
|
||||
sleep 1 # give it a second, so observers watching can take note
|
||||
fi
|
||||
done
|
||||
echo
|
||||
|
||||
# if some tests fail, we want the bundlescript to fail, but we want to
|
||||
# try running ALL the tests first, hence TESTS_FAILED
|
||||
if [ "${#TESTS_FAILED[@]}" -gt 0 ]; then
|
||||
echo "${RED}Test failures in: ${TESTS_FAILED[@]}${TEXTRESET}"
|
||||
echo
|
||||
false
|
||||
else
|
||||
echo "${GREEN}Test success${TEXTRESET}"
|
||||
echo
|
||||
true
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue