From 4db377ff8a2a4e9fa24d0f8431ce7398b70fa7a7 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Thu, 4 Apr 2019 15:38:04 +0200 Subject: [PATCH] TTM: Check the publish state in releaser --- ttm/publisher.py | 3 +++ ttm/releaser.py | 49 ++++++++++++++++++++++++------------------------ 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/ttm/publisher.py b/ttm/publisher.py index ff9c5ecc..c3037646 100644 --- a/ttm/publisher.py +++ b/ttm/publisher.py @@ -188,6 +188,9 @@ class ToTestPublisher(ToTestManager): self.send_amqp_event(current_snapshot, current_result) + if current_result == QA_FAILED: + self.update_status('failed', current_snapshot) + if current_result != QA_PASSED: return diff --git a/ttm/releaser.py b/ttm/releaser.py index 25bfe830..5b71afc1 100644 --- a/ttm/releaser.py +++ b/ttm/releaser.py @@ -26,38 +26,37 @@ class ToTestReleaser(ToTestManager): def release(self, project, force=False): self.setup(project) - try: - current_snapshot = self.version_from_totest_project() - except NotFoundException as e: - # nothing in test project (yet) - self.logger.warn(e) - current_snapshot = None + + current_snapshot = self.get_status('testing') new_snapshot = self.version_from_project() - current_qa_version = self.current_qa_version() - publisher_state = 'inprogress' - - self.logger.info('current_snapshot %s: %s' % - (current_snapshot, publisher_state)) - self.logger.debug('new_snapshot %s', new_snapshot) - self.logger.debug('current_qa_version %s', current_qa_version) - - snapshotable = self.is_snapshotable() - self.logger.debug('snapshotable: %s', snapshotable) - can_release = ((current_snapshot is None or publisher_state != 'inprogress') and snapshotable) # not overwriting - if not force: - if new_snapshot == current_qa_version: - self.logger.debug('no change in snapshot version') - return - elif not self.all_repos_done(self.project.test_project): - self.logger.debug("not all repos done, can't release") - # the repos have to be done, otherwise we better not touch them - # with a new release + if new_snapshot == current_snapshot: + self.logger.debug('no change in snapshot version') + return + + if current_snapshot: + testing_snapshot = self.get_status('testing') + if testing_snapshot != self.get_status('failed') and testing_snapshot != self.get_status('publishing'): + self.logger.debug('Snapshot {} is still in progress'.format(testing_snapshot)) return + self.logger.info('current_snapshot %s', current_snapshot) + self.logger.debug('new_snapshot %s', new_snapshot) + + if not self.is_snapshotable(): + self.logger.debug('not snapshotable') + return + + if not force and not self.all_repos_done(self.project.test_project): + self.logger.debug("not all repos done, can't release") + # the repos have to be done, otherwise we better not touch them + # with a new release + return + self.update_totest(new_snapshot) self.update_status('testing', new_snapshot) + self.update_status('failed', '') self.write_version_to_dashboard('totest', new_snapshot) return 1