Edit pipeline to use runtime parameters

https://stackoverflow.com/a/70046417
This commit is contained in:
Marek Wolan
2023-07-11 08:05:38 +00:00
parent d8cfbc1042
commit 548ecf8e08

View File

@@ -6,41 +6,49 @@ trigger:
- bugfix/*
- release/*
strategy:
${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
matrix:
parameters:
# https://stackoverflow.com/a/70046417
- name: matrix
type: object
default:
UbuntuPython38:
python.version: '3.8'
imageName: 'ubuntu-latest'
py: '3.8'
img: 'ubuntu-latest'
only_pr: false
UbuntuPython310:
python.version: '3.10'
imageName: 'ubuntu-latest'
py: '3.10'
img: 'ubuntu-latest'
only_pr: true
WindowsPython38:
python.version: '3.8'
imageName: 'windows-latest'
py: '3.8'
img: 'windows-latest'
only_pr: false
WindowsPython310:
python.version: '3.10'
imageName: 'windows-latest'
py: '3.10'
img: 'windows-latest'
only_pr: false
MacOSPython38:
python.version: '3.8'
imageName: 'macOS-latest'
py: '3.8'
img: 'macOS-latest'
only_pr: false
MacOSPython310:
python.version: '3.10'
imageName: 'macOS-latest'
${{ if not(eq(variables['Build.Reason'], 'PullRequest')) }}:
matrix:
UbuntuPython310:
python.version: '3.10'
imageName: 'ubuntu-latest'
py: '3.10'
img: 'macOS-latest'
only_pr: false
stages:
- stage: Test
jobs:
- ${{ each item in parameters.matrix }}:
${{ if or(eq(variables['Build.Reason'], 'PullRequest'), item.value.on_pr) }}:
- job: ${{ item.Key }}
pool:
vmImage: $(imageName)
vmImage: ${{ item.Value.img }}
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
displayName: 'Use Python $(python.version)'
versionSpec: ${{ item.Value.py }}
displayName: 'Use Python ${{ item.Value.py }}'
- script: |
python -m pip install pre-commit