mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-25 20:29:23 -05:00
Add option to skip unit tests when building debs (#9793)
Signed-off-by: Dan Callahan <danc@element.io>
This commit is contained in:
parent
e300ef64b1
commit
3efde8b69a
1
changelog.d/9793.misc
Normal file
1
changelog.d/9793.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Add option to skip unit tests when building Debian packages.
|
11
debian/build_virtualenv
vendored
11
debian/build_virtualenv
vendored
@ -50,7 +50,13 @@ PACKAGE_BUILD_DIR="debian/matrix-synapse-py3"
|
|||||||
VIRTUALENV_DIR="${PACKAGE_BUILD_DIR}${DH_VIRTUALENV_INSTALL_ROOT}/matrix-synapse"
|
VIRTUALENV_DIR="${PACKAGE_BUILD_DIR}${DH_VIRTUALENV_INSTALL_ROOT}/matrix-synapse"
|
||||||
TARGET_PYTHON="${VIRTUALENV_DIR}/bin/python"
|
TARGET_PYTHON="${VIRTUALENV_DIR}/bin/python"
|
||||||
|
|
||||||
# we copy the tests to a temporary directory so that we can put them on the
|
case "$DEB_BUILD_OPTIONS" in
|
||||||
|
*nocheck*)
|
||||||
|
# Skip running tests if "nocheck" present in $DEB_BUILD_OPTIONS
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
# Copy tests to a temporary directory so that we can put them on the
|
||||||
# PYTHONPATH without putting the uninstalled synapse on the pythonpath.
|
# PYTHONPATH without putting the uninstalled synapse on the pythonpath.
|
||||||
tmpdir=`mktemp -d`
|
tmpdir=`mktemp -d`
|
||||||
trap "rm -r $tmpdir" EXIT
|
trap "rm -r $tmpdir" EXIT
|
||||||
@ -60,6 +66,9 @@ cp -r tests "$tmpdir"
|
|||||||
PYTHONPATH="$tmpdir" \
|
PYTHONPATH="$tmpdir" \
|
||||||
"${TARGET_PYTHON}" -m twisted.trial --reporter=text -j2 tests
|
"${TARGET_PYTHON}" -m twisted.trial --reporter=text -j2 tests
|
||||||
|
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# build the config file
|
# build the config file
|
||||||
"${TARGET_PYTHON}" "${VIRTUALENV_DIR}/bin/generate_config" \
|
"${TARGET_PYTHON}" "${VIRTUALENV_DIR}/bin/generate_config" \
|
||||||
--config-dir="/etc/matrix-synapse" \
|
--config-dir="/etc/matrix-synapse" \
|
||||||
|
6
debian/changelog
vendored
6
debian/changelog
vendored
@ -1,3 +1,9 @@
|
|||||||
|
matrix-synapse-py3 (1.31.0+nmu1) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
|
* Skip tests when DEB_BUILD_OPTIONS contains "nocheck".
|
||||||
|
|
||||||
|
-- Dan Callahan <danc@element.io> Mon, 12 Apr 2021 13:07:36 +0000
|
||||||
|
|
||||||
matrix-synapse-py3 (1.31.0) stable; urgency=medium
|
matrix-synapse-py3 (1.31.0) stable; urgency=medium
|
||||||
|
|
||||||
* New synapse release 1.31.0.
|
* New synapse release 1.31.0.
|
||||||
|
@ -41,7 +41,7 @@ class Builder(object):
|
|||||||
self._lock = threading.Lock()
|
self._lock = threading.Lock()
|
||||||
self._failed = False
|
self._failed = False
|
||||||
|
|
||||||
def run_build(self, dist):
|
def run_build(self, dist, skip_tests=False):
|
||||||
"""Build deb for a single distribution"""
|
"""Build deb for a single distribution"""
|
||||||
|
|
||||||
if self._failed:
|
if self._failed:
|
||||||
@ -49,13 +49,13 @@ class Builder(object):
|
|||||||
raise Exception("failed")
|
raise Exception("failed")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._inner_build(dist)
|
self._inner_build(dist, skip_tests)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("build of %s failed: %s" % (dist, e), file=sys.stderr)
|
print("build of %s failed: %s" % (dist, e), file=sys.stderr)
|
||||||
self._failed = True
|
self._failed = True
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def _inner_build(self, dist):
|
def _inner_build(self, dist, skip_tests=False):
|
||||||
projdir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
projdir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
||||||
os.chdir(projdir)
|
os.chdir(projdir)
|
||||||
|
|
||||||
@ -99,6 +99,7 @@ class Builder(object):
|
|||||||
"--volume=" + debsdir + ":/debs",
|
"--volume=" + debsdir + ":/debs",
|
||||||
"-e", "TARGET_USERID=%i" % (os.getuid(), ),
|
"-e", "TARGET_USERID=%i" % (os.getuid(), ),
|
||||||
"-e", "TARGET_GROUPID=%i" % (os.getgid(), ),
|
"-e", "TARGET_GROUPID=%i" % (os.getgid(), ),
|
||||||
|
"-e", "DEB_BUILD_OPTIONS=%s" % ("nocheck" if skip_tests else ""),
|
||||||
"dh-venv-builder:" + tag,
|
"dh-venv-builder:" + tag,
|
||||||
], stdout=stdout, stderr=subprocess.STDOUT)
|
], stdout=stdout, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
@ -122,7 +123,7 @@ class Builder(object):
|
|||||||
self.active_containers.remove(c)
|
self.active_containers.remove(c)
|
||||||
|
|
||||||
|
|
||||||
def run_builds(dists, jobs=1):
|
def run_builds(dists, jobs=1, skip_tests=False):
|
||||||
builder = Builder(redirect_stdout=(jobs > 1))
|
builder = Builder(redirect_stdout=(jobs > 1))
|
||||||
|
|
||||||
def sig(signum, _frame):
|
def sig(signum, _frame):
|
||||||
@ -131,7 +132,7 @@ def run_builds(dists, jobs=1):
|
|||||||
signal.signal(signal.SIGINT, sig)
|
signal.signal(signal.SIGINT, sig)
|
||||||
|
|
||||||
with ThreadPoolExecutor(max_workers=jobs) as e:
|
with ThreadPoolExecutor(max_workers=jobs) as e:
|
||||||
res = e.map(builder.run_build, dists)
|
res = e.map(lambda dist: builder.run_build(dist, skip_tests), dists)
|
||||||
|
|
||||||
# make sure we consume the iterable so that exceptions are raised.
|
# make sure we consume the iterable so that exceptions are raised.
|
||||||
for r in res:
|
for r in res:
|
||||||
@ -146,9 +147,13 @@ if __name__ == '__main__':
|
|||||||
'-j', '--jobs', type=int, default=1,
|
'-j', '--jobs', type=int, default=1,
|
||||||
help='specify the number of builds to run in parallel',
|
help='specify the number of builds to run in parallel',
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--no-check', action='store_true',
|
||||||
|
help='skip running tests after building',
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'dist', nargs='*', default=DISTS,
|
'dist', nargs='*', default=DISTS,
|
||||||
help='a list of distributions to build for. Default: %(default)s',
|
help='a list of distributions to build for. Default: %(default)s',
|
||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
run_builds(dists=args.dist, jobs=args.jobs)
|
run_builds(dists=args.dist, jobs=args.jobs, skip_tests=args.no_check)
|
||||||
|
Loading…
Reference in New Issue
Block a user