Merged PR 232: Allow cancelling jobs

## Summary
Fix the azure build pipeline job conditions to correctly stop the job if we cancel the build.

Related work items: #2103
This commit is contained in:
Marek Wolan
2023-12-07 13:49:08 +00:00

View File

@@ -18,36 +18,43 @@ parameters:
py: '3.8' py: '3.8'
img: 'ubuntu-latest' img: 'ubuntu-latest'
every_time: false every_time: false
publish_coverage: false
- job_name: 'UbuntuPython310' - job_name: 'UbuntuPython310'
py: '3.10' py: '3.10'
img: 'ubuntu-latest' img: 'ubuntu-latest'
every_time: true every_time: true
publish_coverage: true
- job_name: 'WindowsPython38' - job_name: 'WindowsPython38'
py: '3.8' py: '3.8'
img: 'windows-latest' img: 'windows-latest'
every_time: false every_time: false
publish_coverage: false
- job_name: 'WindowsPython310' - job_name: 'WindowsPython310'
py: '3.10' py: '3.10'
img: 'windows-latest' img: 'windows-latest'
every_time: false every_time: false
publish_coverage: false
- job_name: 'MacOSPython38' - job_name: 'MacOSPython38'
py: '3.8' py: '3.8'
img: 'macOS-latest' img: 'macOS-latest'
every_time: false every_time: false
publish_coverage: false
- job_name: 'MacOSPython310' - job_name: 'MacOSPython310'
py: '3.10' py: '3.10'
img: 'macOS-latest' img: 'macOS-latest'
every_time: false every_time: false
publish_coverage: false
stages: stages:
- stage: Test - stage: Test
jobs: jobs:
- ${{ each item in parameters.matrix }}: - ${{ each item in parameters.matrix }}:
- job: ${{ item.job_name }} - job: ${{ item.job_name }}
timeoutInMinutes: 90
cancelTimeoutInMinutes: 1
pool: pool:
vmImage: ${{ item.img }} vmImage: ${{ item.img }}
condition: and(succeeded(), or( eq(variables['Build.Reason'], 'PullRequest'), ${{ item.every_time }} ))
condition: or( eq(variables['Build.Reason'], 'PullRequest'), ${{ item.every_time }} )
steps: steps:
- task: UsePythonVersion@0 - task: UsePythonVersion@0
@@ -109,12 +116,12 @@ stages:
- publish: $(System.DefaultWorkingDirectory)/htmlcov/ - publish: $(System.DefaultWorkingDirectory)/htmlcov/
# publish the html report - so we can debug the coverage if needed # publish the html report - so we can debug the coverage if needed
condition: ${{ item.every_time }} # should only be run once condition: ${{ item.publish_coverage }} # should only be run once
artifact: coverage_report artifact: coverage_report
- task: PublishCodeCoverageResults@2 - task: PublishCodeCoverageResults@2
# publish the code coverage so it can be viewed in the run coverage page # publish the code coverage so it can be viewed in the run coverage page
condition: ${{ item.every_time }} # should only be run once condition: ${{ item.publish_coverage }} # should only be run once
inputs: inputs:
codeCoverageTool: Cobertura codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'