Merge pull request #406 from mcarlton00/lint-the-things

Add linting to azure pipeline
This commit is contained in:
mcarlton00 2020-10-03 22:34:01 -04:00 committed by GitHub
commit 224def393b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 10 deletions

View file

@ -7,14 +7,29 @@ trigger:
include: include:
- '*' - '*'
steps: jobs:
# On every PR, build the addon and make it available for download as an artifact - job: 'Validate'
- template: build.yml pool:
parameters: vmImage: 'ubuntu-18.04'
py_versions: [ 'py2', 'py3' ] 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 - job: Build
- ${{ if startsWith(variables['Build.SourceBranch'], 'refs/tags') }}: steps:
- template: publish.yml # On every PR, build the addon and make it available for download as an artifact
parameters: - template: build.yml
py_versions: [ 'py2', 'py3' ] 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)'