Skip to content

Commit

Permalink
Add CI templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Jianjie Liu (MAIDAP) committed Jan 28, 2021
1 parent cc31cf5 commit 7ae1d6c
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 0 deletions.
58 changes: 58 additions & 0 deletions devops/pr-gate-os.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: $(Date:yyyyMMdd).$(Rev:r)

strategy:
matrix:
linux_x64_py3.6:
imageName: 'ubuntu-18.04'
pyVersion: '3.6'

# windows_x64_py3.6:
# imageName: 'windows-2019'
# pyVersion: '3.6'

# macos_x64_py3.6:
# imageName: 'macOS-10.14'
# pyVersion: '3.6'

# To build using more python versions follow the syntax below:
# linux_x64_py3.5:
# imageName: 'ubuntu-16.04'
# pyVersion: '3.5'

pool:
vmImage: '$(imageName)'

steps:
- template: templates/run-linter.yml
parameters:
pyVersion: $(python.version)

- template: templates/run-tests.yml
parameters:
testType: 'unit'
imageName: $(imageName)
pyVersion: $(python.version)

# - template: templates/run-tests.yml
# parameters:
# testType: 'azure'
# imageName: $(imageName)
# pyVersion: $(python.version)

# - bash: |
# python setup.py bdist_wheel --build-number $(Build.BuildNumber) --dist-dir dist
# workingDirectory: $(Build.SourcesDirectory)
# displayName: 'Building wheel package'

# - bash: |
# mkdir $BUILD_ARTIFACTSTAGINGDIRECTORY/py$(python.version)/
# cp -r dist/* $BUILD_ARTIFACTSTAGINGDIRECTORY/py$(python.version)/
# workingDirectory: $(Build.SourcesDirectory)
# displayName: 'Copying builds to artifact staging dir'

# - task: PublishBuildArtifacts@1
# inputs:
# PathtoPublish: $(Build.ArtifactStagingDirectory)
# ArtifactName: genalog
# publishLocation: 'Container'
# displayName: 'Publish build as artifacts'
24 changes: 24 additions & 0 deletions devops/templates/run-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Template for running linter and other static analysis tools on the code
parameters:
- name: pyVersion
type: string
default: 3.6

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(pyVersion)'
addToPath: true
architecture: 'x64'
displayName: 'Use Python $(pyVersion)'

- bash: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements-dev.txt
workingDirectory: $(Build.SourcesDirectory)
displayName: 'Install flake8 and other dev dependencies'

- bash: |
tox -e flake8
workingDirectory: $(Build.SourcesDirectory)
displayName: 'Run Linter (flake8)'
63 changes: 63 additions & 0 deletions devops/templates/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Template for running tests on multiple Python versions and platforms

parameters:
- name: imageName
type: string
- name: testType
type: string
default: all
values:
- slow
- azure
- unit
- all
- name: pyVersion
type: string
default: 3.6

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(pyVersion)'
addToPath: true
architecture: 'x64'
displayName: 'Use Python $(pyVersion)'

- bash: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements.txt
python -m pip install -r requirements-dev.txt
workingDirectory: $(Build.SourcesDirectory)
displayName: 'Install dependencies'

- bash: |
if [[ '${{parameters.testType}}' == 'all' ]]
then
tox -e py
elif [[ '${{parameters.testType}}' == 'unit' ]]
then
tox -e py -- -m "not slow and not azure"
else
tox -e py -- -m "${{parameters.testType}}"
fi
env:
BLOB_KEY : $(BLOB_KEY)
SEARCH_SERVICE_KEY: $(SEARCH_SERVICE_KEY)
COGNITIVE_SERVICE_KEY: $(COGNITIVE_SERVICE_KEY)
COMPUTER_VISION_SUBSCRIPTION_KEY: $(COMPUTER_VISION_SUBSCRIPTION_KEY)
workingDirectory: $(Build.SourcesDirectory)
displayName: 'Test via tox'

- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: 'junit/*.xml'
searchFolder: $(Build.SourcesDirectory)
testRunTitle: $(imageName)_$(pyVersion) Build
buildPlatform: $(imageName)
displayName: 'Publish unit test report'

- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/**/coverage.xml'

0 comments on commit 7ae1d6c

Please sign in to comment.