From faf7ad4bb3ea0781426603eb0c08ce0c97abeab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Mon, 5 Oct 2020 06:27:07 +0200 Subject: [PATCH] Improve validation pipeline --- .ci/validate.yml | 44 ++++++++++++++++++++++++++++++++++++++------ .gitignore | 2 ++ tox.ini | 3 ++- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/.ci/validate.yml b/.ci/validate.yml index 0cc73368..a4313c3e 100644 --- a/.ci/validate.yml +++ b/.ci/validate.yml @@ -7,20 +7,52 @@ steps: 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 } }' + # Azure pipelines: https://github.com/microsoft/azure-pipelines-tasks/blob/master/docs/authoring/commands.md + # GitHub actions: https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions + + rm -f flake8.output + flake8 . --statistics --output-file=flake8.output && { + echo "##vso[task.complete result=Succeeded;]" + } || { + echo "##vso[task.complete result=Failed;]" + } + + cat flake8.output | awk -F: '{ + if ($0 ~ /^\./) { + gsub(/^[ \t]+/,"",$4); + codesep=index($4, " "); + code=substr($4, 1, codesep-1); + msg=substr($4, codesep+1); + print "##vso[task.logissue type=error;sourcepath=" $1 ";linenumber=" $2 ";columnnumber=" $3 ";code=" code ";]" msg; + } else { + print $0 + } + }' displayName: 'Run Linter' failOnStderr: false - script: | - rm ../test_results.xml - pytest --junitxml=../test_results.xml + rm -f test.xml coverage.xml + coverage run && { + echo "##vso[task.complete result=Succeeded;]" + } || { + echo "##vso[task.complete result=Failed;]" + } + coverage xml + coverage html + coverage report displayName: 'Run Tests' failOnStderr: false + condition: succeededOrFailed() - task: PublishTestResults@2 condition: succeededOrFailed() inputs: - testResultsFiles: '../test_results.xml' + testResultsFiles: 'test.xml' testRunTitle: 'Publish test results for Python $(python.version)' + + - task: PublishCodeCoverageResults@1 + condition: succeededOrFailed() + inputs: + codeCoverageTool: 'cobertura' + summaryFileLocation: 'coverage.xml' diff --git a/.gitignore b/.gitignore index d7548765..fa83b3a9 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,8 @@ coverage.xml *.py,cover .hypothesis/ .pytest_cache/ +flake8.output +test.xml # Translations *.mo diff --git a/tox.ini b/tox.ini index ae876e22..fdb7a179 100644 --- a/tox.ini +++ b/tox.ini @@ -21,4 +21,5 @@ source = service.py .config/generate_xml.py omit = tests/* -command_line = -m pytest +branch = True +command_line = -m pytest --junitxml=test.xml