From ddaf1c29366399a61ae9aa1678293e342079f23f Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Fri, 21 Feb 2020 17:35:12 -0800 Subject: CI: move lint & tests job into templates Splitting steps into several files makes the YAML more maintainable. --- ci/lint-test.yml | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 ci/lint-test.yml (limited to 'ci/lint-test.yml') diff --git a/ci/lint-test.yml b/ci/lint-test.yml new file mode 100644 index 0000000..3c3eae6 --- /dev/null +++ b/ci/lint-test.yml @@ -0,0 +1,41 @@ +steps: + - script: | + docker exec snekbox_test /bin/bash -c \ + 'pipenv run lint --format junit-xml --output-file test-lint.xml' + displayName: 'Run Linter' + + - task: PublishTestResults@2 + displayName: 'Publish Lint Results' + condition: succeededOrFailed() + inputs: + testResultsFiles: '**/test-lint.xml' + testRunTitle: 'Lint Results' + + # Memory limit tests would fail if this isn't disabled. + - script: sudo swapoff -a + displayName: 'Disable Swap Memory' + + - script: | + docker exec snekbox_test /bin/bash -c \ + 'pipenv run coverage run -m xmlrunner' + displayName: 'Run Unit Tests' + + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + condition: succeededOrFailed() + inputs: + testResultsFiles: '**/TEST-*.xml' + testRunTitle: 'Test Results' + + # Run report too because the XML report doesn't output to stdout. + - script: | + docker exec snekbox_test /bin/bash -c \ + 'pipenv run /bin/bash -c "coverage report && coverage xml"' + displayName: 'Generate Coverage Report' + + - task: PublishCodeCoverageResults@1 + displayName: 'Publish Coverage Results' + condition: succeededOrFailed() + inputs: + codeCoverageTool: Cobertura + summaryFileLocation: '**/coverage.xml' -- cgit v1.2.3 From 01abcb67ef3efc52edcfa302377137b46007287f Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Sat, 22 Feb 2020 21:24:52 -0800 Subject: CI: don't run commands through pipenv Since #62, the dependencies have been installed to the system interpreter. Therefore, it's not necessary to run through pipenv to ensure the commands run through an activated virtual environment. This should also fix pipenv run creating a virtual environment. It seems it cannot tell when it should be using the system interpreter. It probably wasn't designed for that anyway i.e. the intent was to run commands directly in such case, which is what this PR will do. --- ci/lint-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ci/lint-test.yml') diff --git a/ci/lint-test.yml b/ci/lint-test.yml index 3c3eae6..6350fde 100644 --- a/ci/lint-test.yml +++ b/ci/lint-test.yml @@ -1,7 +1,7 @@ steps: - script: | docker exec snekbox_test /bin/bash -c \ - 'pipenv run lint --format junit-xml --output-file test-lint.xml' + 'flake8 --format junit-xml --output-file test-lint.xml' displayName: 'Run Linter' - task: PublishTestResults@2 @@ -17,7 +17,7 @@ steps: - script: | docker exec snekbox_test /bin/bash -c \ - 'pipenv run coverage run -m xmlrunner' + 'coverage run -m xmlrunner' displayName: 'Run Unit Tests' - task: PublishTestResults@2 @@ -30,7 +30,7 @@ steps: # Run report too because the XML report doesn't output to stdout. - script: | docker exec snekbox_test /bin/bash -c \ - 'pipenv run /bin/bash -c "coverage report && coverage xml"' + 'coverage report && coverage xml' displayName: 'Generate Coverage Report' - task: PublishCodeCoverageResults@1 -- cgit v1.2.3 From 692c75a470682a97947bcd060b153ed757626805 Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Sat, 22 Feb 2020 21:32:41 -0800 Subject: CI: output flake8 to stdout (resolve #37) The Azure website has proven to not be reliable for displaying the JUnit output. Furthermore, some may simply prefer the format of the output in the terminal over the JUnit representation on the Azure site. Nevertheless, the JUnit output isn't that bad (when there's actually a lint error) so it will remain for now. It also provides historical statistics on occurrences of errors, which is kind of cool, I guess... --- ci/lint-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ci/lint-test.yml') diff --git a/ci/lint-test.yml b/ci/lint-test.yml index 6350fde..2d70f6e 100644 --- a/ci/lint-test.yml +++ b/ci/lint-test.yml @@ -1,7 +1,7 @@ steps: - script: | docker exec snekbox_test /bin/bash -c \ - 'flake8 --format junit-xml --output-file test-lint.xml' + 'flake8; flake8 --format junit-xml --output-file test-lint.xml' displayName: 'Run Linter' - task: PublishTestResults@2 -- cgit v1.2.3