From a4ca2ae2d8bd97b989d0666134ad25448b8bd959 Mon Sep 17 00:00:00 2001 From: Rui Ban Date: Wed, 9 Dec 2020 16:20:34 +0800 Subject: [PATCH] add build_on_tag flag (#456) * feat(docker-compose): update version * feat(docker-compose): update version * fix(test): check active build for tag event * feat(github): add build_on_tag flag --- src/db/migrations/00035.sql | 1 + src/github/trigger/trigger.py | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 src/db/migrations/00035.sql diff --git a/src/db/migrations/00035.sql b/src/db/migrations/00035.sql new file mode 100644 index 000000000..1af273882 --- /dev/null +++ b/src/db/migrations/00035.sql @@ -0,0 +1 @@ +ALTER TABLE "project" ADD COLUMN build_on_tag boolean DEFAULT true NOT NULL; \ No newline at end of file diff --git a/src/github/trigger/trigger.py b/src/github/trigger/trigger.py index 390a76b28..911795661 100755 --- a/src/github/trigger/trigger.py +++ b/src/github/trigger/trigger.py @@ -187,8 +187,18 @@ def create_push(self, c, repository, branch, tag): self.execute(''' UPDATE "commit" SET tag = %s WHERE id = %s AND project_id = %s ''', [tag, c['id'], project_id], fetch=False) - if self.has_active_build(commit_id, project_id): - return + + build_on_tag = self.execute(''' + SELECT build_on_tag + FROM project + WHERE id = %s''', [project_id])[0] + + if not build_on_tag and self.has_active_build(commit_id, project_id): + return + else: + if self.has_active_build(commit_id, project_id): + return + if not result: status_url = repository['statuses_url'].format(sha=c['id']) @@ -411,8 +421,8 @@ def handle_pull_request(self, event): FROM job j JOIN build b ON b.id = j.build_id - WHERE - b.commit_id = %s AND + WHERE + b.commit_id = %s AND j.state in ('scheduled', 'running', 'queued') ''', [commit_id], fetch=False)