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,75 +6,83 @@ trigger:
- bugfix/* - bugfix/*
- release/* - release/*
strategy: parameters:
${{ if eq(variables['Build.Reason'], 'PullRequest') }}: # https://stackoverflow.com/a/70046417
matrix: - name: matrix
type: object
default:
UbuntuPython38: UbuntuPython38:
python.version: '3.8' py: '3.8'
imageName: 'ubuntu-latest' img: 'ubuntu-latest'
only_pr: false
UbuntuPython310: UbuntuPython310:
python.version: '3.10' py: '3.10'
imageName: 'ubuntu-latest' img: 'ubuntu-latest'
only_pr: true
WindowsPython38: WindowsPython38:
python.version: '3.8' py: '3.8'
imageName: 'windows-latest' img: 'windows-latest'
only_pr: false
WindowsPython310: WindowsPython310:
python.version: '3.10' py: '3.10'
imageName: 'windows-latest' img: 'windows-latest'
only_pr: false
MacOSPython38: MacOSPython38:
python.version: '3.8' py: '3.8'
imageName: 'macOS-latest' img: 'macOS-latest'
only_pr: false
MacOSPython310: MacOSPython310:
python.version: '3.10' py: '3.10'
imageName: 'macOS-latest' img: 'macOS-latest'
${{ if not(eq(variables['Build.Reason'], 'PullRequest')) }}: only_pr: false
matrix:
UbuntuPython310:
python.version: '3.10'
imageName: 'ubuntu-latest'
pool: stages:
vmImage: $(imageName) - stage: Test
jobs:
- ${{ each item in parameters.matrix }}:
${{ if or(eq(variables['Build.Reason'], 'PullRequest'), item.value.on_pr) }}:
- job: ${{ item.Key }}
pool:
vmImage: ${{ item.Value.img }}
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: ${{ item.Value.py }}
displayName: 'Use Python ${{ item.Value.py }}'
steps: - script: |
- task: UsePythonVersion@0 python -m pip install pre-commit
inputs: pre-commit install
versionSpec: '$(python.version)' pre-commit run --all-files
displayName: 'Use Python $(python.version)' displayName: 'Run pre-commits'
- script: | - script: |
python -m pip install pre-commit python -m pip install --upgrade pip==23.0.1
pre-commit install pip install wheel==0.38.4 --upgrade
pre-commit run --all-files pip install setuptools==66 --upgrade
displayName: 'Run pre-commits' pip install build==0.10.0
pip install pytest-azurepipelines
displayName: 'Install build dependencies'
- script: | - script: |
python -m pip install --upgrade pip==23.0.1 python -m build
pip install wheel==0.38.4 --upgrade displayName: 'Build PrimAITE'
pip install setuptools==66 --upgrade
pip install build==0.10.0
pip install pytest-azurepipelines
displayName: 'Install build dependencies'
- script: | - script: |
python -m build PRIMAITE_WHEEL=$(ls ./dist/primaite*.whl)
displayName: 'Build PrimAITE' python -m pip install $PRIMAITE_WHEEL[dev]
displayName: 'Install PrimAITE'
condition: or(eq( variables['Agent.OS'], 'Linux' ), eq( variables['Agent.OS'], 'Darwin' ))
- script: | - script: |
PRIMAITE_WHEEL=$(ls ./dist/primaite*.whl) forfiles /p dist\ /m *.whl /c "cmd /c python -m pip install @file[dev]"
python -m pip install $PRIMAITE_WHEEL[dev] displayName: 'Install PrimAITE'
displayName: 'Install PrimAITE' condition: eq( variables['Agent.OS'], 'Windows_NT' )
condition: or(eq( variables['Agent.OS'], 'Linux' ), eq( variables['Agent.OS'], 'Darwin' ))
- script: | - script: |
forfiles /p dist\ /m *.whl /c "cmd /c python -m pip install @file[dev]" primaite setup
displayName: 'Install PrimAITE' displayName: 'Perform PrimAITE Setup'
condition: eq( variables['Agent.OS'], 'Windows_NT' )
- script: | - script: |
primaite setup pytest tests/
displayName: 'Perform PrimAITE Setup' displayName: 'Run tests'
- script: |
pytest tests/
displayName: 'Run tests'