From 6a68da526a56375919a674cbf82947cc52445b31 Mon Sep 17 00:00:00 2001 From: Jianhui Harold Date: Wed, 8 Jan 2020 10:54:51 +0800 Subject: [PATCH] [CI] Move 2, 3: Copy job SourceTests, LintModifiedExtensions from Travis to ADO (#1174) --- azure-pipelines.yml | 82 +++++++++++++++++++-------------------- scripts/ci/test_source.py | 10 +++++ 2 files changed, 50 insertions(+), 42 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index cc850215d9d..039342f9e7a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -66,50 +66,48 @@ jobs: python ./scripts/ci/test_index.py -v displayName: "Verify Extensions Index" -# - job: TestsPython27 -# displayName: "Tests Python 2.7" -# pool: -# vmImage: 'ubuntu-16.04' -# steps: -# - task: UsePythonVersion@0 -# displayName: 'Use Python 2.7' -# inputs: -# versionSpec: 2.7 -# - task: Bash@3 -# displayName: "Tests Python 2.7" -# inputs: -# targetType: 'filePath' -# filePath: scripts/ci/test_source.sh +- job: SourceTests + displayName: "Integration Tests, Build Tests" + pool: + vmImage: 'ubuntu-16.04' + strategy: + matrix: + Python36: + python.version: '3.6' + Python38: + python.version: '3.8' + steps: + - task: UsePythonVersion@0 + displayName: 'Use Python $(python.version)' + inputs: + versionSpec: '$(python.version)' + - bash: pip install wheel==0.30.0 + displayName: 'Install wheel==0.30.0' + - bash: ./scripts/ci/test_source.sh + displayName: 'Run integration test and build test' + env: + ADO_PULL_REQUEST_LATEST_COMMIT: $(System.PullRequest.SourceCommitId) + ADO_PULL_REQUEST_TARGET_BRANCH: $(System.PullRequest.TargetBranch) + +- job: LintModifiedExtensions + displayName: "CLI Linter on Modified Extensions" + pool: + vmImage: 'ubuntu-16.04' + steps: + - task: UsePythonVersion@0 + displayName: 'Use Python 3.6' + inputs: + versionSpec: 3.6 + - bash: | + set -ev -# - job: TestsPython37 -# displayName: "Tests Python 3.7" -# pool: -# vmImage: 'ubuntu-16.04' -# steps: -# - task: UsePythonVersion@0 -# displayName: 'Use Python 3.7' -# inputs: -# versionSpec: 3.7 -# - task: Bash@3 -# displayName: "Tests Python 3.7" -# inputs: -# targetType: 'filePath' -# filePath: scripts/ci/test_source.sh + # prepare and activate virtualenv + pip install virtualenv + python -m virtualenv venv/ + source ./venv/bin/activate -# - job: LintModifiedExtensions -# displayName: "CLI Linter on Modified Extensions" -# pool: -# vmImage: 'ubuntu-16.04' -# steps: -# - task: UsePythonVersion@0 -# displayName: 'Use Python 3.7' -# inputs: -# versionSpec: 3.7 -# - task: Bash@3 -# displayName: "CLI Linter on Modified Extension" -# inputs: -# targetType: 'filePath' -# filePath: scripts/ci/verify_modified_index.sh + ./scripts/ci/verify_modified_index.sh + displayName: "CLI Linter on Modified Extension" - job: IndexRefDocVerify displayName: "Verify Ref Docs" diff --git a/scripts/ci/test_source.py b/scripts/ci/test_source.py index 6cc356d5f15..95864e7e850 100755 --- a/scripts/ci/test_source.py +++ b/scripts/ci/test_source.py @@ -12,6 +12,7 @@ import tempfile import unittest import shutil +import shlex from subprocess import check_output, check_call, CalledProcessError import mock @@ -34,6 +35,15 @@ if commit_range and not check_output(['git', '--no-pager', 'diff', '--name-only', commit_range, '--', src_d_full]): continue + # Running in Azure DevOps + cmd_tpl = 'git --no-pager diff --name-only origin/{commit_start} {commit_end} {code_dir}' + ado_branch_last_commit = os.environ.get('ADO_PULL_REQUEST_LATEST_COMMIT') + ado_target_branch = os.environ.get('ADO_PULL_REQUEST_TARGET_BRANCH') + if ado_branch_last_commit and ado_target_branch: + cmd = cmd_tpl.format(commit_start=ado_target_branch, commit_end=ado_branch_last_commit, code_dir=src_d_full) + if not check_output(shlex.split(cmd)): + continue + # Find the package and check it has tests if pkg_name and os.path.isdir(os.path.join(src_d_full, pkg_name, 'tests')): ALL_TESTS.append((pkg_name, src_d_full))