azure-pipelines-test.yml 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. parameters:
  2. - name: ImageNames
  3. type: object
  4. default:
  5. Linux: "ubuntu-latest"
  6. Windows: "windows-latest"
  7. macOS: "macos-latest"
  8. - name: TestProjects
  9. type: string
  10. default: "tests/**/*Tests.csproj"
  11. - name: DotNetSdkVersion
  12. type: string
  13. default: 5.0.100
  14. jobs:
  15. - job: Test
  16. displayName: Test
  17. strategy:
  18. matrix:
  19. ${{ each imageName in parameters.ImageNames }}:
  20. ${{ imageName.key }}:
  21. ImageName: ${{ imageName.value }}
  22. pool:
  23. vmImage: "$(ImageName)"
  24. steps:
  25. - checkout: self
  26. clean: true
  27. submodules: true
  28. persistCredentials: false
  29. # This is required for the SonarCloud analyzer
  30. - task: UseDotNet@2
  31. displayName: "Install .NET SDK 5.x"
  32. condition: eq(variables['ImageName'], 'ubuntu-latest')
  33. inputs:
  34. packageType: sdk
  35. version: '5.x'
  36. - task: UseDotNet@2
  37. displayName: "Update DotNet"
  38. inputs:
  39. packageType: sdk
  40. version: ${{ parameters.DotNetSdkVersion }}
  41. - task: SonarCloudPrepare@1
  42. displayName: 'Prepare analysis on SonarCloud'
  43. condition: eq(variables['ImageName'], 'ubuntu-latest')
  44. enabled: false
  45. inputs:
  46. SonarCloud: 'Sonarcloud for Jellyfin'
  47. organization: 'jellyfin'
  48. projectKey: 'jellyfin_jellyfin'
  49. - task: DotNetCoreCLI@2
  50. displayName: 'Run CLI Tests'
  51. inputs:
  52. command: "test"
  53. projects: ${{ parameters.TestProjects }}
  54. arguments: '--configuration Release --collect:"XPlat Code Coverage" --settings tests/coverletArgs.runsettings --verbosity minimal'
  55. publishTestResults: true
  56. testRunTitle: $(Agent.JobName)
  57. workingDirectory: "$(Build.SourcesDirectory)"
  58. - task: SonarCloudAnalyze@1
  59. displayName: 'Run Code Analysis'
  60. condition: eq(variables['ImageName'], 'ubuntu-latest')
  61. enabled: false
  62. - task: SonarCloudPublish@1
  63. displayName: 'Publish Quality Gate Result'
  64. condition: eq(variables['ImageName'], 'ubuntu-latest')
  65. enabled: false
  66. - task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4
  67. condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) # !! THIS is for V1 only V2 will/should support merging
  68. displayName: 'Run ReportGenerator'
  69. inputs:
  70. reports: "$(Agent.TempDirectory)/**/coverage.cobertura.xml"
  71. targetdir: "$(Agent.TempDirectory)/merged/"
  72. reporttypes: "Cobertura"
  73. ## V2 is already in the repository but it does not work "wrong number of segments" YAML error.
  74. - task: PublishCodeCoverageResults@1
  75. condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) # !! THIS is for V1 only V2 will/should support merging
  76. displayName: 'Publish Code Coverage'
  77. inputs:
  78. codeCoverageTool: "cobertura"
  79. #summaryFileLocation: '$(Agent.TempDirectory)/**/coverage.cobertura.xml' # !!THIS IS FOR V2
  80. summaryFileLocation: "$(Agent.TempDirectory)/merged/**.xml"
  81. pathToSources: $(Build.SourcesDirectory)
  82. failIfCoverageEmpty: true
  83. - task: PublishPipelineArtifact@1
  84. displayName: 'Publish OpenAPI Artifact'
  85. condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
  86. inputs:
  87. targetPath: "tests/Jellyfin.Api.Tests/bin/Release/net5.0/openapi.json"
  88. artifactName: 'OpenAPI Spec'