Files
PrimAITE/.azure/azure-ci-build-pipeline.yaml
2023-12-02 14:17:34 +00:00

150 lines
4.9 KiB
YAML

trigger:
- main
- dev
- feature/*
- hotfix/*
- bugfix/*
- release/*
pr:
autoCancel: true # automatically cancel PR if new push made
drafts: true # get triggered when doing drafts
branches:
include:
- main
- dev
- feature/*
- hotfix/*
- bugfix/*
- release/*
parameters:
# https://stackoverflow.com/a/70046417
- name: matrix
type: object
default:
- job_name: 'UbuntuPython38'
py: '3.8'
img: 'ubuntu-latest'
every_time: false
- job_name: 'UbuntuPython310'
py: '3.10'
img: 'ubuntu-latest'
every_time: true
- job_name: 'WindowsPython38'
py: '3.8'
img: 'windows-latest'
every_time: false
- job_name: 'WindowsPython310'
py: '3.10'
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
stages:
- stage: Test
jobs:
- ${{ each item in parameters.matrix }}:
- job: ${{ item.job_name }}
pool:
vmImage: ${{ item.img }}
condition: or( eq(variables['Build.Reason'], 'PullRequest'), ${{ item.every_time }} )
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: ${{ item.py }}
displayName: 'Use Python ${{ item.py }}'
- script: |
python -m pip install pre-commit
pre-commit install
pre-commit run --all-files
displayName: 'Run pre-commits'
- script: |
python -m pip install --upgrade pip==23.0.1
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: |
python -m build
displayName: 'Build PrimAITE'
- script: |
PRIMAITE_WHEEL=$(ls ./dist/primaite*.whl)
python -m pip install $PRIMAITE_WHEEL[dev]
displayName: 'Install PrimAITE'
condition: or(eq( variables['Agent.OS'], 'Linux' ), eq( variables['Agent.OS'], 'Darwin' ))
- script: |
forfiles /p dist\ /m *.whl /c "cmd /c python -m pip install @file[dev]"
displayName: 'Install PrimAITE'
condition: eq( variables['Agent.OS'], 'Windows_NT' )
- script: |
primaite setup
displayName: 'Perform PrimAITE Setup'
- task: UseDotNet@2
displayName: 'Install dotnet dependencies'
inputs:
packageType: 'sdk'
version: '2.1.x'
- script: |
coverage run -m pytest tests/unit_tests
coverage xml -o coverage.xml -i
coverage html -d htmlcov -i
displayName: 'Run tests and code coverage'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: 'junit/**.xml'
testRunTitle: 'Publish test results'
- publish: $(System.DefaultWorkingDirectory)/htmlcov/
artifact: coverage_report
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov'
# - task: PublishCodeCoverageResults@2
# displayName: 'Publish coverage report'
# inputs:
# codeCoverageTool: Cobertura
# summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage.xml'
# failIfCoverageEmpty: true
# - task: PublishCodeCoverageResults@2
# displayName: 'Install code coverage upload dependencies'
# # We only want the dependencies - this azure task is borked https://github.com/microsoft/azure-pipelines-tasks/issues/17756
# # ref: https://github.com/microsoft/azure-pipelines-tasks/issues/17756#issuecomment-1585620675
# condition: eq('true', 'false') # THIS WILL NEVER RUN ONCE TASK DECLARATION IS NEEDED TO DOWNLOAD IT SOURCES
# inputs:
# summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage.xml'
# - task: CmdLine@2
# displayName: Publish Code Coverage
# env: { 'SYSTEM_ACCESSTOKEN': $(System.AccessToken) } #access token is needed to upload report to azure pipeline tabs
# inputs:
# script: |
# mkdir /home/vsts/work/_temp/cobertura
# "$(Dotnet_Root)/dotnet" `find /home/vsts/work/_tasks/ -name CoveragePublisher.Console.dll` '$(System.DefaultWorkingDirectory)/coverage.xml' --reportDirectory /home/vsts/work/_temp/cobertura