From c1d4ef81fcee85e5c953c9e3d2b9dd2948edf044 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 3 Oct 2020 20:03:28 -0400 Subject: [PATCH] Add linting to azure pipeline --- .ci/azure-pipelines.yml | 35 +++++++++++++++++++++++++---------- .ci/validate.yml | 26 ++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 .ci/validate.yml diff --git a/.ci/azure-pipelines.yml b/.ci/azure-pipelines.yml index 25448ed1..a76bfc1d 100644 --- a/.ci/azure-pipelines.yml +++ b/.ci/azure-pipelines.yml @@ -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' ] diff --git a/.ci/validate.yml b/.ci/validate.yml new file mode 100644 index 00000000..0cc73368 --- /dev/null +++ b/.ci/validate.yml @@ -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)'