azure-pipelines.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. - dev
  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.7:
  29. PYTHON_VERSION: '3.7'
  30. py3.8:
  31. PYTHON_VERSION: '3.8'
  32. py3.9:
  33. PYTHON_VERSION: '3.9'
  34. py3.10:
  35. PYTHON_VERSION: '3.10'
  36. steps:
  37. - task: UsePythonVersion@0
  38. displayName: 'Use Python version'
  39. inputs:
  40. versionSpec: '$(PYTHON_VERSION)'
  41. architecture: 'x64'
  42. - script: python -m pip install -r requirements-ci.txt
  43. displayName: 'CR-QC: Install coderedcms from local repo'
  44. - script: coderedcms start testproject
  45. displayName: 'CR-QC: Create starter project from template'
  46. - pwsh: ./ci/run-tests.ps1
  47. displayName: 'CR-QC: Run unit tests'
  48. - task: PublishTestResults@2
  49. displayName: 'Publish unit test report'
  50. condition: succeededOrFailed()
  51. inputs:
  52. testResultsFiles: '**/test-*.xml'
  53. testRunTitle: 'Publish test results for Python $(python.version)'
  54. - task: PublishCodeCoverageResults@1
  55. displayName: 'Publish code coverage report'
  56. condition: succeededOrFailed()
  57. inputs:
  58. codeCoverageTool: Cobertura
  59. summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage.xml'
  60. - stage: Static_Analysis
  61. displayName: Static Analysis
  62. dependsOn: Unit_Tests
  63. condition: succeeded('Unit_Tests')
  64. jobs:
  65. - job: linters
  66. displayName: Linters
  67. pool:
  68. vmImage: 'ubuntu-latest'
  69. steps:
  70. - task: UsePythonVersion@0
  71. displayName: 'Use Python version'
  72. inputs:
  73. versionSpec: '3.10'
  74. architecture: 'x64'
  75. - script: python -m pip install -r requirements-ci.txt
  76. displayName: 'CR-QC: Install coderedcms from local repo'
  77. - pwsh: ./ci/spellcheck.ps1
  78. displayName: 'CR-QC: Spelling'
  79. - script: coderedcms start testproject
  80. displayName: 'CR-QC: Generate a test project'
  81. - script: |
  82. cd testproject/
  83. python manage.py makemigrations --check
  84. displayName: 'CR-QC: Check migrations'
  85. - pwsh: ./ci/run-flake8.ps1
  86. displayName: 'CR-QC: Flake8'
  87. - job: codecov
  88. displayName: Code Coverage
  89. pool:
  90. vmImage: 'ubuntu-latest'
  91. steps:
  92. - task: DownloadBuildArtifacts@0
  93. displayName: 'Download code coverage from current build'
  94. inputs:
  95. buildType: 'current'
  96. project: '$(System.TeamProjectId)'
  97. pipeline: '$(System.DefinitionId)'
  98. downloadType: 'specific'
  99. downloadPath: '$(Agent.WorkFolder)/current-artifacts'
  100. - pwsh: ./ci/compare-codecov.ps1 -wd $Env:WorkDir
  101. displayName: 'CR-QC: Compare code coverage'
  102. failOnStderr: false
  103. env:
  104. WorkDir: $(Agent.WorkFolder)
  105. - job: docs
  106. displayName: Documentation
  107. pool:
  108. vmImage: 'ubuntu-latest'
  109. steps:
  110. - task: UsePythonVersion@0
  111. displayName: 'Use Python version'
  112. inputs:
  113. versionSpec: '3.10'
  114. architecture: 'x64'
  115. - script: python -m pip install -r requirements-ci.txt
  116. displayName: 'CR-QC: Install coderedcms from local repo'
  117. - pwsh: ./ci/make-docs.ps1
  118. displayName: 'CR-QC: Build documentation'