Merge "Add option to run unit tests during builds"

This commit is contained in:
Zuul 2021-11-03 19:21:34 +00:00 committed by Gerrit Code Review
commit f133cb7dd5
2 changed files with 16 additions and 7 deletions

View File

@ -88,7 +88,7 @@ def add_chroot():
@app.route('/pkgbuilder/addtask', methods=['GET'])
def add_task():
response = {}
attrs = ['user', 'project', 'dsc', 'type', 'name', 'mode']
attrs = ['user', 'project', 'dsc', 'type', 'name', 'mode', 'run_tests']
if not all(t in request.form for t in attrs):
log.error("Invalid request to add task")
response['status'] = 'fail'
@ -98,8 +98,13 @@ def add_task():
user = request.form['user']
project = request.form['project']
task_info = {'package': request.form['name'],
'dsc': request.form['dsc'], 'type': request.form['type']}
task_info = {
'package': request.form['name'],
'dsc': request.form['dsc'],
'type': request.form['type'],
'run_tests': request.form['run_tests']
}
response = dbuilder.add_task(user, project, task_info)
log.info("Reply to add task, response=%s", str(response))
return jsonify(response)

View File

@ -211,15 +211,19 @@ class Debbuilder:
response['msg'] = dsc_target + ' does not exist'
return response
# Disable unit tests globally to speed up builds
nocheck = os.environ
nocheck["DEB_BUILD_OPTIONS"] = "nocheck"
bcommand = ' '.join([BUILD_ENGINE, '-d', DEBDIST, '-c', chroot,
'--build-dir', build_dir, dsc_target])
self.logger.debug("Build command: %s" % bcommand)
self._state = 'works'
p = subprocess.Popen(bcommand, shell=True, env=nocheck)
# verify if tests need to be executed
if task_info['run_tests'] == 'True':
p = subprocess.Popen(bcommand, shell=True)
else:
self.logger.debug("No tests needed, setting DEB_BUILD_OPTIONS=nocheck")
p = subprocess.Popen(bcommand, shell=True, env={**os.environ, 'DEB_BUILD_OPTIONS': 'nocheck'})
self.sbuild_processes.setdefault(user, []).append(p)
response['status'] = 'success'