add a "retired" flag for repositories

Some repositories used to create older deliverables have since been
retired. Add support for a flag to designate them as such, and refactor
the flag test code to make it a little cleaner and to define tags
clearly in one place

Change-Id: I7002f2a13409edfbd76e681b267e28bc28e1a53e
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2016-06-07 18:03:17 -04:00
parent 9bce360514
commit 50d792175d
3 changed files with 38 additions and 6 deletions

View File

@ -224,6 +224,10 @@ The top level of a deliverable file is a mapping with keys:
This repository has no job for building an artifact, but should
be tagged anyway.
``retired``
This repository is no longer used, but was present in old
versions of a deliverable.
``releases``
A list of the releases for the deliverable.

View File

@ -0,0 +1,26 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Work with the flags within a deliverable file.
"""
NO_ARTIFACT_BUILD_JOB = 'no-artifact-build-job'
RETIRED = 'retired'
def has_flag(deliverable_info, repo_name, flag_name):
"""Return boolean indicating whether the flag is present for the repo.
"""
all_settings = deliverable_info.get('repository-settings', {})
repo_settings = all_settings.get(repo_name, {})
flags = repo_settings.get('flags', [])
return flag_name in flags

View File

@ -16,6 +16,8 @@
import requests
import yaml
from openstack_releases import flags
ZUUL_LAYOUT_URL = 'http://git.openstack.org/cgit/openstack-infra/project-config/plain/zuul/layout.yaml' # noqa
ZUUL_LAYOUT_FILENAME = 'openstack-infra/project-config/zuul/layout.yaml'
@ -53,14 +55,14 @@ def require_release_jobs_for_repo(deliverable_info, zuul_layout, repo):
"""
errors = []
# Look up the flags for this repository.
all_settings = deliverable_info.get('repository-settings', {})
repo_settings = all_settings.get(repo, {})
flags = repo_settings.get('flags', [])
# If the repository is configured as not having an artifact to
# build, we don't need to check for any jobs.
if 'no-artifact-build-job' in flags:
if flags.has_flag(deliverable_info, repo, flags.NO_ARTIFACT_BUILD_JOB):
return errors
# If the repository is retired, we don't need to check for any
# jobs.
if flags.has_flag(deliverable_info, repo, flags.RETIRED):
return errors
if repo not in zuul_layout[_VALIDATE_KEY]: