Add linting to azure pipeline

This commit is contained in:
Matt 2020-10-03 20:03:28 -04:00
parent b5404f992e
commit c1d4ef81fc
2 changed files with 51 additions and 10 deletions

View file

@ -7,14 +7,29 @@ trigger:
include:
- '*'
steps:
# On every PR, build the addon and make it available for download as an artifact
- template: build.yml
parameters:
py_versions: [ 'py2', 'py3' ]
jobs:
- job: 'Validate'
pool:
vmImage: 'ubuntu-18.04'
strategy:
matrix:
Python27:
python.version: '2.7'
Python36:
python.version: '3.6'
steps:
# Run tests and linting
- template: validate.yml
# When triggered by a tag, publish the built addon to the repo server
- ${{ if startsWith(variables['Build.SourceBranch'], 'refs/tags') }}:
- template: publish.yml
parameters:
py_versions: [ 'py2', 'py3' ]
- job: Build
steps:
# On every PR, build the addon and make it available for download as an artifact
- template: build.yml
parameters:
py_versions: [ 'py2', 'py3' ]
# When triggered by a tag, publish the built addon to the repo server
- ${{ if startsWith(variables['Build.SourceBranch'], 'refs/tags') }}:
- template: publish.yml
parameters:
py_versions: [ 'py2', 'py3' ]

26
.ci/validate.yml Normal file
View file

@ -0,0 +1,26 @@
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
- script: python -m pip install -r requirements-dev.txt
displayName: 'Install dev tools'
- script: |
rm flake8.output
flake8 . --statistics --output-file=flake8.output && echo "::set-output name=lint::ok" || echo "::set-output name=lint::error"
cat flake8.output | awk -F: '{ if ($0 ~ /^\./) { gsub(/^[ \t]+/,"",$4); print "::error file=" $1 ",line=" $2 ",col=" $3 "::" $4 } else { print $0 } }'
displayName: 'Run Linter'
failOnStderr: false
- script: |
rm ../test_results.xml
pytest --junitxml=../test_results.xml
displayName: 'Run Tests'
failOnStderr: false
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: '../test_results.xml'
testRunTitle: 'Publish test results for Python $(python.version)'