only check the tarball-base when building tarballs

Only require projects that build tarball artifacts to have the
tarball-base value set properly.

Change-Id: I9d42329f4080cc0f766b71fae4c45cd87aea3e3a
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2016-12-19 15:38:29 -05:00
parent 2107955e5f
commit ef416c92e6
2 changed files with 57 additions and 24 deletions

View File

@ -234,23 +234,25 @@ def validate_releases(deliverable_info, zuul_layout,
gitutils.clone_repo(workdir, project['repo'])
# Check that the sdist name and tarball-base name match.
sdist = pythonutils.get_sdist_name(workdir, project['repo'])
if sdist is not None:
expected = project.get(
'tarball-base',
os.path.basename(project['repo']),
)
if sdist != expected:
if 'tarball-base' in deliverable_info:
action = 'is set to'
else:
action = 'defaults to'
mk_error(
('tarball-base for %s %s %s %r '
'but the sdist name is actually %r. ' +
_PLEASE)
% (project['repo'], release['version'],
action, expected, sdist))
if link_mode == 'tarball':
sdist = pythonutils.get_sdist_name(workdir,
project['repo'])
if sdist is not None:
expected = project.get(
'tarball-base',
os.path.basename(project['repo']),
)
if sdist != expected:
if 'tarball-base' in deliverable_info:
action = 'is set to'
else:
action = 'defaults to'
mk_error(
('tarball-base for %s %s %s %r '
'but the sdist name is actually %r. ' +
_PLEASE)
% (project['repo'], release['version'],
action, expected, sdist))
# Report if the version has already been
# tagged. We expect it to not exist, but neither

View File

@ -630,10 +630,10 @@ class TestValidateTarballBase(base.BaseTestCase):
super(TestValidateTarballBase, self).setUp()
self.tmpdir = self.useFixture(fixtures.TempDir()).path
@mock.patch('openstack_releases.project_config.require_release_jobs_for_repo')
@mock.patch('openstack_releases.pythonutils.get_sdist_name')
def test_default_ok(self, gsn):
def test_default_ok(self, gsn, jobs):
deliverable_info = {
'artifact-link-mode': 'none',
'releases': [
{'version': '1.5.0',
'projects': [
@ -653,11 +653,13 @@ class TestValidateTarballBase(base.BaseTestCase):
warnings.append,
errors.append,
)
print(warnings, errors)
self.assertEqual(0, len(warnings))
self.assertEqual(0, len(errors))
@mock.patch('openstack_releases.project_config.require_release_jobs_for_repo')
@mock.patch('openstack_releases.pythonutils.get_sdist_name')
def test_default_invalid(self, gsn):
def test_ignored_link_mode_none(self, gsn, jobs):
deliverable_info = {
'artifact-link-mode': 'none',
'releases': [
@ -670,6 +672,33 @@ class TestValidateTarballBase(base.BaseTestCase):
}
warnings = []
errors = []
gsn.return_value = 'this-is-wrong'
validate.validate_releases(
deliverable_info,
{'validate-projects-by-name': {}},
'ocata',
self.tmpdir,
warnings.append,
errors.append,
)
print(warnings, errors)
self.assertEqual(0, len(warnings))
self.assertEqual(0, len(errors))
@mock.patch('openstack_releases.project_config.require_release_jobs_for_repo')
@mock.patch('openstack_releases.pythonutils.get_sdist_name')
def test_default_invalid(self, gsn, jobs):
deliverable_info = {
'releases': [
{'version': '1.5.0',
'projects': [
{'repo': 'openstack/automaton',
'hash': 'be2885f544637e6ee6139df7dc7bf937925804dd'},
]}
],
}
warnings = []
errors = []
gsn.return_value = 'automaton1'
validate.validate_releases(
deliverable_info,
@ -679,13 +708,14 @@ class TestValidateTarballBase(base.BaseTestCase):
warnings.append,
errors.append,
)
print(warnings, errors)
self.assertEqual(0, len(warnings))
self.assertEqual(1, len(errors))
@mock.patch('openstack_releases.project_config.require_release_jobs_for_repo')
@mock.patch('openstack_releases.pythonutils.get_sdist_name')
def test_explicit_ok(self, gsn):
def test_explicit_ok(self, gsn, jobs):
deliverable_info = {
'artifact-link-mode': 'none',
'releases': [
{'version': '1.5.0',
'projects': [
@ -706,13 +736,14 @@ class TestValidateTarballBase(base.BaseTestCase):
warnings.append,
errors.append,
)
print(warnings, errors)
self.assertEqual(0, len(warnings))
self.assertEqual(0, len(errors))
@mock.patch('openstack_releases.project_config.require_release_jobs_for_repo')
@mock.patch('openstack_releases.pythonutils.get_sdist_name')
def test_explicit_invalid(self, gsn):
def test_explicit_invalid(self, gsn, jobs):
deliverable_info = {
'artifact-link-mode': 'none',
'releases': [
{'version': '1.5.0',
'projects': [