complement.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env bash
  2. # This script is designed for developers who want to test their code
  3. # against Complement.
  4. #
  5. # It makes a Synapse image which represents the current checkout,
  6. # builds a synapse-complement image on top, then runs tests with it.
  7. #
  8. # By default the script will fetch the latest Complement master branch and
  9. # run tests with that. This can be overridden to use a custom Complement
  10. # checkout by setting the COMPLEMENT_DIR environment variable to the
  11. # filepath of a local Complement checkout.
  12. #
  13. # A regular expression of test method names can be supplied as the first
  14. # argument to the script. Complement will then only run those tests. If
  15. # no regex is supplied, all tests are run. For example;
  16. #
  17. # ./complement.sh "TestOutboundFederation(Profile|Send)"
  18. #
  19. # Exit if a line returns a non-zero exit code
  20. set -e
  21. # Change to the repository root
  22. cd "$(dirname $0)/.."
  23. # Check for a user-specified Complement checkout
  24. if [[ -z "$COMPLEMENT_DIR" ]]; then
  25. echo "COMPLEMENT_DIR not set. Fetching the latest Complement checkout..."
  26. wget -Nq https://github.com/matrix-org/complement/archive/master.tar.gz
  27. tar -xzf master.tar.gz
  28. COMPLEMENT_DIR=complement-master
  29. echo "Checkout available at 'complement-master'"
  30. fi
  31. # Build the base Synapse image from the local checkout
  32. docker build -t matrixdotorg/synapse -f docker/Dockerfile .
  33. # Build the Synapse monolith image from Complement, based on the above image we just built
  34. docker build -t complement-synapse -f "$COMPLEMENT_DIR/dockerfiles/Synapse.Dockerfile" "$COMPLEMENT_DIR/dockerfiles"
  35. cd "$COMPLEMENT_DIR"
  36. EXTRA_COMPLEMENT_ARGS=""
  37. if [[ -n "$1" ]]; then
  38. # A test name regex has been set, supply it to Complement
  39. EXTRA_COMPLEMENT_ARGS+="-run $1 "
  40. fi
  41. # Run the tests!
  42. COMPLEMENT_BASE_IMAGE=complement-synapse go test -v -tags synapse_blacklist,msc2946,msc3083 -count=1 $EXTRA_COMPLEMENT_ARGS ./tests