mirror of
https://github.com/matrix-org/dendrite
synced 2024-12-12 14:22:47 +00:00
b5bfff47d2
Some systems (like nixos) don't have bash living at `/bin/bash` so using `/usr/bin/env bash` we can make these scripts universal. ### Pull Request Checklist <!-- Please read docs/CONTRIBUTING.md before submitting your pull request --> * [X] I have added added tests for PR _or_ I have justified why this PR doesn't need tests. * [x] Pull request includes a [sign off](https://github.com/matrix-org/dendrite/blob/main/docs/CONTRIBUTING.md#sign-off) Signed-off-by: `Dov Alperin <git@dov.dev>` Signed-off-by: `Dov Alperin <git@dov.dev>`
63 lines
1.9 KiB
Bash
Executable file
63 lines
1.9 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
#
|
|
# Runs SyTest either from Docker Hub, or from ../sytest. If it's run
|
|
# locally, the Docker image is rebuilt first.
|
|
#
|
|
# Logs are stored in ../sytestout/logs.
|
|
|
|
set -e
|
|
set -o pipefail
|
|
|
|
main() {
|
|
local tag=buster
|
|
local base_image=debian:$tag
|
|
local runargs=()
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
if [ -d ../sytest ]; then
|
|
local tmpdir
|
|
tmpdir="$(mktemp -d -t run-systest.XXXXXXXXXX)"
|
|
trap "rm -r '$tmpdir'" EXIT
|
|
|
|
if [ -z "$DISABLE_BUILDING_SYTEST" ]; then
|
|
echo "Re-building ../sytest Docker images..."
|
|
|
|
local status
|
|
(
|
|
cd ../sytest
|
|
|
|
docker build -f docker/base.Dockerfile --build-arg BASE_IMAGE="$base_image" --tag matrixdotorg/sytest:"$tag" .
|
|
docker build -f docker/dendrite.Dockerfile --build-arg SYTEST_IMAGE_TAG="$tag" --tag matrixdotorg/sytest-dendrite:latest .
|
|
) &>"$tmpdir/buildlog" || status=$?
|
|
if (( status != 0 )); then
|
|
# Docker is very verbose, and we don't really care about
|
|
# building SyTest. So we accumulate and only output on
|
|
# failure.
|
|
cat "$tmpdir/buildlog" >&2
|
|
return $status
|
|
fi
|
|
fi
|
|
|
|
runargs+=( -v "$PWD/../sytest:/sytest:ro" )
|
|
fi
|
|
if [ -n "$SYTEST_POSTGRES" ]; then
|
|
runargs+=( -e POSTGRES=1 )
|
|
fi
|
|
|
|
local sytestout=$PWD/../sytestout
|
|
mkdir -p "$sytestout"/{logs,cache/go-build,cache/go-pkg}
|
|
docker run \
|
|
--rm \
|
|
--name "sytest-dendrite-${LOGNAME}" \
|
|
-e LOGS_USER=$(id -u) \
|
|
-e LOGS_GROUP=$(id -g) \
|
|
-v "$PWD:/src/:ro" \
|
|
-v "$sytestout/logs:/logs/" \
|
|
-v "$sytestout/cache/go-build:/root/.cache/go-build" \
|
|
-v "$sytestout/cache/go-pkg:/gopath/pkg" \
|
|
"${runargs[@]}" \
|
|
matrixdotorg/sytest-dendrite:latest "$@"
|
|
}
|
|
|
|
main "$@"
|