Преглед изворни кода

Publish test results and make task names more readable.

Jeremy Koritzinsky пре 7 година
родитељ
комит
f5f8d1594c
3 измењених фајлова са 71 додато и 23 уклоњено
  1. 51 15
      azure-pipelines.yml
  2. 15 7
      build.cake
  3. 5 1
      parameters.cake

+ 51 - 15
azure-pipelines.yml

@@ -4,20 +4,31 @@ jobs:
     vmImage: 'ubuntu-16.04'
   steps:
   - task: CmdLine@2
+    displayName: 'Install CastXML'
     inputs:
       script: |
         sudo apt-get update
         sudo apt-get install castxml
+
   - task: CmdLine@2
+    displayName: 'Install Cake'
     inputs:
       script: |
         dotnet tool install -g Cake.Tool --version 0.30.0
   
-  - script: |
-      export PATH="$PATH:$HOME/.dotnet/tools"
-      dotnet --info
-      printenv
-      dotnet cake build.cake -target="Azure-Linux" -configuration="Release"
+  - task: CmdLine@2
+    displayName: 'Run Cake'
+    inputs:
+      script: |
+        export PATH="$PATH:$HOME/.dotnet/tools"
+        dotnet --info
+        printenv
+        dotnet cake build.cake -target="Azure-Linux" -configuration="Release"
+
+  - task: PublishTestResults@2
+    inputs:
+      testResultsFormat: 'VSTest'
+      testResultsFiles: '$(Build.SourcesDirectory)/artifacts/test-results/*.trx'
      
 - job: macOS
   pool:
@@ -26,6 +37,7 @@ jobs:
   - task: DotNetCoreInstaller@0
     inputs:
       version: '2.1.403'
+
   - task: Xcode@5
     inputs:
       actions: 'build'
@@ -35,29 +47,43 @@ jobs:
       xcWorkspacePath: '**/*.xcodeproj/project.xcworkspace'
       xcodeVersion: 'default' # Options: 8, 9, default, specifyPath
       args: '-derivedDataPath ./'
+
   - task: CmdLine@2
+    displayName: 'Install CastXML'
     inputs:
       script: brew install castxml
+
   - task: CmdLine@2
+    displayName: 'Install Cake'
     inputs:
       script: |
         dotnet tool install -g Cake.Tool --version 0.30.0
-  - script: |
-      export COREHOST_TRACE=0
-      export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
-      export DOTNET_CLI_TELEMETRY_OPTOUT=1
-      which dotnet
-      dotnet --info
-      export PATH="$PATH:$HOME/.dotnet/tools"
-      dotnet --info
-      printenv
-      dotnet cake build.cake -target="Azure-OSX" -configuration="Release"
+
+  - task: CmdLine@2
+    displayName: 'Run Cake'
+    inputs:
+      script: |
+        export COREHOST_TRACE=0
+        export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
+        export DOTNET_CLI_TELEMETRY_OPTOUT=1
+        which dotnet
+        dotnet --info
+        export PATH="$PATH:$HOME/.dotnet/tools"
+        dotnet --info
+        printenv
+        dotnet cake build.cake -target="Azure-OSX" -configuration="Release"
+
+  - task: PublishTestResults@2
+    inputs:
+      testResultsFormat: 'VSTest'
+      testResultsFiles: '$(Build.SourcesDirectory)/artifacts/test-results/*.trx'
   
   - task: PublishBuildArtifacts@1
     inputs:
       pathToPublish: '$(Build.SourcesDirectory)/Build/Products/Release/'
       artifactName: 'Avalonia.Native.OSX'
     condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false))
+    
   - task: PublishBuildArtifacts@1
     inputs:
       pathtoPublish: '$(Build.SourcesDirectory)/artifacts/nuget'
@@ -69,19 +95,29 @@ jobs:
     vmImage: 'vs2017-win2016'
   steps:
   - task: CmdLine@2
