aboutsummaryrefslogtreecommitdiff
path: root/.ci/azure-pipelines-test.yml
blob: cc94dc2c5aaa0a32ddb828cbb78c6c31215e1ee1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
parameters:
- name: ImageNames
  type: object
  default:
    Linux: "ubuntu-latest"
    Windows: "windows-latest"
    macOS: "macos-latest"
- name: TestProjects
  type: string
  default: "tests/**/*Tests.csproj"
- name: DotNetSdkVersion
  type: string
  default: 6.0.x

jobs:
  - job: Test
    displayName: Test
    strategy:
      matrix:
        ${{ each imageName in parameters.ImageNames }}:
          ${{ imageName.key }}:
            ImageName: ${{ imageName.value }}
    pool:
      vmImage: "$(ImageName)"
    steps:
      - checkout: self
        clean: true
        submodules: true
        persistCredentials: false

      # This is required for the SonarCloud analyzer
      - task: UseDotNet@2
        displayName: "Install .NET SDK 5.x"
        condition: eq(variables['ImageName'], 'ubuntu-latest')
        inputs:
          packageType: sdk
          version: '5.x'

      - task: UseDotNet@2
        displayName: "Update DotNet"
        inputs:
          packageType: sdk
          version: ${{ parameters.DotNetSdkVersion }}

      - task: SonarCloudPrepare@1
        displayName: 'Prepare analysis on SonarCloud'
        condition: eq(variables['ImageName'], 'ubuntu-latest')
        enabled: false
        inputs:
          SonarCloud: 'Sonarcloud for Jellyfin'
          organization: 'jellyfin'
          projectKey: 'jellyfin_jellyfin'

      - task: DotNetCoreCLI@2
        displayName: 'Run CLI Tests'
        inputs:
          command: "test"
          projects: ${{ parameters.TestProjects }}
          arguments: '--configuration Release --collect:"XPlat Code Coverage" --settings tests/coverletArgs.runsettings --verbosity minimal'
          publishTestResults: true
          testRunTitle: $(Agent.JobName)
          workingDirectory: "$(Build.SourcesDirectory)"

      - task: SonarCloudAnalyze@1
        displayName: 'Run Code Analysis'
        condition: eq(variables['ImageName'], 'ubuntu-latest')
        enabled: false

      - task: SonarCloudPublish@1
        displayName: 'Publish Quality Gate Result'
        condition: eq(variables['ImageName'], 'ubuntu-latest')
        enabled: false

      - task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4
        condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) # !! THIS is for V1 only V2 will/should support merging
        displayName: 'Run ReportGenerator'
        inputs:
          reports: "$(Agent.TempDirectory)/**/coverage.cobertura.xml"
          targetdir: "$(Agent.TempDirectory)/merged/"
          reporttypes: "Cobertura"

      ## V2 is already in the repository but it does not work "wrong number of segments" YAML error.
      - task: PublishCodeCoverageResults@1
        condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) # !! THIS is for V1 only V2 will/should support merging
        displayName: 'Publish Code Coverage'
        inputs:
          codeCoverageTool: "cobertura"
          #summaryFileLocation: '$(Agent.TempDirectory)/**/coverage.cobertura.xml' # !!THIS IS FOR V2
          summaryFileLocation: "$(Agent.TempDirectory)/merged/**.xml"
          pathToSources: $(Build.SourcesDirectory)
          failIfCoverageEmpty: true

      - task: PublishPipelineArtifact@1
        displayName: 'Publish OpenAPI Artifact'
        condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
        inputs:
          targetPath: "tests/Jellyfin.Server.Integration.Tests/bin/Release/net6.0/openapi.json"
          artifactName: 'OpenAPI Spec'