From 13599aaba6413a77707cd0202c956913b303455c Mon Sep 17 00:00:00 2001 From: Willie Xu Date: Fri, 20 Jul 2018 11:44:35 -0700 Subject: [PATCH] removed static check for py2 and only run tests for extensions that have been edited (#244) --- .travis.yml | 8 ++------ scripts/ci/test_source.py | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 93a017c66a2..b145a478431 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,6 @@ install: - pip install pylint==1.9.2 flake8 requests wheel==0.30.0 -q jobs: include: - - stage: precheck - env: PURPOSE='SourceStatic' - script: ./scripts/ci/test_static.sh - python: 2.7 - stage: precheck env: PURPOSE='SourceStatic' script: ./scripts/ci/test_static.sh @@ -21,11 +17,11 @@ jobs: python: 3.6 - stage: verify env: PURPOSE='SourceTests' - script: travis_wait 40 ./scripts/ci/test_source.sh + script: ./scripts/ci/test_source.sh python: 2.7 - stage: verify env: PURPOSE='SourceTests' - script: travis_wait 40 ./scripts/ci/test_source.sh + script: ./scripts/ci/test_source.sh python: 3.6 - stage: verify env: PURPOSE='IndexRefDocVerify' diff --git a/scripts/ci/test_source.py b/scripts/ci/test_source.py index d4e4fb9db56..6cc356d5f15 100755 --- a/scripts/ci/test_source.py +++ b/scripts/ci/test_source.py @@ -25,11 +25,18 @@ for src_d in os.listdir(SRC_PATH): src_d_full = os.path.join(SRC_PATH, src_d) - if os.path.isdir(src_d_full): - pkg_name = next((d for d in os.listdir(src_d_full) if d.startswith('azext_')), None) - # 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)) + if not os.path.isdir(src_d_full): + continue + pkg_name = next((d for d in os.listdir(src_d_full) if d.startswith('azext_')), None) + + # If running in Travis CI, only run tests for edited extensions + commit_range = os.environ.get('TRAVIS_COMMIT_RANGE') + if commit_range and not check_output(['git', '--no-pager', 'diff', '--name-only', commit_range, '--', src_d_full]): + 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)) class TestExtensionSourceMeta(type):