azure-pipelines.yml 4.1 KB

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