2023-05-25 10:52:29 +01:00
|
|
|
trigger:
|
|
|
|
|
- main
|
|
|
|
|
- dev
|
|
|
|
|
- feature/*
|
|
|
|
|
- hotfix/*
|
|
|
|
|
- bugfix/*
|
|
|
|
|
- release/*
|
|
|
|
|
|
2023-11-30 19:21:11 +00:00
|
|
|
pr:
|
2023-12-02 19:46:04 +00:00
|
|
|
autoCancel: true
|
|
|
|
|
drafts: false
|
2023-07-11 08:05:38 +00:00
|
|
|
parameters:
|
|
|
|
|
# https://stackoverflow.com/a/70046417
|
|
|
|
|
- name: matrix
|
|
|
|
|
type: object
|
|
|
|
|
default:
|
2025-03-14 09:59:58 +00:00
|
|
|
- job_name: 'UbuntuPython39'
|
|
|
|
|
py: 'v3.9'
|
|
|
|
|
img: 'ubuntu-latest'
|
|
|
|
|
every_time: false
|
|
|
|
|
publish_coverage: false
|
2025-01-21 13:08:36 +00:00
|
|
|
- job_name: 'UbuntuPython310'
|
2025-03-14 09:51:59 +00:00
|
|
|
py: 'v3.10'
|
2023-07-11 08:22:30 +00:00
|
|
|
img: 'ubuntu-latest'
|
2023-07-11 08:53:37 +00:00
|
|
|
every_time: true
|
2023-12-07 10:35:50 +00:00
|
|
|
publish_coverage: true
|
2025-03-14 09:59:58 +00:00
|
|
|
- job_name: 'UbuntuPython311'
|
|
|
|
|
py: 'v3.11'
|
|
|
|
|
img: 'ubuntu-latest'
|
|
|
|
|
every_time: false
|
|
|
|
|
publish_coverage: false
|
|
|
|
|
- job_name: 'WindowsPython39'
|
|
|
|
|
py: 'v3.9'
|
|
|
|
|
img: 'windows-latest'
|
|
|
|
|
every_time: false
|
|
|
|
|
publish_coverage: false
|
|
|
|
|
- job_name: 'WindowsPython311'
|
|
|
|
|
py: 'v3.11'
|
|
|
|
|
img: 'windows-latest'
|
|
|
|
|
every_time: false
|
|
|
|
|
publish_coverage: false
|
|
|
|
|
- job_name: 'MacOSPython39'
|
|
|
|
|
py: 'v3.9'
|
|
|
|
|
img: 'macOS-latest'
|
|
|
|
|
every_time: false
|
|
|
|
|
publish_coverage: false
|
|
|
|
|
- job_name: 'MacOSPython311'
|
|
|
|
|
py: 'v3.11'
|
|
|
|
|
img: 'macOS-latest'
|
|
|
|
|
every_time: false
|
|
|
|
|
publish_coverage: false
|
2023-05-25 10:52:29 +01:00
|
|
|
|
2023-07-11 08:05:38 +00:00
|
|
|
stages:
|
|
|
|
|
- stage: Test
|
|
|
|
|
jobs:
|
2023-07-11 08:22:30 +00:00
|
|
|
- ${{ each item in parameters.matrix }}:
|
2023-07-11 08:53:37 +00:00
|
|
|
- job: ${{ item.job_name }}
|
2023-12-04 11:34:17 +00:00
|
|
|
timeoutInMinutes: 90
|
|
|
|
|
cancelTimeoutInMinutes: 1
|
2023-07-11 08:53:37 +00:00
|
|
|
pool:
|
|
|
|
|
vmImage: ${{ item.img }}
|
2023-12-04 11:34:17 +00:00
|
|
|
condition: and(succeeded(), or( eq(variables['Build.Reason'], 'PullRequest'), ${{ item.every_time }} ))
|
2023-05-25 10:52:29 +01:00
|
|
|
|
2023-07-11 08:53:37 +00:00
|
|
|
steps:
|
|
|
|
|
- task: UsePythonVersion@0
|
|
|
|
|
inputs:
|
|
|
|
|
versionSpec: ${{ item.py }}
|
|
|
|
|
displayName: 'Use Python ${{ item.py }}'
|
2023-06-27 12:07:33 +00:00
|
|
|
|
2023-07-11 08:53:37 +00:00
|
|
|
- script: |
|
2025-01-21 13:08:36 +00:00
|
|
|
python -m pip install pre-commit>=6.1
|
2023-07-11 08:53:37 +00:00
|
|
|
pre-commit install
|
|
|
|
|
pre-commit run --all-files
|
|
|
|
|
displayName: 'Run pre-commits'
|
2023-05-25 10:52:29 +01:00
|
|
|
|
2023-07-11 08:53:37 +00:00
|
|
|
- script: |
|
|
|
|
|
python -m pip install --upgrade pip==23.0.1
|
|
|
|
|
pip install wheel==0.38.4 --upgrade
|
|
|
|
|
pip install build==0.10.0
|
|
|
|
|
pip install pytest-azurepipelines
|
|
|
|
|
displayName: 'Install build dependencies'
|
2023-05-25 10:52:29 +01:00
|
|
|
|
2023-07-11 08:53:37 +00:00
|
|
|
- script: |
|
|
|
|
|
python -m build
|
|
|
|
|
displayName: 'Build PrimAITE'
|
2023-07-03 12:44:01 +00:00
|
|
|
|
2023-07-11 08:53:37 +00:00
|
|
|
- script: |
|
|
|
|
|
PRIMAITE_WHEEL=$(ls ./dist/primaite*.whl)
|
2024-05-29 14:54:45 +01:00
|
|
|
python -m pip install $PRIMAITE_WHEEL[dev,rl]
|
2023-07-11 08:53:37 +00:00
|
|
|
displayName: 'Install PrimAITE'
|
|
|
|
|
condition: or(eq( variables['Agent.OS'], 'Linux' ), eq( variables['Agent.OS'], 'Darwin' ))
|
2023-05-25 10:52:29 +01:00
|
|
|
|
2023-07-11 08:53:37 +00:00
|
|
|
- script: |
|
2024-05-29 14:54:45 +01:00
|
|
|
forfiles /p dist\ /m *.whl /c "cmd /c python -m pip install @file[dev,rl]"
|
2023-07-11 08:53:37 +00:00
|
|
|
displayName: 'Install PrimAITE'
|
|
|
|
|
condition: eq( variables['Agent.OS'], 'Windows_NT' )
|
2023-06-08 08:39:00 +01:00
|
|
|
|
2023-07-11 08:53:37 +00:00
|
|
|
- script: |
|
|
|
|
|
primaite setup
|
|
|
|
|
displayName: 'Perform PrimAITE Setup'
|
|
|
|
|
|
2023-12-02 01:05:13 +00:00
|
|
|
- task: UseDotNet@2
|
|
|
|
|
displayName: 'Install dotnet dependencies'
|
|
|
|
|
inputs:
|
|
|
|
|
packageType: 'sdk'
|
|
|
|
|
version: '2.1.x'
|
|
|
|
|
|
2023-07-11 08:53:37 +00:00
|
|
|
- script: |
|
2024-07-29 15:15:15 +01:00
|
|
|
python run_test_and_coverage.py
|
2023-11-29 01:28:40 +00:00
|
|
|
displayName: 'Run tests and code coverage'
|
2023-12-01 09:13:17 +00:00
|
|
|
|
2024-07-02 00:00:20 +01:00
|
|
|
# Run the notebooks
|
2024-07-01 14:31:58 +01:00
|
|
|
- script: |
|
2024-07-02 00:28:59 +01:00
|
|
|
pytest --nbmake -n=auto src/primaite/notebooks --junit-xml=./notebook-tests/notebooks.xml
|
|
|
|
|
notebooks_exit_code=$?
|
2025-02-25 14:25:27 +00:00
|
|
|
# Fail step if exit code not equal to 0
|
|
|
|
|
if [ $notebooks_exit_code -ne 0 ]; then
|
2024-07-02 00:28:59 +01:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
displayName: 'Run notebooks on Linux and macOS'
|
|
|
|
|
condition: or(eq(variables['Agent.OS'], 'Linux'), eq(variables['Agent.OS'], 'Darwin'))
|
2024-07-02 00:00:20 +01:00
|
|
|
|
2024-07-02 00:25:30 +01:00
|
|
|
# Run notebooks
|
|
|
|
|
- script: |
|
|
|
|
|
pytest --nbmake -n=auto src/primaite/notebooks --junit-xml=./notebook-tests/notebooks.xml
|
2024-07-02 01:31:59 +01:00
|
|
|
set notebooks_exit_code=%ERRORLEVEL%
|
2025-02-25 14:25:27 +00:00
|
|
|
rem Fail step if exit code not equal to 0
|
2024-07-02 01:31:59 +01:00
|
|
|
if %notebooks_exit_code% NEQ 0 exit /b 1
|
2024-07-02 00:25:30 +01:00
|
|
|
displayName: 'Run notebooks on Windows'
|
|
|
|
|
condition: eq(variables['Agent.OS'], 'Windows_NT')
|
2024-07-01 14:31:58 +01:00
|
|
|
|
2023-12-01 10:32:48 +00:00
|
|
|
- task: PublishTestResults@2
|
|
|
|
|
condition: succeededOrFailed()
|
2024-07-01 12:21:05 +01:00
|
|
|
displayName: 'Publish Test Results'
|
2023-12-01 10:32:48 +00:00
|
|
|
inputs:
|
|
|
|
|
testRunner: JUnit
|
2024-07-01 14:31:58 +01:00
|
|
|
testResultsFiles: |
|
|
|
|
|
'junit/**.xml'
|
|
|
|
|
'notebook-tests/**.xml'
|
2023-12-01 10:32:48 +00:00
|
|
|
testRunTitle: 'Publish test results'
|
2024-02-06 18:58:50 +00:00
|
|
|
failTaskOnFailedTests: true
|
2023-12-01 10:32:48 +00:00
|
|
|
|
2023-12-01 15:59:34 +00:00
|
|
|
- publish: $(System.DefaultWorkingDirectory)/htmlcov/
|
2023-12-02 19:38:45 +00:00
|
|
|
# publish the html report - so we can debug the coverage if needed
|
2023-12-07 10:35:50 +00:00
|
|
|
condition: ${{ item.publish_coverage }} # should only be run once
|
2023-12-01 15:49:20 +00:00
|
|
|
artifact: coverage_report
|
|
|
|
|
|
2023-12-02 14:41:45 +00:00
|
|
|
- task: PublishCodeCoverageResults@2
|
2023-12-02 19:38:45 +00:00
|
|
|
# publish the code coverage so it can be viewed in the run coverage page
|
2023-12-07 10:35:50 +00:00
|
|
|
condition: ${{ item.publish_coverage }} # should only be run once
|
2023-12-02 14:17:34 +00:00
|
|
|
inputs:
|
|
|
|
|
codeCoverageTool: Cobertura
|
|
|
|
|
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
|