Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move scripts which aren't in docker out of docker #752

Merged
merged 1 commit into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions docker/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,28 @@

set -ex

export SYTEST_TARGET="$1"
shift

if [ -d "/sytest" ]; then
# If the user has mounted in a SyTest checkout, use that.
echo "Using local sytests..."
echo "Using local sytests"
else
echo "--- Trying to get same-named sytest branch..."

if [ -n "BUILDKITE_BRANCH" ]; then
branch_name=$BUILDKITE_BRANCH
else
# Otherwise, try and find out what the branch that the Synapse/Dendrite checkout is using. Fall back to develop if it's not a branch.
branch_name="$(git --git-dir=/src/.git symbolic-ref HEAD 2>/dev/null)" || branch_name="develop"

if [ "$1" == "dendrite" ] && [ branch_name == "master" ]; then
if [ "$SYTEST_TARGET" == "dendrite" ] && [ branch_name == "master" ]; then
# Dendrite uses master as its main branch. If the branch is master, we probably want sytest develop
branch_name="develop"
fi
fi

# Try and fetch the branch
echo "Trying to get same-named sytest branch..."
wget -q https://github.com/matrix-org/sytest/archive/$branch_name.tar.gz -O sytest.tar.gz || {
# Probably a 404, fall back to develop
echo "Using develop instead..."
Expand All @@ -32,8 +36,18 @@ else
tar -C /sytest --strip-components=1 -xf sytest.tar.gz
fi

echo "--- Preparing sytest for ${SYTEST_TARGET}"

export SYTEST_LIB="/sytest/lib"
SYTEST_SCRIPT="/sytest/docker/$1_sytest.sh"

# Run the sytest script
$SYTEST_SCRIPT "${@:2}"
if [ -x "/sytest/scripts/${SYTEST_TARGET}_sytest.sh" ]; then
exec "/sytest/scripts/${SYTEST_TARGET}_sytest.sh" "$@"

elif [ -x "/sytest/docker/${SYTEST_TARGET}_sytest.sh" ]; then
# old branches of sytest used to put the sytest running script in the "/docker" directory
exec "/sytest/docker/${SYTEST_TARGET}_sytest.sh" "$@"

else
echo "sytest runner script for ${SYTEST_TARGET} not found" >&2
exit 1
fi
7 changes: 6 additions & 1 deletion docker/dendrite_sytest.sh → scripts/dendrite_sytest.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#! /usr/bin/env bash
#!/bin/bash
#
# This script is run by the bootstrap.sh script in the docker image.
#
# It expects to find a built dendrite in /src/bin. It sets up the
# postgres database and runs sytest against dendrite.

set -ex

Expand Down
11 changes: 9 additions & 2 deletions docker/synapse_sytest.sh → scripts/synapse_sytest.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
#!/bin/bash
#
# This script is run by the bootstrap.sh script in the docker image.
#
# It expects to find the synapse source in /src, and a virtualenv in /venv.
# It installs synapse into the virtualenv, configures sytest according to the
# env vars, and runs sytest.
#

# Run the sytests.

set -ex

cd /sytest
cd "$(dirname $0)/.."

mkdir /work

Expand All @@ -18,7 +25,7 @@ if [ -n "$POSTGRES" ]; then
su -c 'eatmydata /usr/lib/postgresql/*/bin/pg_ctl -w -D $PGDATA start' postgres

# Write out the configuration for a PostgreSQL using Synapse
docker/prep_sytest_for_postgres.sh
./scripts/prep_sytest_for_postgres.sh

# Make the test databases for the two Synapse servers that will be spun up
su -c 'psql -c "CREATE DATABASE pg1;"' postgres
Expand Down