ci: separate unittests and e2e into separate runs, combine afterwards

This commit is contained in:
Jens Langhammer 2020-07-10 17:12:37 +02:00
parent 40e794099a
commit 723a825085
2 changed files with 69 additions and 9 deletions

View file

@ -1,12 +1,12 @@
[run] [run]
source = passbook source = passbook
branch = True
relative_files = True
omit = omit =
*/wsgi.py */wsgi.py
manage.py manage.py
*/migrations/* */migrations/*
*/apps.py */apps.py
passbook/management/commands/web.py
passbook/management/commands/worker.py
docs/ docs/
[report] [report]

View file

@ -117,7 +117,38 @@ stages:
- task: CmdLine@2 - task: CmdLine@2
inputs: inputs:
script: pipenv run ./manage.py migrate script: pipenv run ./manage.py migrate
- job: coverage - job: coverage-unittest
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.8'
- task: DockerCompose@0
displayName: Run services
inputs:
dockerComposeFile: 'scripts/docker-compose.yml'
action: 'Run services'
buildImages: false
- task: CmdLine@2
inputs:
script: |
sudo pip install -U wheel pipenv
pipenv install --dev
- task: CmdLine@2
displayName: Run full test suite
inputs:
script: |
pipenv run coverage run ./manage.py test --failfast passbook
mkdir output-unittest
mv unittest.xml output-unittest/unittest.xml
mv .coverage output-unittest/coverage
- task: PublishPipelineArtifact@1
inputs:
targetPath: 'coverage-unittest'
artifact: 'output-unittest/'
publishLocation: 'pipeline'
- job: coverage-e2e
pool: pool:
vmImage: 'ubuntu-latest' vmImage: 'ubuntu-latest'
steps: steps:
@ -150,17 +181,46 @@ stages:
- task: CmdLine@2 - task: CmdLine@2
displayName: Run full test suite displayName: Run full test suite
inputs: inputs:
script: pipenv run coverage run ./manage.py test --failfast script: |
- task: PublishBuildArtifacts@1 pipenv run coverage run ./manage.py test --failfast e2e
mkdir output-e2e
mv unittest.xml output-e2e/unittest.xml
mv .coverage output-e2e/coverage
- task: PublishPipelineArtifact@1
condition: failed() condition: failed()
displayName: Upload screenshots if selenium tests fail displayName: Upload screenshots if selenium tests fail
inputs: inputs:
PathtoPublish: 'selenium_screenshots/' targetPath: 'selenium_screenshots/'
ArtifactName: 'drop' artifact: 'selenium screenshots'
publishLocation: 'Container' publishLocation: 'pipeline'
- task: PublishPipelineArtifact@1
inputs:
targetPath: 'coverage-e2e'
artifact: 'output-e2e/'
publishLocation: 'pipeline'
- stage: Test (combine)
jobs:
- job: test_coverage_combine
pool:
vmImage: 'ubuntu-latest'
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'coverage-e2e'
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'coverage-unittest'
- task: UsePythonVersion@0
inputs:
versionSpec: '3.8'
- task: CmdLine@2 - task: CmdLine@2
inputs: inputs:
script: | script: |
sudo pip install -U wheel pipenv
pipenv install --dev
pipenv run combine coverage-e2e/coverage coverage-unittest/coverage
pipenv run coverage xml pipenv run coverage xml
pipenv run coverage html pipenv run coverage html
- task: PublishCodeCoverageResults@1 - task: PublishCodeCoverageResults@1
@ -171,7 +231,7 @@ stages:
condition: succeededOrFailed() condition: succeededOrFailed()
inputs: inputs:
testRunTitle: 'Publish test results for Python $(python.version)' testRunTitle: 'Publish test results for Python $(python.version)'
testResultsFiles: 'unittest.xml' testResultsFiles: 'coverage-e2e/unittest.xml:coverage-unittest/unittest.xml'
- task: CmdLine@2 - task: CmdLine@2
env: env:
CODECOV_TOKEN: $(CODECOV_TOKEN) CODECOV_TOKEN: $(CODECOV_TOKEN)