azure-pipelines.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. - script: black --check .
  86. displayName: 'CR-QC: Black'
  87. - script: flake8 .
  88. displayName: 'CR-QC: Flake8'
  89. - job: codecov
  90. displayName: Code Coverage
  91. pool:
  92. vmImage: 'ubuntu-latest'
  93. steps:
  94. - task: DownloadBuildArtifacts@0
  95. displayName: 'Download code coverage from current build'
  96. inputs:
  97. buildType: 'current'
  98. project: '$(System.TeamProjectId)'
  99. pipeline: '$(System.DefinitionId)'
  100. downloadType: 'specific'
  101. downloadPath: '$(Agent.WorkFolder)/current-artifacts'
  102. - pwsh: ./ci/compare-codecov.ps1 -wd $Env:WorkDir
  103. displayName: 'CR-QC: Compare code coverage'
  104. failOnStderr: false
  105. env:
  106. WorkDir: $(Agent.WorkFolder)
  107. - job: docs
  108. displayName: Documentation
  109. pool:
  110. vmImage: 'ubuntu-latest'
  111. steps:
  112. - task: UsePythonVersion@0
  113. displayName: 'Use Python version'
  114. inputs:
  115. versionSpec: '3.10'
  116. architecture: 'x64'
  117. - script: python -m pip install -r requirements-ci.txt
  118. displayName: 'CR-QC: Install coderedcms from local repo'
  119. - pwsh: ./ci/make-docs.ps1
  120. displayName: 'CR-QC: Build documentation'