Merge "add validation for sdist building"

This commit is contained in:
Zuul 2018-08-10 09:31:34 +00:00 committed by Gerrit Code Review
commit 1bba892b3d
2 changed files with 56 additions and 1 deletions

View File

@ -713,6 +713,33 @@ def validate_tarball_base(deliv, context):
sdist, expected))
@applies_to_released
def validate_build_sdist(deliv, context):
"Can we build an sdist for a python project?"
release = deliv.releases[-1]
for project in release.projects:
version_exists = gitutils.commit_exists(
context.workdir, project.repo.name, release.version,
)
if version_exists:
print('version {} was already tagged, skipping'.format(
release.version))
continue
gitutils.safe_clone_repo(
context.workdir, project.repo.name, project.hash, context)
try:
pythonutils.build_sdist(
context.workdir, project.repo.name)
except Exception as err:
context.error(
'Failed to build sdist for {}: {}'.format(
project.repo.name, err))
@skip_existing_tags
@applies_to_released
def validate_pypi_readme(deliv, context):
@ -1779,6 +1806,7 @@ def main():
validate_release_type,
validate_pypi_permissions,
validate_pypi_readme,
validate_build_sdist,
validate_gitreview,
validate_release_sha_exists,
validate_existing_tags,

View File

@ -27,7 +27,7 @@ LOG = logging.getLogger(__name__)
def get_sdist_name(workdir, repo):
"Check out the code."
"Find the name of the sdist."
dest = os.path.join(workdir, repo)
setup_path = os.path.join(dest, 'setup.py')
if not os.path.exists(setup_path):
@ -59,6 +59,33 @@ def get_sdist_name(workdir, repo):
return name
def build_sdist(workdir, repo):
"Build the sdist."
dest = os.path.join(workdir, repo)
setup_path = os.path.join(dest, 'setup.py')
if not os.path.exists(setup_path):
LOG.debug('did not find %s, maybe %s is not a python project',
setup_path, repo)
return
use_tox = repo.endswith('/pbr')
if use_tox and not os.path.exists(os.path.join(dest, '.tox', 'venv')):
# Use tox to set up a virtualenv so we can install the
# dependencies for the package. This only seems to be
# necessary for pbr, but...
processutils.check_output(
['tox', '-e', 'venv', '--notest'],
cwd=dest,
)
if use_tox:
python = '.tox/venv/bin/python'
else:
python = 'python'
# Run it once and discard the result to ensure any setup_requires
# dependencies are installed.
cmd = [python, 'setup.py', 'sdist', 'bdist_wheel']
processutils.check_call(cmd, cwd=dest)
def check_readme_format(workdir, repo):
"Verify that the README format looks OK."
dest = os.path.join(workdir, repo)