azure-pipelines.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. # Python Django
  2. # Test a Django project on multiple versions of Python.
  3. # Add steps that analyze code, save build artifacts, deploy, and more:
  4. # https://docs.microsoft.com/azure/devops/pipelines/languages/python
  5. # NOTES:
  6. #
  7. # Display name of each step should be prefixed with one of the following:
  8. # CR-QC: for quality control measures.
  9. # CR-BUILD: for build-related tasks.
  10. # CR-DEPLOY: for publication or deployment.
  11. # [no prefix]: for unrelated CI setup/tooling.
  12. #
  13. # Use PowerShell Core for any utility scripts so they are re-usable across
  14. # Windows, macOS, and Linux.
  15. #
  16. trigger:
  17. - master
  18. stages:
  19. - stage: Unit_Tests
  20. displayName: Unit Tests
  21. jobs:
  22. - job: pytest
  23. displayName: pytest
  24. pool:
  25. vmImage: 'ubuntu-latest'
  26. strategy:
  27. matrix:
  28. py3.5:
  29. PYTHON_VERSION: '3.5'
  30. py3.6:
  31. PYTHON_VERSION: '3.6'
  32. py3.7:
  33. PYTHON_VERSION: '3.7'
  34. steps:
  35. - task: UsePythonVersion@0
  36. displayName: 'Use Python version'
  37. inputs:
  38. versionSpec: '$(PYTHON_VERSION)'
  39. architecture: 'x64'
  40. - script: python -m pip install -e ./[ci]
  41. displayName: 'CR-QC: Install coderedcms from local repo'
  42. - script: coderedcms start testproject
  43. displayName: 'CR-QC: Create starter project from template'
  44. - pwsh: ./ci/run-tests.ps1
  45. displayName: 'CR-QC: Run unit tests'
  46. - task: PublishTestResults@2
  47. displayName: 'Publish unit test report'
  48. condition: succeededOrFailed()
  49. inputs:
  50. testResultsFiles: '**/test-*.xml'
  51. testRunTitle: 'Publish test results for Python $(python.version)'
  52. - task: PublishCodeCoverageResults@1
  53. displayName: 'Publish code coverage report'
  54. condition: succeededOrFailed()
  55. inputs:
  56. codeCoverageTool: Cobertura
  57. summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage.xml'
  58. - stage: Static_Analysis
  59. displayName: Static Analysis
  60. dependsOn: Unit_Tests
  61. condition: succeeded('Unit_Tests')
  62. jobs:
  63. - job: flake8
  64. displayName: flake8
  65. pool:
  66. vmImage: 'ubuntu-latest'
  67. steps:
  68. - task: UsePythonVersion@0
  69. displayName: 'Use Python version'
  70. inputs:
  71. versionSpec: '3.7'
  72. architecture: 'x64'
  73. - script: python -m pip install -e ./[ci]
  74. displayName: 'CR-QC: Install coderedcms from local repo'
  75. - script: coderedcms start testproject
  76. displayName: 'CR-QC: Generate a test project'
  77. - pwsh: ./ci/run-flake8.ps1
  78. displayName: 'CR-QC: Static analysis (flake8)'
  79. - job: codecov
  80. displayName: Code Coverage
  81. pool:
  82. vmImage: 'ubuntu-latest'
  83. steps:
  84. - task: DownloadPipelineArtifact@2
  85. displayName: 'Download code coverage from current build'
  86. inputs:
  87. source: 'current'
  88. path: '$(Agent.WorkFolder)/current-artifacts'
  89. project: '$(System.TeamProjectId)'
  90. pipeline: '$(System.DefinitionId)'
  91. - task: DownloadPipelineArtifact@2
  92. displayName: 'Download code coverage from latest master build'
  93. inputs:
  94. source: 'specific'
  95. path: '$(Agent.WorkFolder)/previous-artifacts'
  96. project: '$(System.TeamProjectId)'
  97. pipeline: '$(System.DefinitionId)'
  98. runVersion: 'latestFromBranch'
  99. runBranch: 'refs/heads/master'
  100. - pwsh: ./ci/compare-artifacts.ps1 -wd $Env:WorkDir
  101. displayName: 'CR-QC: Compare code coverage'
  102. env:
  103. WorkDir: $(Agent.WorkFolder)
  104. - job: docs
  105. displayName: Documentation
  106. pool:
  107. vmImage: 'ubuntu-latest'
  108. steps:
  109. - task: UsePythonVersion@0
  110. displayName: 'Use Python version'
  111. inputs:
  112. versionSpec: '3.7'
  113. architecture: 'x64'
  114. - script: python -m pip install -e ./[ci]
  115. displayName: 'CR-QC: Install coderedcms from local repo'
  116. - pwsh: ./ci/make-docs.ps1
  117. displayName: 'CR-QC: Build documentation'