MT#61223 build: fix trunk-next builds

* set release to "trunk-next"
* create tests just for trunk-next scenario

Change-Id: I81d2510250536abeae9cba1824f25e3f5095c908
mprokop/trixie
Victor Seva 2 years ago
parent dc4752bde2
commit 2768edea92

@ -0,0 +1,15 @@
- model: build.buildrelease
pk: 1
fields:
branch: master
built_projects: release-copy-debs-yml
distribution: bookworm
failed_projects: ''
pool_size: 0
projects: 'asterisk-voicemail,backup-tools,bulk-processor,bulk-processor-projects,bootenv,cdr-exporter,cfg-schema,check-tools,cleanup-tools,cloudpbx-sources,codec-chain,csta-testsuite,data-hal,db-schema,deployment-iso,dhtest,documentation,faxserver,installer,kamailio,kamailio-config-tests,keyring,libswrate,libtcap,license-client,lnpd,lua-ngcp-kamailio,mediator,metapackages,monitoring-tools,ngcp-admin-ui,ngcp-api-tools,ngcp-csc-ui,ngcp-cudecs,ngcp-exporter,ngcp-fauditd,ngcp-freeswitch-appserv,ngcp-inventory,ngcp-js-api-client,ngcp-logfs,ngcp-panel,ngcp-prompts,ngcp-rest-api,ngcp-schema,ngcp-status,ngcp-sudo-plugin,ngcp-support,ngcp-task-agent,ngcp-user-framework,ngcp-web-tests-e2e,ngcpcfg,ngcpcfg-api,ngcpcfg-ha,ngrep-sip,prosody,pushd,rate-o-mat,reminder,rtpengine,sems,sems-pbx,sipwise-base,snmp-agent,system-tests,system-tools,templates,upgrade,vmnotify,voisniff-ng,websocket'
release: trunk-next
start_date: '2024-10-14T10:28:01.000Z'
tag: ''
triggered_jobs: ''
triggered_projects: ''
uuid: 53f9e166-4271-4581-ae3d-b3c1bb0bb081

@ -0,0 +1,126 @@
# Copyright (C) 2024 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
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
from unittest.mock import patch
from django.test import override_settings
from django.test import SimpleTestCase
from build.conf import settings
from build.models import BuildRelease
from build.models import ReleaseConfig
from build.utils import get_simple_release
from build.utils import guess_trunk_filename
from repoapi.test.base import BaseTest
FIXTURES_PATH = settings.BASE_DIR.joinpath("build", "fixtures")
@override_settings(
BUILD_REPOS_SCRIPTS_CONFIG_DIR=FIXTURES_PATH.joinpath("config.next")
)
class BuildReleaseTestCase(BaseTest):
fixtures = ["test_trunk_next"]
release_uuid = "53f9e166-4271-4581-ae3d-b3c1bb0bb081"
def test_distribution(self):
br = BuildRelease.objects.get(uuid=self.release_uuid)
self.assertEqual(br.release, "trunk-next")
self.assertEqual(br.distribution, "bookworm")
@override_settings(
BUILD_REPOS_SCRIPTS_CONFIG_DIR=FIXTURES_PATH.joinpath("config.next")
)
class ReleaseConfigNext(SimpleTestCase):
@override_settings(
BUILD_REPOS_SCRIPTS_CONFIG_DIR=FIXTURES_PATH.joinpath("config")
)
def test_trunk_next_check(self):
"""
No trunk-next.yml in config
validate() works fine but
release gets detected as trunk
since there is no trunk-next.yml in config!!
"""
ok = FIXTURES_PATH.joinpath("config.next", "trunk-next.yml")
data = ReleaseConfig.load_config(ok)
cfg = ReleaseConfig("fake", config=data)
self.assertEqual(cfg.branch, "master")
self.assertEqual(cfg.config_file, "fake.yml")
self.assertEqual(cfg.debian_release, "bookworm")
self.assertEqual(cfg.release, "trunk")
self.assertEqual(cfg.distribution, None)
def test_guess_trunk_filename(self):
res = guess_trunk_filename("release-trunk-bullseye")
self.assertEqual(res, "trunk")
res = guess_trunk_filename("release-trunk-bookworm")
self.assertEqual(res, "trunk-next")
@override_settings(BUILD_RELEASES_SKIP=["mr0.1"])
def test_supported_releases(self):
supported = [
"release-trunk-bullseye",
"release-trunk-bookworm",
]
res = ReleaseConfig.supported_releases()
self.assertListEqual(res, supported)
def test_trunk_next(self):
rc = ReleaseConfig("trunk-next")
self.assertIsNotNone(rc.config)
self.assertEqual(rc.debian_release, "bookworm")
self.assertNotIn("rainbow-misc", rc.projects)
rc = ReleaseConfig("release-trunk-bookworm")
self.assertEqual(rc.debian_release, "bookworm")
self.assertNotIn("rainbow-misc", rc.projects)
@override_settings(
BUILD_REPOS_SCRIPTS_CONFIG_DIR=FIXTURES_PATH.joinpath("config.next")
)
class BuildReleaseCreate(BaseTest):
@patch("build.tasks.trigger_copy_deps")
@patch("build.signals.build_resume")
def test_create_build_release(self, build_resume, trigger_copy_deps):
br = BuildRelease.objects.create_build_release(
"UUID1",
"release-trunk-bookworm",
)
self.assertEqual(br.release, "trunk-next")
self.assertEqual(br.distribution, "bookworm")
def test_get_simple_release(self):
val = get_simple_release("release-trunk-bookworm")
self.assertEqual(val, "trunk-next")
def test_is_trunk_next(self):
self.assertTrue(ReleaseConfig.is_trunk_next("release-trunk-bookworm"))
@override_settings(
BUILD_REPOS_SCRIPTS_CONFIG_DIR=FIXTURES_PATH.joinpath("config")
)
def test_is_trunk_next_no_cfg(self):
self.assertFalse(ReleaseConfig.is_trunk_next("release-trunk-bookworm"))
def test_config(self):
cfg = ReleaseConfig("release-trunk-bookworm")
self.assertEqual(cfg.branch, "master")
self.assertEqual(cfg.distribution, "bookworm")
self.assertEqual(cfg.config_file, "trunk-next.yml")
self.assertEqual(cfg.debian_release, "bookworm")
self.assertEqual(cfg.release, "trunk-next")