+    displayName: 'Install Cake'
     inputs:
       script: |
         dotnet tool install -g Cake.Tool --version 0.30.0
+
   - task: CmdLine@2
+    displayName: 'Run Cake'
     inputs:
       script: |
         set PATH=%PATH%;%USERPROFILE%\.dotnet\tools
         dotnet cake build.cake -target="Azure-Windows" -configuration="Release"
+      
+  - task: PublishTestResults@2
+    inputs:
+      testResultsFormat: 'VSTest'
+      testResultsFiles: '$(Build.SourcesDirectory)/artifacts/test-results/*.trx'
+
   - task: PublishBuildArtifacts@1
     inputs:
       pathtoPublish: '$(Build.SourcesDirectory)/artifacts/nuget'
       artifactName: 'NuGet'
     condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false))
+
   - task: PublishBuildArtifacts@1
     inputs:
       pathToPublish: '$(Build.SourcesDirectory)/artifacts/zip'

+ 15 - 7
build.cake

@@ -78,6 +78,7 @@ Task("Clean-Impl")
     CleanDirectory(data.ArtifactsDir);
     CleanDirectory(data.NugetRoot);
     CleanDirectory(data.ZipRoot);
+    CleanDirectory(data.TestResultsRoot);
 });
 
 void DotNetCoreBuild(Parameters parameters)
@@ -129,13 +130,20 @@ void RunCoreTest(string project, Parameters parameters, bool coreOnly = false)
             continue;
         Information("Running for " + fw);
         
-        DotNetCoreTest(project,
-            new DotNetCoreTestSettings {
-                Configuration = parameters.Configuration,
-                Framework = fw,
-                NoBuild = true,
-                NoRestore = true
-            });
+        var settings = new DotNetCoreTestSettings {
+            Configuration = parameters.Configuration,
+            Framework = fw,
+            NoBuild = true,
+            NoRestore = true
+        };
+
+        if (parameters.PublishTestResults)
+        {
+            settings.Logger = "trx";
+            settings.ResultsDirectory = parameters.TestResultsRoot;
+        }
+
+        DotNetCoreTest(project, settings);
     }
 }
 

+ 5 - 1
parameters.cake

@@ -22,11 +22,13 @@ public class Parameters
     public bool IsReleasable { get; private set; }
     public bool IsMyGetRelease { get; private set; }
     public bool IsNuGetRelease { get; private set; }
+    public bool PublishTestResults { get; private set; }
     public string Version { get; private set; } 
     public DirectoryPath ArtifactsDir { get; private set; }
     public DirectoryPath NugetRoot { get; private set; }
     public DirectoryPath ZipRoot { get; private set; }
     public DirectoryPath BinRoot { get; private set; }
+    public DirectoryPath TestResultsRoot { get; private set; }
     public string DirSuffix { get; private set; }
     public DirectoryPathCollection BuildDirs { get; private set; }
     public string FileZipSuffix { get; private set; }
@@ -91,7 +93,8 @@ public class Parameters
         else if (IsRunningOnAzure)
         {
                 // Use AssemblyVersion with Build as version
-                Version += "-build" + context.EnvironmentVariable("BUILD_BUILDID") + "-beta";   
+                Version += "-build" + context.EnvironmentVariable("BUILD_BUILDID") + "-beta";
+                PublishTestResults = true; 
         }
 
         // DIRECTORIES
@@ -99,6 +102,7 @@ public class Parameters
         NugetRoot = ArtifactsDir.Combine("nuget");
         ZipRoot = ArtifactsDir.Combine("zip");
         BinRoot = ArtifactsDir.Combine("bin");
+        TestResultsRoot = ArtifactsDir.Combine("test-results");
         BuildDirs = context.GetDirectories("**/bin") + context.GetDirectories("**/obj");
         DirSuffix = Configuration;
         FileZipSuffix = Version + ".zip";