Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
chore: split CI build in multiple stages (#115)
Browse files Browse the repository at this point in the history
* chore: split CI build in multiple stages

* pr-fix: add build folder to trigger paths

* pr-fix: manual trigger vesion parameter

* pr-fix: correct typo 'succeeded'

* pr-fix: correct typo 'succeeded'

* pr-fix: add 'lazydocs' to installed unit test modules
  • Loading branch information
stijnmoreels authored Jan 7, 2022
1 parent a39764c commit 7b99c6c
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 69 deletions.
166 changes: 97 additions & 69 deletions build/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,73 +25,101 @@ resources:
name: arcus-azure/azure-devops-templates
endpoint: arcus-azure

pool:
vmImage: 'ubuntu-latest'

steps:
- template: 'pypi/determine-pr-version.yml@templates'
parameters:
manualTriggerVersion: preview

- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
addToPath: true
architecture: 'x64'

- task: Bash@3
displayName: 'Update version number'
inputs:
targetType: 'inline'
script: 'sed -i ''s/1.0.0/$(Package.Version).$(Build.BuildNumber)/g'' arcus/ml/__init__.py'
failOnStderr: true

- script: python -m pip install --upgrade pip setuptools wheel lazydocs
displayName: 'Install tools'

- script: pip install -r requirements.txt
displayName: 'Install requirements'

- script: |
pip install pytest
pip install pytest-cov
pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=. --cov-report=xml --cov-report=html
displayName: 'Unit tests (pytest)'

- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: '**/test-*.xml'
testRunTitle: 'Publish test results for Python $(python.version)'
variables:
- template: ./variables/build.yml

- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov'

- script: |
python setup.py sdist bdist_wheel
displayName: 'Build wheels'

- script: python -m pip install --upgrade twine
displayName: 'Install Twine'

- task: TwineAuthenticate@1
inputs:
pythonUploadServiceConnection: 'Arcus ML PyPi feed'

- script: |
python -m twine upload --skip-existing --verbose -r 'arcus-ml' --config-file $(PYPIRC_PATH) dist/*
displayName: 'Publish to PyPi dev'
condition: succeededOrFailed()

- task: CopyFiles@2
inputs:
targetFolder: $(Build.ArtifactStagingDirectory)

- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'dist'
publishLocation: 'Container'
pool:
vmImage: $(Vm.Image)

stages:
- stage: Build
jobs:
- job: DefineVersion
displayName: 'Define version number'
steps:
- template: 'pypi/determine-pr-version.yml@templates'
parameters:
manualTriggerVersion: preview
- task: UsePythonVersion@0
inputs:
versionSpec: $(Python.Version)
addToPath: true
- task: Bash@3
displayName: 'Update version number'
inputs:
targetType: 'inline'
script: 'sed -i ''s/1.0.0/$(Package.Version).$(Build.BuildNumber)/g'' arcus/ml/__init__.py'
failOnStderr: true
- task: CopyFiles@2
displayName: 'Copy build artifacts'
inputs:
contents: '**/*.py'
targetFolder: '$(Pipeline.Workspace)/build'
- task: PublishPipelineArtifact@0
displayName: 'Publish build artifacts'
inputs:
targetPath: '$(Pipeline.Workspace)/build'
artifactName: Build

- stage: UnitTests
displayName: Unit Tests
dependsOn: Build
condition: succeeded()
jobs:
- job: UnitTests
displayName: 'Run unit tests'
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download build artifacts'
inputs:
artifact: 'Build'
path: '$(Build.SourcesDirectory)'
- script: pip install -r requirements.txt
displayName: 'Install requirements'
- script: |
pip install pytest
pip install pytest-cov
pip install lazydocs
pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=. --cov-report=xml --cov-report=html
displayName: 'Unit tests (pytest)'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: '**/test-*.xml'
testRunTitle: 'Publish test results for Python $(Python.Version)'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov'

- stage: Release
dependsOn: UnitTests
condition: succeeded()
jobs:
- job: PushToPyPi
displayName: 'Package wheel and push to PyPi'
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download build artifacts'
inputs:
artifact: 'Build'
path: '$(Build.SourcesDirectory)'
- script: python -m pip install --upgrade pip setuptools wheel lazydocs twine
displayName: 'Install tools'
- script: python setup.py sdist bdist_wheel
displayName: 'Build wheels'
- task: TwineAuthenticate@1
inputs:
pythonUploadServiceConnection: 'Arcus ML PyPi feed'
- script: python -m twine upload --skip-existing --verbose -r 'arcus-ml' --config-file $(PYPIRC_PATH) dist/*
displayName: 'Publish to PyPi dev'
condition: succeededOrFailed()
- task: CopyFiles@2
inputs:
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'dist'
publishLocation: 'Container'
3 changes: 3 additions & 0 deletions build/variables/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
variables:
Vm.Image: 'ubuntu-latest'
Python.Version: '3.7'

0 comments on commit 7b99c6c

Please sign in to comment.