2017-03-01 08:55:27 -06:00
|
|
|
#! /bin/bash
|
|
|
|
|
2017-10-10 05:02:39 -05:00
|
|
|
# The entry point for travis tests
|
2017-11-14 08:58:27 -06:00
|
|
|
#
|
|
|
|
# TEST_SUITE env var can be set to "lint", "unit-test" or "integ-test", in
|
|
|
|
# which case only the linting, unit tests or integration tests will be run
|
|
|
|
# respectively. If not specified or null all tests are run.
|
2017-10-10 05:02:39 -05:00
|
|
|
|
2017-03-01 08:55:27 -06:00
|
|
|
set -eu
|
|
|
|
|
2017-10-10 05:02:39 -05:00
|
|
|
# Tune the GC to use more memory to reduce the number of garbage collections
|
|
|
|
export GOGC=400
|
|
|
|
export DENDRITE_LINT_DISABLE_GC=1
|
|
|
|
|
2019-05-21 15:56:55 -05:00
|
|
|
export GO111MODULE=on
|
2017-11-14 08:58:27 -06:00
|
|
|
|
2017-12-19 07:45:14 -06:00
|
|
|
# starts a travis fold section. The first argument is the name of the fold
|
|
|
|
# section (which appears on the RHS) and may contain no spaces. Remaining
|
|
|
|
# arguments are echoed in yellow on the LHS as the header line of the fold
|
|
|
|
# section.
|
|
|
|
travis_sections=()
|
|
|
|
function travis_start {
|
|
|
|
name="$1"
|
|
|
|
shift
|
|
|
|
echo -en "travis_fold:start:$name\r"
|
|
|
|
travis_sections+=($name)
|
|
|
|
|
|
|
|
# yellow/bold
|
|
|
|
echo -en "\e[33;1m"
|
|
|
|
echo "$@"
|
|
|
|
# normal
|
|
|
|
echo -en "\e[0m"
|
|
|
|
}
|
|
|
|
|
|
|
|
# ends a travis fold section
|
|
|
|
function travis_end {
|
|
|
|
name=${travis_sections[-1]}
|
|
|
|
unset 'travis_sections[-1]'
|
|
|
|
echo -en "travis_fold:end:$name\r"
|
|
|
|
}
|
|
|
|
|
2017-12-19 07:56:41 -06:00
|
|
|
function kill_kafka {
|
|
|
|
echo "killing kafka"
|
|
|
|
# sometimes kafka doesn't die on a SIGTERM so we SIGKILL it.
|
|
|
|
killall -9 -v java
|
|
|
|
}
|
|
|
|
|
2017-11-14 08:58:27 -06:00
|
|
|
if [ "${TEST_SUITE:-lint}" == "lint" ]; then
|
|
|
|
./scripts/find-lint.sh
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${TEST_SUITE:-unit-test}" == "unit-test" ]; then
|
2019-05-21 15:56:55 -05:00
|
|
|
go test ./...
|
2017-11-14 08:58:27 -06:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${TEST_SUITE:-integ-test}" == "integ-test" ]; then
|
2019-05-21 15:56:55 -05:00
|
|
|
travis_start go-build "Building dendrite and integ tests"
|
|
|
|
go install ./cmd/...
|
2017-12-19 07:45:14 -06:00
|
|
|
travis_end
|
|
|
|
|
2017-11-14 08:58:27 -06:00
|
|
|
# Check that all the packages can build.
|
|
|
|
# When `go build` is given multiple packages it won't output anything, and just
|
2019-05-21 15:56:55 -05:00
|
|
|
# checks that everything builds.
|
|
|
|
go build ./cmd/...
|
2017-11-14 08:58:27 -06:00
|
|
|
|
|
|
|
# Create necessary certificates and keys to run dendrite
|
2017-12-19 07:45:14 -06:00
|
|
|
travis_start certs "Building SSL certs"
|
|
|
|
openssl req -x509 -newkey rsa:512 -keyout server.key -out server.crt -days 365 -nodes -subj /CN=localhost
|
|
|
|
travis_end
|
|
|
|
|
|
|
|
travis_start kafka "Installing kafka"
|
|
|
|
./scripts/install-local-kafka.sh
|
|
|
|
travis_end
|
2017-11-14 08:58:27 -06:00
|
|
|
|
2017-12-19 07:56:41 -06:00
|
|
|
# make sure we kill off zookeeper/kafka on exit, because it stops the
|
|
|
|
# travis container being cleaned up (cf
|
|
|
|
# https://github.com/travis-ci/travis-ci/issues/8082)
|
|
|
|
trap kill_kafka EXIT
|
|
|
|
|
2017-11-14 08:58:27 -06:00
|
|
|
# Run the integration tests
|
2017-12-19 07:45:14 -06:00
|
|
|
for i in roomserver syncserver mediaapi; do
|
|
|
|
travis_start "$i-integration-tests" "Running integration tests for $i"
|
2019-05-21 15:56:55 -05:00
|
|
|
$i-integration-tests
|
2017-12-19 07:45:14 -06:00
|
|
|
travis_end
|
|
|
|
done
|
2017-11-14 08:58:27 -06:00
|
|
|
fi
|