MT#56231 remove ppa for scenario mrX.X.X review merged

mrX.X.X merges will not trigger a build, so -repos job will never
happen with eventtype 'change-merged'

now -gerrit job sends the proper values of branch and ppa so
we can detect the scenario and clean the ppa

* move common regex definitions to repoapi.utils

Change-Id: I2b6afd0a7dea0fe07f47ba76bd6f9c2fa88e85ce
mprokop/trixie
Victor Seva 3 years ago
parent b6bf74bfd0
commit 9383016f3d

@ -1,4 +1,4 @@
# Copyright (C) 2017-2022 The Sipwise Team - http://sipwise.com
# Copyright (C) 2017-2023 The Sipwise Team - http://sipwise.com
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
@ -13,7 +13,6 @@
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
import datetime
import re
import structlog
from django.db import models
@ -28,12 +27,12 @@ from .utils import get_simple_release
from .utils import ReleaseConfig
from .utils import remove_from_textlist
from repoapi.models import JenkinsBuildInfo
from repoapi.utils import regex_mrXX
from repoapi.utils import regex_mrXX_up
from repoapi.utils import regex_mrXXX
logger = structlog.get_logger(__name__)
regex_mrXXX = re.compile(r"^mr[0-9]+\.[0-9]+\.[0-9]+$")
regex_mrXX = re.compile(r"^mr[0-9]+\.[0-9]+$")
regex_mrXX_up = re.compile(r"^release-mr[0-9]+\.[0-9]+-update$")
build_release_jobs = ",".join(settings.BUILD_RELEASE_JOBS)
release_jobs_len = len(build_release_jobs) + 1

@ -1,4 +1,4 @@
# Copyright (C) 2015-2022 The Sipwise Team - http://sipwise.com
# Copyright (C) 2015-2023 The Sipwise Team - http://sipwise.com
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
@ -23,7 +23,6 @@ from tracker.models import MantisInfo
from tracker.models import TrackerInfo
from tracker.models import WorkfrontInfo
re_branch = re.compile(r"^mr[0-9]+\.[0-9]+\.[0-9]+$")
commit_re = re.compile(r"^(\w{7}) ")

@ -1,4 +1,4 @@
# Copyright (C) 2022 The Sipwise Team - http://sipwise.com
# Copyright (C) 2022-2023 The Sipwise Team - http://sipwise.com
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
@ -19,9 +19,9 @@ from django.dispatch import receiver
from . import utils
from .models.wni import NoteInfo
from .models.wni import re_branch
from .tasks import get_jbi_files
from .tasks import jenkins_remove_project
from .utils import regex_mrXXX
from release_dashboard.utils.build import is_ngcp_project
logger = structlog.get_logger(__name__)
@ -64,6 +64,7 @@ def gerrit_repo_del(instance):
return
structlog.contextvars.bind_contextvars(
instance=str(instance),
branch=instance.param_branch,
ppa=instance.param_ppa,
gerrit_change=instance.gerrit_change,
)
@ -104,6 +105,7 @@ def gerrit_repo_manage(sender, **kwargs):
instance = kwargs["instance"]
structlog.contextvars.bind_contextvars(
instance=str(instance),
branch=instance.param_branch,
ppa=instance.param_ppa,
)
if instance.param_ppa == "$ppa":
@ -125,6 +127,14 @@ def gerrit_repo_manage(sender, **kwargs):
):
logger.info("we need to count this")
gerrit_repo_del(instance)
elif (
instance.jobname.endswith("-gerrit")
and instance.result == "SUCCESS"
and instance.gerrit_eventtype == "change-merged"
and regex_mrXXX.match(instance.param_branch)
):
logger.info("we need to count this")
gerrit_repo_del(instance)
def tracker_release_target(instance, note: NoteInfo):
@ -134,7 +144,7 @@ def tracker_release_target(instance, note: NoteInfo):
)
return
branch = instance.param_branch
if re_branch.search(branch):
if regex_mrXXX.search(branch):
release = branch
else:
release = utils.get_next_release(branch)

@ -1,4 +1,4 @@
# Copyright (C) 2017-2022 The Sipwise Team - http://sipwise.com
# Copyright (C) 2017-2023 The Sipwise Team - http://sipwise.com
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
@ -192,3 +192,21 @@ class TaskGerritRepoTest(BaseTest):
self.assertEqual(ppa.count(), 1)
rp.assert_called_once_with("gerrit_vseva_95650", "lua-ngcp-kamailio")
rppa.assert_not_called()
def test_ppa_merged_mrXXX(self, rppa, rp):
self.params["param_branch"] = "mr9.5.1"
self.params["gerrit_change"] = "54"
self.params["gerrit_patchset"] = "54"
JenkinsBuildInfo.objects.create(**self.params)
ppa = GerritRepoInfo.objects.filter(param_ppa=self.params["param_ppa"])
self.assertEqual(ppa.count(), 1)
self.params["jobname"] = "lua-ngcp-kamailio-gerrit"
ppa = GerritRepoInfo.objects.filter(param_ppa=self.params["param_ppa"])
self.assertEqual(ppa.count(), 1)
self.params["gerrit_eventtype"] = "change-merged"
JenkinsBuildInfo.objects.create(**self.params)
self.assertEqual(ppa.count(), 0)
rp.assert_not_called()
rppa.assert_called_with("gerrit_vseva_95650")

@ -1,4 +1,4 @@
# Copyright (C) 2015-2022 The Sipwise Team - http://sipwise.com
# Copyright (C) 2015-2023 The Sipwise Team - http://sipwise.com
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
@ -24,6 +24,10 @@ from .conf import settings
logger = structlog.get_logger(__name__)
regex_mrXXX = re.compile(r"^mr[0-9]+\.[0-9]+\.[0-9]+$")
regex_mrXX = re.compile(r"^mr[0-9]+\.[0-9]+$")
regex_mrXX_up = re.compile(r"^release-mr[0-9]+\.[0-9]+-update$")
JBI_CONSOLE_URL = "{}/job/{}/{}/consoleText"
JBI_BUILD_URL = "{}/job/{}/{}/api/json"
JBI_ARTIFACT_URL = "{}/job/{}/{}/artifact/{}"

Loading…
Cancel
Save