From 4e98070d9970aff26c19e193320409a8f841f6b2 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Fri, 26 Oct 2018 15:09:24 +0200 Subject: [PATCH] TT#46500 Support triggering $debian_release/master branches If we want to trigger a trunk build against e.g. Debian/buster we might need to build certain projects against branch "buster/master", instead of using the default "master" branch (which works fine for the current Debian stable release AKA stretch, but might need non-backwards compatible changes when building for the current Debian testing release AKA buster ). I identified two approaches to get there: 1) Statically extend the list of available branches which is available for selection in the "Version" drop down (which only provide "ignore" and "branch/master" until now). This could be done by something like: | --- a/release_dashboard/utils/__init__.py | +++ b/release_dashboard/utils/__init__.py | @@ -14,6 +14,7 @@ | # with this program. If not, see . | | from release_dashboard.models import Project | +from release_dashboard.forms import rd_settings | | | def get_tags(projectname, regex=None): | @@ -23,4 +24,8 @@ def get_tags(projectname, regex=None): | | def get_branches(projectname, regex=None): | project, _ = Project.objects.get_or_create(name=projectname) | - return project.filter_branches(regex) | + branches = project.filter_branches(regex) | + for debian_release in rd_settings['debian_supported']: | + if debian_release != "auto": | + branches.append(debian_release + "/master") | + return branches The disadvantage of this approach is, that we're listing all the branches all the time, e.g. the very old "squeeze/master" is listed even though it doesn't exist in any project as such. 2) Identify available branches and extend the regular expression which identifies the "master" branch by also looking for "$debian_release/master" branches, iterating over all supported Debian releases. Since approach 2) doesn't polute the drop down for branch selection so much, this is the solution I decided to use here. JFTR, when testing locally against an unpopulated sqlite database (:= db.sqlite3 file), then the relevant branches need to exist in the release_dashboard_project table of the DB. To fake such data use something like: | root@16f2201e3229:/code# sqlite3 ./db.sqlite3 | SQLite version 3.16.2 2017-01-06 16:32:41 | Enter ".help" for usage hints. | sqlite> update release_dashboard_project set json_branches = '[{"ref": "HEAD", "revision": "master"}, {"ref": "refs/heads/master", "revision": "fakedata"}, | {"ref": "refs/heads/buster/master", "revision": "fakedata"}, {"ref": "refs/heads/stretch/master", "revision": "fakeeeeee"}]'; Change-Id: I5f24574e33ac80d1e92210ff5516dce4bf8fef76 --- release_dashboard/views/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/release_dashboard/views/__init__.py b/release_dashboard/views/__init__.py index 201b8b8..6f424ca 100644 --- a/release_dashboard/views/__init__.py +++ b/release_dashboard/views/__init__.py @@ -15,10 +15,19 @@ import re from release_dashboard.utils import get_tags, get_branches +from release_dashboard.forms import rd_settings regex_hotfix = re.compile(r'^mr[0-9]+\.[0-9]+\.[0-9]+$') regex_mr = re.compile(r'^mr.+$') -regex_master = re.compile(r'^master$') + +# support "master" + "$supported_debian_releases/master" for branch selection, +# e.g. for trunk builds when not everything might build against master +debian_releases = [] +for debian_release in rd_settings['debian_supported']: + if debian_release != "auto": + debian_releases.append(debian_release) +regex_master = re.compile(r'^master$|^(%s)/master$' % + '|'.join(map(re.escape, debian_releases))) def _projects_versions(projects, regex=None,