summaryrefslogtreecommitdiff
path: root/eng/test-job.yml
blob: 00982f762b0c641bf97874dfd3e27bc1a7eac04d (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
parameters:
  buildConfig: ''
  archType: ''
  osGroup: ''
  osGroupName: ''
  priority: 0
  crossgen: false
  scenarios: ''

### Test job

### Each test job depends on a corresponding build job with the same
### buildConfig and archType.

jobs:
- template: xplat-job.yml
  parameters:
    buildConfig: ${{ parameters.buildConfig }}
    archType: ${{ parameters.archType }}
    osGroup: ${{ parameters.osGroup }}
    osGroupName: ${{ parameters.osGroupName }}

    # Compute job name from template parameters
    ${{ if eq(parameters.crossgen, 'false') }}:
        name: ${{ format('testbuild_pri{0}_{1}_{2}_{3}', parameters.priority, parameters.osGroupName, parameters.archType, parameters.buildConfig) }}
        displayName: ${{ format('Test pri{0} {1} {2} {3}', parameters.priority, parameters.osGroupName, parameters.archType, parameters.buildConfig) }}
    ${{ if eq(parameters.crossgen, 'true') }}:
        name: ${{ format('testbuild_pri{0}_r2r_{1}_{2}_{3}', parameters.priority, parameters.osGroupName, parameters.archType, parameters.buildConfig) }}
        displayName: ${{ format('Test Pri{0} R2R {1} {2} {3}', parameters.priority, parameters.osGroupName, parameters.archType, parameters.buildConfig) }}

    variables:
      # Map template parameters to command line arguments
      ${{ if eq(parameters.priority, '1') }}:
        ${{ if or(eq(parameters.osGroup, 'Linux'), eq(parameters.osGroup, 'OSX')) }}:
          priorityArg: 'priority1'
        ${{ if eq(parameters.osGroup, 'Windows_NT') }}:
          priorityArg: '-priority=1'
      ${{ if eq(parameters.priority, '0') }}:
        priorityArg: ''

      ${{ if eq(parameters.crossgen, 'true') }}:
        crossgenArg: 'crossgen'
      ${{ if eq(parameters.crossgen, 'false') }}:
        crossgenArg: ''
      ${{ if ne(parameters.scenarios, '') }}:
        scenariosArg: ${{ format('/p:Scenarios=\"{0}\"', parameters.scenarios) }}
      ${{ if eq(parameters.scenarios, '') }}:
        scenariosArg: ''

    # TODO: Enable crossgen in build-test.sh. It currently doesn't
    # accept a crossgen arg, so disable the macos/linux crossgen test
    # build jobs.
    ${{ if and(eq(parameters.crossgen, 'true'), or(eq(parameters.osGroup, 'Linux'), eq(parameters.osGroup, 'OSX'))) }}:
      condition: false

    # Test job depends on the corresponding build job
    dependsOn: ${{ format('build_{0}_{1}_{2}', parameters.osGroupName, parameters.archType, parameters.buildConfig) }}

    # Run all steps in the container.
    # Note that the containers are resources defined in azure-pipelines.yml
    containerName: ${{ parameters.containerName }}

    steps:

    # Install test build dependencies
    - ${{ if eq(parameters.osGroup, 'OSX') }}:
      - script: sh eng/install-native-dependencies.sh $(osGroup)
        displayName: Install native dependencies


    # Download product build from pipeline artifact storage
    - ${{ if or(eq(parameters.osGroup, 'Linux'), eq(parameters.osGroup, 'OSX')) }}:
      - task: DownloadPipelineArtifact@0
        displayName: Download product build pipeline artifact
        inputs:
          artifactName: ${{ format('{0}_{1}_{2}_build', parameters.osGroupName, parameters.archType, parameters.buildConfig) }}
          targetPath: $(Build.SourcesDirectory)/bin/Product/$(osGroup).$(archType).$(buildConfigUpper)
    - ${{ if eq(parameters.osGroup, 'Windows_NT') }}:
      - task: DownloadPipelineArtifact@0
        displayName: Download product build pipeline artifact
        inputs:
          artifactName: ${{ format('{0}_{1}_{2}_build', parameters.osGroupName, parameters.archType, parameters.buildConfig) }}
          targetPath: $(Build.SourcesDirectory)\bin\Product\Windows_NT.$(archType).$(buildConfigUpper)

      
    # Build tests
    - ${{ if or(eq(parameters.osGroup, 'Linux'), eq(parameters.osGroup, 'OSX')) }}:
        # TODO: enable crossgen in build-test.sh
      - script: ./build-test.sh $(buildConfig) $(archType) $(priorityArg) $(crossgenArg)
        displayName: Build tests
    - ${{ if eq(parameters.osGroup, 'Windows_NT') }}:
      - script: build-test.cmd $(buildConfig) $(archType) $(priorityArg) $(crossgenArg)
        displayName: Build tests


    # Prepare tests for helix
    - ${{ if or(eq(parameters.osGroup, 'Linux'), eq(parameters.osGroup, 'OSX')) }}:
      - script: ./Tools/dotnetcli/dotnet msbuild tests/helixprep.proj /p:CORE_ROOT=$(Build.SourcesDirectory)/bin/tests/$(osGroup).$(archType).$(buildConfigUpper)/Tests/Core_Root /p:__BuildType=$(buildConfig) /p:__BuildArch=$(archType) /p:UsePython=true
        # TODO: remove UsePython argument once we've removed generated wrappers in helixprep.proj
        displayName: Prepare test archives for Helix
    - ${{ if eq(parameters.osGroup, 'Windows_NT') }}:
        # TODO: remove UsePython argument once we've removed generated wrappers in helixprep.proj
      - script: .\Tools\dotnetcli\dotnet.exe msbuild tests\helixprep.proj /p:CORE_ROOT=$(Build.SourcesDirectory)\bin\tests\Windows_NT.$(archType).$(buildConfigUpper)\tests\core_root /p:__BuildType=$(buildConfig) /p:__BuildArch=$(archType) /p:UsePython=true
        displayName: Prepare test archives for Helix


    # Send tests to helix
    - ${{ if or(eq(parameters.osGroup, 'Linux'), eq(parameters.osGroup, 'OSX')) }}:
      - script: ./Tools/dotnetcli/dotnet msbuild tests/helixpublishwitharcade.proj /t:Test $(scenariosArg)
        displayName: Send test jobs to Helix
        env:
          ${{ if eq(variables['System.TeamProject'], 'internal') }}:
            # Access token variable for internal project
            HelixAccessToken: $(DotNet-HelixApi-Access)
          ${{ if eq(variables['System.TeamProject'], 'public') }}:
            # Access token variable for public project
            HelixAccessToken: $(BotAccount-dotnet-github-anon-kaonashi-bot-helix-token)
    - ${{ if eq(parameters.osGroup, 'Windows_NT') }}:
      - script: .\Tools\dotnetcli\dotnet msbuild tests\helixpublishwitharcade.proj /t:Test $(scenariosArg)
        displayName: Send test jobs to Helix
        env:
          ${{ if eq(variables['System.TeamProject'], 'internal') }}:
            # Access token variable for internal project
            HelixAccessToken: $(DotNet-HelixApi-Access)
          ${{ if eq(variables['System.TeamProject'], 'public') }}:
            # Access token variable for public project
            HelixAccessToken: $(BotAccount-dotnet-github-anon-kaonashi-bot-helix-token)