jenkins-postgres.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. set -eux
  3. : ${WORKSPACE:="$(pwd)"}
  4. export PYTHONDONTWRITEBYTECODE=yep
  5. export SYNAPSE_CACHE_FACTOR=1
  6. # Output test results as junit xml
  7. export TRIAL_FLAGS="--reporter=subunit"
  8. export TOXSUFFIX="| subunit-1to2 | subunit2junitxml --no-passthrough --output-to=results.xml"
  9. # Write coverage reports to a separate file for each process
  10. export COVERAGE_OPTS="-p"
  11. export DUMP_COVERAGE_COMMAND="coverage help"
  12. # Output flake8 violations to violations.flake8.log
  13. # Don't exit with non-0 status code on Jenkins,
  14. # so that the build steps continue and a later step can decided whether to
  15. # UNSTABLE or FAILURE this build.
  16. export PEP8SUFFIX="--output-file=violations.flake8.log || echo flake8 finished with status code \$?"
  17. rm .coverage* || echo "No coverage files to remove"
  18. tox --notest -e py27
  19. TOX_BIN=$WORKSPACE/.tox/py27/bin
  20. $TOX_BIN/pip install psycopg2
  21. : ${GIT_BRANCH:="origin/$(git rev-parse --abbrev-ref HEAD)"}
  22. if [[ ! -e .sytest-base ]]; then
  23. git clone https://github.com/matrix-org/sytest.git .sytest-base --mirror
  24. else
  25. (cd .sytest-base; git fetch -p)
  26. fi
  27. rm -rf sytest
  28. git clone .sytest-base sytest --shared
  29. cd sytest
  30. git checkout "${GIT_BRANCH}" || (echo >&2 "No ref ${GIT_BRANCH} found, falling back to develop" ; git checkout develop)
  31. : ${PORT_BASE:=8000}
  32. ./jenkins/prep_sytest_for_postgres.sh
  33. echo >&2 "Running sytest with PostgreSQL";
  34. ./jenkins/install_and_run.sh --coverage \
  35. --python $TOX_BIN/python \
  36. --synapse-directory $WORKSPACE \
  37. --port-base $PORT_BASE
  38. cd ..
  39. cp sytest/.coverage.* .
  40. # Combine the coverage reports
  41. echo "Combining:" .coverage.*
  42. $TOX_BIN/python -m coverage combine
  43. # Output coverage to coverage.xml
  44. $TOX_BIN/coverage xml -o coverage.xml