@ -1,4 +1,4 @@
# Copyright (C) 2017-2022 The Sipwise Team - http://sipwise.com
# Copyright (C) 2017-2024 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
@ -224,6 +224,7 @@ class TestCheckConfig(APISimpleTestCase):
self.data = {
"jenkins-jobs": {},
"distris": ["release-trunk-buster"],
"debian_release": "buster",
"release-trunk-buster": [],
}

@ -1,4 +1,4 @@
# Copyright (C) 2017-2023 The Sipwise Team - http://sipwise.com
# Copyright (C) 2017-2024 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
@ -689,33 +689,3 @@ class CheckConfig(SimpleTestCase):
match = "bullseye not in distris in a release config"
with self.assertRaisesRegex(err.WrongDistris, match):
ReleaseConfig("fake", config=data)
@override_settings(
BUILD_REPOS_SCRIPTS_CONFIG_DIR=FIXTURES_PATH.joinpath("config.next")
)
class ReleaseConfigNext(SimpleTestCase):
def test_guess_trunk_filename(self):
res = guess_trunk_filename("release-trunk-bullseye")
self.assertEqual(res, "trunk")
res = guess_trunk_filename("release-trunk-bookworm")
self.assertEqual(res, "trunk-next")
@override_settings(BUILD_RELEASES_SKIP=["mr0.1"])
def test_supported_releases(self):
supported = [
"release-trunk-bullseye",
"release-trunk-bookworm",
]
res = ReleaseConfig.supported_releases()
self.assertListEqual(res, supported)
def test_trunk_next(self):
rc = ReleaseConfig("trunk-next")
self.assertIsNotNone(rc.config)
self.assertEqual(rc.debian_release, "bookworm")
self.assertNotIn("rainbow-misc", rc.projects)
rc = ReleaseConfig("release-trunk-bookworm")
self.assertEqual(rc.debian_release, "bookworm")
self.assertNotIn("rainbow-misc", rc.projects)

@ -1,4 +1,4 @@
# Copyright (C) 2017-2022 The Sipwise Team - http://sipwise.com
# Copyright (C) 2017-2024 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
@ -252,6 +252,17 @@ class ReleaseConfig(object):
f"problems detected with {builds}"
)
@classmethod
def is_trunk_next(cls, release):
try:
path = settings.BUILD_REPOS_SCRIPTS_CONFIG_DIR / "trunk-next.yml"
cfg = cls.load_config(path)
if release in cfg["distris"]:
return True
except err.NoConfigReleaseFile:
pass
return False
@classmethod
def load_config(cls, config_path):
try:
@ -399,7 +410,7 @@ class ReleaseConfig(object):
@property
def branch(self):
release = self.release
if release in ("trunk", "release-trunk-weekly"):
if release in ("trunk", "trunk-next", "release-trunk-weekly"):
return "master"
release_count = release.count(".")
if release_count in [1, 2]:
@ -418,6 +429,8 @@ class ReleaseConfig(object):
if dist == "release-trunk-weekly":
return dist
if dist.startswith("release-trunk-"):
if self.is_trunk_next(dist):
return "trunk-next"
return "trunk"
elif dist.startswith("release-"):
return dist

Loading…
Cancel
Save