Add validation for xstatic package versions
Xstatic packages need their version hard coded in the source. This can cause problems if the version committed in the repo is different than the tag being requested. This adds checking to our validation to make sure there is not a mismatch for this value. Change-Id: I5ad54c3623fe5caf3dd075195fb75a3a48165ebf
This commit is contained in:
@@ -48,6 +48,7 @@ from openstack_releases import puppetutils
|
||||
from openstack_releases import pythonutils
|
||||
from openstack_releases import requirements
|
||||
from openstack_releases import versionutils
|
||||
from openstack_releases import xstaticutils
|
||||
|
||||
LOG = logging.getLogger()
|
||||
|
||||
@@ -944,6 +945,26 @@ def validate_version_numbers(deliv, context):
|
||||
)
|
||||
)
|
||||
|
||||
# If this is an xstatic package, ensure the package version in code
|
||||
# matches the tag being requested.
|
||||
if release_type == 'xstatic':
|
||||
LOG.debug('performing xstatic version checks')
|
||||
xs_versions = xstaticutils.get_versions(
|
||||
context.workdir, project.repo.name)
|
||||
if not xs_versions:
|
||||
context.error(
|
||||
'%s should contain a PACKAGE_VERSION but none found')
|
||||
for xs_version in xs_versions:
|
||||
if xs_version != release.version:
|
||||
context.error(
|
||||
'%s xstatic.pkg has PACKAGE_VERSION "%s" but is '
|
||||
'being tagged as "%s"' % (
|
||||
project.repo.name,
|
||||
xs_version,
|
||||
release.version,
|
||||
)
|
||||
)
|
||||
|
||||
# If we know the previous version and the
|
||||
# project is a python deliverable make sure
|
||||
# the requirements haven't changed in a way
|
||||
|
||||
45
openstack_releases/xstaticutils.py
Normal file
45
openstack_releases/xstaticutils.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import importlib
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def get_versions(workdir, repo):
|
||||
"""Get the package versions from packages."""
|
||||
versions = []
|
||||
|
||||
# Switch to the workdir
|
||||
start_path = os.getcwd()
|
||||
repo_dir = '%s/%s' % (workdir, repo)
|
||||
os.chdir(repo_dir)
|
||||
|
||||
# Add the repo to the PYTHONPATH so we can import its contents
|
||||
sys.path.append(repo_dir)
|
||||
|
||||
# Extract PACAKGE_VERSION from any xstatic packages found
|
||||
try:
|
||||
for name in os.listdir('xstatic/pkg'):
|
||||
if '__' in name:
|
||||
continue
|
||||
if os.path.isdir('xstatic/pkg/%s' % name):
|
||||
xs = importlib.import_module('xstatic.pkg.%s' % name)
|
||||
versions.append(xs.PACKAGE_VERSION)
|
||||
finally:
|
||||
# Get back to our original state
|
||||
sys.path.pop()
|
||||
os.chdir(start_path)
|
||||
|
||||
return versions
|
||||
Reference in New Issue
Block a user