Merged PR 114: Change build pipeline to only run once on commits
## Summary Unfortunately, I had to do away with the nice and neat matrix strategy for builds, because they do not support conditionals. Instead, I manually replicated the behaviour of the matrix but added a conditional to run every platform only when the 'build reason' is PR. ## Test process *How have you tested this (if applicable)?* ## Checklist - [x] This PR is linked to a **work item** - [x] I have performed **self-review** of the code - [ ] I have written **tests** for any new functionality added with this PR - [ ] I have updated the **documentation** if this PR changes or adds functionality - [x] I have run **pre-commit** checks for code style Related work items: #1603
This commit is contained in:
@@ -6,69 +6,85 @@ trigger:
|
|||||||
- bugfix/*
|
- bugfix/*
|
||||||
- release/*
|
- release/*
|
||||||
|
|
||||||
strategy:
|
parameters:
|
||||||
matrix:
|
# https://stackoverflow.com/a/70046417
|
||||||
UbuntuPython38:
|
- name: matrix
|
||||||
python.version: '3.8'
|
type: object
|
||||||
imageName: 'ubuntu-latest'
|
default:
|
||||||
UbuntuPython310:
|
- job_name: 'UbuntuPython38'
|
||||||
python.version: '3.10'
|
py: '3.8'
|
||||||
imageName: 'ubuntu-latest'
|
img: 'ubuntu-latest'
|
||||||
WindowsPython38:
|
every_time: false
|
||||||
python.version: '3.8'
|
- job_name: 'UbuntuPython310'
|
||||||
imageName: 'windows-latest'
|
py: '3.10'
|
||||||
WindowsPython310:
|
img: 'ubuntu-latest'
|
||||||
python.version: '3.10'
|
every_time: true
|
||||||
imageName: 'windows-latest'
|
- job_name: 'WindowsPython38'
|
||||||
MacOSPython38:
|
py: '3.8'
|
||||||
python.version: '3.8'
|
img: 'windows-latest'
|
||||||
imageName: 'macOS-latest'
|
every_time: false
|
||||||
MacOSPython310:
|
- job_name: 'WindowsPython310'
|
||||||
python.version: '3.10'
|
py: '3.10'
|
||||||
imageName: 'macOS-latest'
|
img: 'windows-latest'
|
||||||
|
every_time: false
|
||||||
|
- job_name: 'MacOSPython38'
|
||||||
|
py: '3.8'
|
||||||
|
img: 'macOS-latest'
|
||||||
|
every_time: false
|
||||||
|
- job_name: 'MacOSPython310'
|
||||||
|
py: '3.10'
|
||||||
|
img: 'macOS-latest'
|
||||||
|
every_time: false
|
||||||
|
|
||||||
pool:
|
stages:
|
||||||
vmImage: $(imageName)
|
- stage: Test
|
||||||
|
jobs:
|
||||||
|
- ${{ each item in parameters.matrix }}:
|
||||||
|
- job: ${{ item.job_name }}
|
||||||
|
pool:
|
||||||
|
vmImage: ${{ item.img }}
|
||||||
|
|
||||||
steps:
|
condition: or( eq(variables['Build.Reason'], 'PullRequest'), ${{ item.every_time }} )
|
||||||
- task: UsePythonVersion@0
|
|
||||||
inputs:
|
|
||||||
versionSpec: '$(python.version)'
|
|
||||||
displayName: 'Use Python $(python.version)'
|
|
||||||
|
|
||||||
- script: |
|
steps:
|
||||||
python -m pip install pre-commit
|
- task: UsePythonVersion@0
|
||||||
pre-commit install
|
inputs:
|
||||||
pre-commit run --all-files
|
versionSpec: ${{ item.py }}
|
||||||
displayName: 'Run pre-commits'
|
displayName: 'Use Python ${{ item.py }}'
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
python -m pip install --upgrade pip==23.0.1
|
python -m pip install pre-commit
|
||||||
pip install wheel==0.38.4 --upgrade
|
pre-commit install
|
||||||
pip install setuptools==66 --upgrade
|
pre-commit run --all-files
|
||||||
pip install build==0.10.0
|
displayName: 'Run pre-commits'
|
||||||
pip install pytest-azurepipelines
|
|
||||||
displayName: 'Install build dependencies'
|
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
python -m build
|
python -m pip install --upgrade pip==23.0.1
|
||||||
displayName: 'Build PrimAITE'
|
pip install wheel==0.38.4 --upgrade
|
||||||
|
pip install setuptools==66 --upgrade
|
||||||
|
pip install build==0.10.0
|
||||||
|
pip install pytest-azurepipelines
|
||||||
|
displayName: 'Install build dependencies'
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
PRIMAITE_WHEEL=$(ls ./dist/primaite*.whl)
|
python -m build
|
||||||
python -m pip install $PRIMAITE_WHEEL[dev]
|
displayName: 'Build PrimAITE'
|
||||||
displayName: 'Install PrimAITE'
|
|
||||||
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_WHEEL=$(ls ./dist/primaite*.whl)
|
||||||
displayName: 'Install PrimAITE'
|
python -m pip install $PRIMAITE_WHEEL[dev]
|
||||||
condition: eq( variables['Agent.OS'], 'Windows_NT' )
|
displayName: 'Install PrimAITE'
|
||||||
|
condition: or(eq( variables['Agent.OS'], 'Linux' ), eq( variables['Agent.OS'], 'Darwin' ))
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
primaite setup
|
forfiles /p dist\ /m *.whl /c "cmd /c python -m pip install @file[dev]"
|
||||||
displayName: 'Perform PrimAITE Setup'
|
displayName: 'Install PrimAITE'
|
||||||
|
condition: eq( variables['Agent.OS'], 'Windows_NT' )
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
pytest tests/
|
primaite setup
|
||||||
displayName: 'Run tests'
|
displayName: 'Perform PrimAITE Setup'
|
||||||
|
|
||||||
|
- script: |
|
||||||
|
pytest tests/
|
||||||
|
displayName: 'Run tests'
|
||||||
|
|||||||
Reference in New Issue
Block a user