azure-pipelines.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. # Test a Django project on multiple versions of Python.
  2. # Add steps that analyze code, save build artifacts, deploy, and more:
  3. # https://docs.microsoft.com/azure/devops/pipelines/languages/python
  4. # NOTES:
  5. #
  6. # Display name of each step should be prefixed with one of the following:
  7. # CR-QC: for quality control measures.
  8. # CR-BUILD: for build-related tasks.
  9. # CR-DEPLOY: for publication or deployment.
  10. # [no prefix]: for unrelated CI setup/tooling.
  11. #
  12. # Use PowerShell Core for any utility scripts so they are re-usable across
  13. # Windows, macOS, and Linux.
  14. trigger:
  15. - main
  16. stages:
  17. - stage: Unit_Tests
  18. displayName: Unit Tests
  19. jobs:
  20. - job: pytest
  21. displayName: pytest
  22. pool:
  23. vmImage: 'ubuntu-latest'
  24. strategy:
  25. matrix:
  26. py3.8:
  27. PYTHON_VERSION: '3.8'
  28. WAGTAIL_VERSION: '6.0.*'
  29. TEMPLATE: 'basic'
  30. py3.9:
  31. PYTHON_VERSION: '3.9'
  32. WAGTAIL_VERSION: '6.0.*'
  33. TEMPLATE: 'basic'
  34. py3.10:
  35. PYTHON_VERSION: '3.10'
  36. WAGTAIL_VERSION: '6.0.*'
  37. TEMPLATE: 'basic'
  38. py3.11:
  39. PYTHON_VERSION: '3.11'
  40. WAGTAIL_VERSION: '6.1.*'
  41. TEMPLATE: 'basic'
  42. py3.12_basic:
  43. PYTHON_VERSION: '3.12'
  44. WAGTAIL_VERSION: '6.1.*'
  45. TEMPLATE: 'basic'
  46. py3.12_pro:
  47. PYTHON_VERSION: '3.12'
  48. WAGTAIL_VERSION: '6.1.*'
  49. TEMPLATE: 'pro'
  50. steps:
  51. - task: UsePythonVersion@0
  52. displayName: 'Use Python version'
  53. inputs:
  54. versionSpec: '$(PYTHON_VERSION)'
  55. architecture: 'x64'
  56. - script: python -m pip install -r requirements-ci.txt wagtail==$(WAGTAIL_VERSION)
  57. displayName: 'CR-QC: Install coderedcms from local repo'
  58. - script: coderedcms start testproject --template $(TEMPLATE)
  59. displayName: 'CR-QC: Create starter project from template'
  60. - script: |
  61. cd testproject/
  62. python -m pip install -r requirements-dev.txt
  63. python manage.py makemigrations --check
  64. displayName: 'CR-QC: Check migrations'
  65. - pwsh: ./ci/run-tests.ps1
  66. displayName: 'CR-QC: Run unit tests'
  67. - task: PublishTestResults@2
  68. displayName: 'Publish unit test report'
  69. condition: succeededOrFailed()
  70. inputs:
  71. testResultsFiles: '**/test-*.xml'
  72. testRunTitle: 'Publish test results for Python $(python.version)'
  73. - task: PublishCodeCoverageResults@1
  74. displayName: 'Publish code coverage report'
  75. condition: succeededOrFailed()
  76. inputs:
  77. codeCoverageTool: Cobertura
  78. summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage.xml'
  79. - stage: Static_Analysis
  80. displayName: Static Analysis
  81. dependsOn: Unit_Tests
  82. condition: succeeded('Unit_Tests')
  83. jobs:
  84. - job: linters
  85. displayName: Linters
  86. pool:
  87. vmImage: 'ubuntu-latest'
  88. steps:
  89. - task: UsePythonVersion@0
  90. displayName: 'Use Python version'
  91. inputs:
  92. versionSpec: '3.12'
  93. architecture: 'x64'
  94. - script: python -m pip install -r requirements-ci.txt
  95. displayName: 'CR-QC: Install coderedcms from local repo'
  96. - pwsh: ./ci/spellcheck.ps1
  97. displayName: 'CR-QC: Spelling'
  98. - script: ruff format --check .
  99. displayName: 'CR-QC: Ruff Format'
  100. - script: ruff check .
  101. displayName: 'CR-QC: Ruff Check'
  102. - job: codecov
  103. displayName: Code Coverage
  104. pool:
  105. vmImage: 'ubuntu-latest'
  106. steps:
  107. - task: DownloadBuildArtifacts@0
  108. displayName: 'Download code coverage from current build'
  109. inputs:
  110. buildType: 'current'
  111. project: '$(System.TeamProjectId)'
  112. pipeline: '$(System.DefinitionId)'
  113. downloadType: 'specific'
  114. downloadPath: '$(Agent.WorkFolder)/current-artifacts'
  115. - pwsh: ./ci/compare-codecov.ps1 -wd $Env:WorkDir
  116. displayName: 'CR-QC: Compare code coverage'
  117. failOnStderr: false
  118. env:
  119. WorkDir: $(Agent.WorkFolder)
  120. - job: docs
  121. displayName: Documentation
  122. pool:
  123. vmImage: 'ubuntu-latest'
  124. steps:
  125. - task: UsePythonVersion@0
  126. displayName: 'Use Python version'
  127. inputs:
  128. versionSpec: '3.12'
  129. architecture: 'x64'
  130. - script: python -m pip install -r requirements-ci.txt
  131. displayName: 'CR-QC: Install coderedcms from local repo'
  132. - pwsh: ./ci/make-docs.ps1
  133. displayName: 'CR-QC: Build documentation'