azure-pipelines.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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@2
  74. displayName: 'Publish code coverage report'
  75. condition: succeededOrFailed()
  76. inputs:
  77. summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage.xml'
  78. - stage: Static_Analysis
  79. displayName: Static Analysis
  80. dependsOn: Unit_Tests
  81. condition: succeeded('Unit_Tests')
  82. jobs:
  83. - job: linters
  84. displayName: Linters
  85. pool:
  86. vmImage: 'ubuntu-latest'
  87. steps:
  88. - task: UsePythonVersion@0
  89. displayName: 'Use Python version'
  90. inputs:
  91. versionSpec: '3.12'
  92. architecture: 'x64'
  93. - script: python -m pip install -r requirements-ci.txt
  94. displayName: 'CR-QC: Install coderedcms from local repo'
  95. - pwsh: ./ci/spellcheck.ps1
  96. displayName: 'CR-QC: Spelling'
  97. - script: ruff format --check .
  98. displayName: 'CR-QC: Ruff Format'
  99. - script: ruff check .
  100. displayName: 'CR-QC: Ruff Check'
  101. - job: codecov
  102. displayName: Code Coverage
  103. pool:
  104. vmImage: 'ubuntu-latest'
  105. steps:
  106. - task: DownloadBuildArtifacts@0
  107. displayName: 'Download code coverage from current build'
  108. inputs:
  109. buildType: 'current'
  110. project: '$(System.TeamProjectId)'
  111. pipeline: '$(System.DefinitionId)'
  112. downloadType: 'specific'
  113. downloadPath: '$(Agent.WorkFolder)/current-artifacts'
  114. - pwsh: ./ci/compare-codecov.ps1 -wd $Env:WorkDir
  115. displayName: 'CR-QC: Compare code coverage'
  116. failOnStderr: false
  117. env:
  118. WorkDir: $(Agent.WorkFolder)
  119. - job: docs
  120. displayName: Documentation
  121. pool:
  122. vmImage: 'ubuntu-latest'
  123. steps:
  124. - task: UsePythonVersion@0
  125. displayName: 'Use Python version'
  126. inputs:
  127. versionSpec: '3.12'
  128. architecture: 'x64'
  129. - script: python -m pip install -r requirements-ci.txt
  130. displayName: 'CR-QC: Install coderedcms from local repo'
  131. - pwsh: ./ci/make-docs.ps1
  132. displayName: 'CR-QC: Build documentation'