azure-pipelines.yml 3.9 KB

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