Skip to content

Commit

Permalink
* leverage twine chk instead of setup.py check
Browse files Browse the repository at this point in the history
* adding installation of readme-renderer[md] to resolve warning during twine check
* adding capability to ignore certain warnings coming back from utility tools
  • Loading branch information
scbedd committed Feb 8, 2019
1 parent 2c53502 commit cbe3397
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
16 changes: 14 additions & 2 deletions .azure-pipelines/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,33 @@ jobs:
versionSpec: 3.6

- script: |
pip install wheel setuptools pathlib Jinja2
pip install wheel setuptools pathlib Jinja2 twine readme-renderer[md]
displayName: 'Prep Environment'
- task: PythonScript@0
displayName: 'Analyze dependencies'
inputs:
scriptPath: 'scripts/analyze_deps.py'
arguments: '--verbose --out "$(Build.ArtifactStagingDirectory)/dependencies.html"'
arguments: '--verbose --out "$(Build.SourcesDirectory)/dependencies.html"'

- task: PythonScript@0
displayName: 'Generate Packages'
inputs:
scriptPath: 'scripts/devops_tasks/build_packages.py'
arguments: '-d "$(Build.ArtifactStagingDirectory)" "$(build_targeting_string)"'

- script: |
twine check $(Build.ArtifactStagingDirectory)/*
displayName: 'Verify Readme'
- task: CopyFiles@2
displayName: 'Move Dependencies Report to Build Artifacts'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: dependencies.html
TargetFolder: '$(Build.ArtifactStagingDirectory)'
condition: always()

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifacts'
condition: succeededOrFailed()
Expand Down
6 changes: 4 additions & 2 deletions scripts/devops_tasks/common_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pathlib import Path
from subprocess import check_call, CalledProcessError
import os
import sys

DEFAULT_BUILD_PACKAGES = ['azure-keyvault', 'azure-servicebus']

Expand All @@ -32,10 +33,11 @@ def process_glob_string(glob_string, target_root_dir):
# dedup, in case we have double coverage from the glob strings. Example: "azure-mgmt-keyvault,azure-mgmt-*"
return list(set(collected_top_level_directories))

def run_check_call(command_array, working_directory):
def run_check_call(command_array, working_directory, acceptable_return_codes = []):
print('Command Array: {0}, Target Working Directory: {1}'.format(command_array, working_directory))
try:
check_call(command_array, cwd = working_directory)
except CalledProcessError as err:
print(err) #, file = sys.stderr
sys.exit(1)
if err.returncode not in acceptable_return_codes:
sys.exit(1)
11 changes: 5 additions & 6 deletions scripts/devops_tasks/setup_execute_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@
root_dir = os.path.abspath(os.path.join(os.path.abspath(__file__), '..', '..', '..'))
dev_setup_script_location = os.path.join(root_dir, 'scripts/dev_setup.py')

# a return code of 5 from pytest == no tests run
# evaluating whether we want this or not.
ALLOWED_RETURN_CODES = []

def prep_and_run_tests(targeted_packages, python_version):
print('running test setup for {}'.format(targeted_packages))
run_check_call([python_version, dev_setup_script_location, '-p', ','.join([os.path.basename(package_path) for package_path in targeted_packages])], root_dir)

print('Setup complete. Running pytest for {}'.format(targeted_packages))
command_array = [python_version, '-m', 'pytest']
command_array.extend(targeted_packages)
run_check_call(command_array, root_dir)

for package_path in targeted_packages:
print('Checking setup.py for {}'.format(os.path.join(package_path, 'setup.py')))
run_check_call([python_version, 'setup.py', 'check', '-r', '-s'], package_path)

run_check_call(command_array, root_dir, ALLOWED_RETURN_CODES)

if __name__ == '__main__':
parser = argparse.ArgumentParser(description = 'Install Dependencies, Install Packages, Test Azure Packages, Called from DevOps YAML Pipeline')
Expand Down

0 comments on commit cbe3397

Please sign in to comment.