Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI conversion #867

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 0 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@ install:
- pip install pylint==1.9.2 flake8==3.5.0 requests wheel==0.30.0 -q
jobs:
include:
- stage: precheck
env: PURPOSE='SourceStatic'
script: ./scripts/ci/test_static.sh
python: 3.6
- stage: precheck
env: PURPOSE='SourceStaticPy'
script: python ./scripts/ci/test_static.py
python: 3.6
- stage: verify
env: PURPOSE='IndexVerify'
script: python ./scripts/ci/test_index.py -v
python: 3.6
- stage: verify
env: PURPOSE='SourceTests'
script: ./scripts/ci/test_source.sh
Expand All @@ -27,14 +15,6 @@ jobs:
env: PURPOSE='SourceTests'
script: ./scripts/ci/test_source.sh
python: 3.6
- stage: verify
env: PURPOSE='Load and Lint Modified Index Entries'
script: ./scripts/ci/verify_modified_index.sh
python: 3.6
- stage: verify
env: PURPOSE='IndexRefDocVerify'
script: ./scripts/ci/test_index_ref_doc.sh
python: 3.6
- stage: publish
script: |
docker run \
Expand Down
127 changes: 64 additions & 63 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
resources:
- repo: self

trigger:
batch: true
branches:
include:
- '*'

jobs:
# - job: SourceStatic
# displayName: "Source Code Static Check"
# pool:
# vmImage: 'ubuntu-16.04'
# steps:
# - task: UsePythonVersion@0
# displayName: 'Use Python 3.7'
# inputs:
# versionSpec: 3.7
# - task: Bash@3
# displayName: "Source Code Static Check"
# inputs:
# targetType: 'filePath'
# filePath: scripts/ci/test_static.sh

- job: SourceStatic
displayName: "Source Code Static Check"
pool:
vmImage: 'ubuntu-16.04'
steps:
- task: UsePythonVersion@0
displayName: 'Use Python 3.7'
inputs:
versionSpec: 3.7
- bash: |
#!/usr/bin/env bash
set -ev
export CI="ADO"
. ./scripts/ci/install_azdev.sh
azdev extension add '*'
azdev style EXT
azdev verify license
displayName: "Check Styles"
- job: IndexVerify
displayName: "Verify Extensions Index"
pool:
Expand All @@ -39,52 +40,52 @@ jobs:
export CI="ADO"
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: 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

# - 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

- 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
- bash: |
#!/usr/bin/env bash
set -ex
. ./scripts/ci/install_azdev.sh
python ./scripts/ci/test_source.py -v
displayName: "Tests Python 2.7"
- 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
- bash: |
#!/usr/bin/env bash
set -ex
. ./scripts/ci/install_azdev.sh
python ./scripts/ci/test_source.py -v
displayName: "Tests Python 3.7"
- job: LintModifiedExtensions
displayName: "Load and Lint Modified Index Entries"
pool:
vmImage: 'ubuntu-16.04'
steps:
- task: UsePythonVersion@0
displayName: 'Use Python 3.7'
inputs:
versionSpec: 3.7
- bash: |
#!/usr/bin/env bash
set -ex
export CI="ADO"
. ./scripts/ci/install_azdev.sh
. ./scripts/ci/verify_modified_index.sh
displayName: "Lint Modified Extensions"
- job: IndexRefDocVerify
displayName: "Verify Ref Docs"
pool:
Expand Down
12 changes: 12 additions & 0 deletions scripts/ci/install_azdev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -e

echo "Install azdev into virtual environment"
export CI="ADO"
pip install virtualenv
python -m virtualenv env
. env/bin/activate
pip install -U pip setuptools wheel -q
pip install git+https://github.com/Azure/azure-cli-dev-tools@ExtensionsCIEnhancements -q
azdev setup -c EDGE -r .
27 changes: 21 additions & 6 deletions scripts/ci/test_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,22 @@
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
ci = os.environ.get('CI')

if ci == 'TRAVIS':
# 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
elif ci == 'ADO':
source_branch = os.environ.get('BUILD_SOURCEBRANCH')
target_branch = os.environ.get('SYSTEM_PULLREQUEST_TARGETBRANCH')
commit_range = '{}..{}'.format(target_branch, source_branch)
print('COMMIT RANGE: {}'.format(commit_range))
if source_branch and target_branch and not check_output(['git', '--no-pager', 'diff', '--name-only', commit_range, '--', src_d_full]):
continue

# Find the package and check if 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))

Expand All @@ -47,13 +57,16 @@ def test(self):
ext_install_dir = os.path.join(self.ext_dir, 'ext')
pip_args = [sys.executable, '-m', 'pip', 'install', '--upgrade', '--target',
ext_install_dir, ext_path]
print(pip_args)
check_call(pip_args)
unittest_args = [sys.executable, '-m', 'unittest', 'discover', '-v', ext_path]
env = os.environ.copy()
env['PYTHONPATH'] = ext_install_dir
print(unittest_args)
check_call(unittest_args, env=env)
return test

print(ALL_TESTS)
for tname, ext_path in ALL_TESTS:
test_name = "test_%s" % tname
_dict[test_name] = gen_test(ext_path)
Expand All @@ -75,11 +88,13 @@ def tearDown(self):
class TestSourceWheels(unittest.TestCase):

def test_source_wheels(self):
print('TEST SOURCE WHEELS')
# Test we can build all sources into wheels and that metadata from the wheel is valid
built_whl_dir = tempfile.mkdtemp()
source_extensions = [os.path.join(SRC_PATH, n) for n in os.listdir(SRC_PATH)
if os.path.isdir(os.path.join(SRC_PATH, n))]
for s in source_extensions:
print('SOURCE EXT: {}'.format(s))
if not os.path.isfile(os.path.join(s, 'setup.py')):
continue
try:
Expand Down
146 changes: 0 additions & 146 deletions scripts/ci/test_static.py

This file was deleted.

Loading