From 3e4bc23390a7262b0b57a29e07b08eea91ed93d5 Mon Sep 17 00:00:00 2001 From: "Brett V. Forsgren" Date: Thu, 16 Jan 2020 13:25:25 -0800 Subject: [PATCH 1/2] add windows build telemetry --- eng/Build.ps1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/eng/Build.ps1 b/eng/Build.ps1 index b1bac65054..cf7ce0413c 100644 --- a/eng/Build.ps1 +++ b/eng/Build.ps1 @@ -61,6 +61,8 @@ param ( Set-StrictMode -version 2.0 $ErrorActionPreference = "Stop" +$BuildCategory = "" +$BuildMessage = "" function Print-Usage() { Write-Host "Common settings:" @@ -303,6 +305,9 @@ function EnablePreviewSdks() { } try { + $script:BuildCategory = "Build" + $script:BuildMessage = "Failure preparing build" + Process-Arguments . (Join-Path $PSScriptRoot "build-utils.ps1") @@ -317,9 +322,11 @@ try { } if ($bootstrap) { + $script:BuildMessage = "Failure building bootstrap compiler" $bootstrapDir = Make-BootstrapBuild } + $script:BuildMessage = "Failure building product" if ($restore -or $build -or $rebuild -or $pack -or $sign -or $publish) { if ($noVisualStudio) { BuildCompiler @@ -332,6 +339,8 @@ try { VerifyAssemblyVersionsAndSymbols } + $script:BuildCategory = "Test" + $script:BuildMessage = "Failure running tests" $desktopTargetFramework = "net472" $coreclrTargetFramework = "netcoreapp3.0" @@ -421,6 +430,7 @@ catch { Write-Host $_ Write-Host $_.Exception Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Category $script:BuildCategory -Message $script:BuildMessage ExitWithExitCode 1 } finally { From b5aa4a0392fc461e2314c9631ee51cffa802535b Mon Sep 17 00:00:00 2001 From: "Brett V. Forsgren" Date: Thu, 16 Jan 2020 16:22:44 -0800 Subject: [PATCH 2/2] fix linux build telemetry --- eng/build.sh | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/eng/build.sh b/eng/build.sh index a53fce7914..6340d55746 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -66,6 +66,9 @@ properties="" docker=false args="" +BuildCategory="" +BuildMessage="" + if [[ $# = 0 ]] then usage @@ -150,6 +153,8 @@ done . "$scriptroot/common/tools.sh" function TestUsingNUnit() { + BuildCategory="Test" + BuildMessage="Error running tests" testproject="" targetframework="" while [[ $# > 0 ]]; do @@ -180,14 +185,12 @@ function TestUsingNUnit() { projectname="${projectname%.*}" testlogpath="$artifacts_dir/TestResults/$configuration/${projectname}_$targetframework.xml" args="test \"$testproject\" --no-restore --no-build -c $configuration -f $targetframework --test-adapter-path . --logger \"nunit;LogFilePath=$testlogpath\"" - "$DOTNET_INSTALL_DIR/dotnet" $args || { - local exit_code=$? - Write-PipelineTelemetryError -category 'Test' "dotnet test failed for $testproject:$targetframework (exit code $exit_code)." - ExitWithExitCode $exit_code - } + "$DOTNET_INSTALL_DIR/dotnet" $args || exit $? } function BuildSolution { + BuildCategory="Build" + BuildMessage="Error preparing build" local solution="FSharp.sln" echo "$solution:" @@ -229,33 +232,28 @@ function BuildSolution { rm -fr $bootstrap_dir fi if [ ! -f "$bootstrap_dir/fslex.dll" ]; then + BuildMessage="Error building tools" MSBuild "$repo_root/src/buildtools/buildtools.proj" \ /restore \ /p:Configuration=$bootstrap_config \ - /t:Publish || { - local exit_code=$? - Write-PipelineTelemetryError -category 'Build' "Error building buildtools (exit code '$exit_code')." - ExitWithExitCode $exit_code - } + /t:Publish mkdir -p "$bootstrap_dir" cp -pr $artifacts_dir/bin/fslex/$bootstrap_config/netcoreapp3.0/publish $bootstrap_dir/fslex cp -pr $artifacts_dir/bin/fsyacc/$bootstrap_config/netcoreapp3.0/publish $bootstrap_dir/fsyacc fi if [ ! -f "$bootstrap_dir/fsc.exe" ]; then + BuildMessage="Error building bootstrap" MSBuild "$repo_root/proto.proj" \ /restore \ /p:Configuration=$bootstrap_config \ - /t:Publish || { - local exit_code=$? - Write-PipelineTelemetryError -category 'Build' "Error building bootstrap compiler (exit code '$exit_code')." - ExitWithExitCode $exit_code - } + /t:Publish cp -pr $artifacts_dir/bin/fsc/$bootstrap_config/netcoreapp3.0/publish $bootstrap_dir/fsc fi # do real build + BuildMessage="Error building solution" MSBuild $toolset_build_proj \ $bl \ /v:$verbosity \ @@ -271,13 +269,20 @@ function BuildSolution { /p:ContinuousIntegrationBuild=$ci \ /p:QuietRestore=$quiet_restore \ /p:QuietRestoreBinaryLog="$binary_log" \ - $properties || { - local exit_code=$? - Write-PipelineTelemetryError -category 'Build' "Error building solution (exit code '$exit_code')." - ExitWithExitCode $exit_code - } + $properties +} + +function TrapAndReportError { + local exit_code=$? + if [[ ! $exit_code == 0 ]]; then + Write-PipelineTelemetryError -category $BuildCategory "$BuildMessage (exit code '$exit_code')." + ExitWithExitCode $exit_code + fi } +# allow early termination to report the appropriate build failure reason +trap TrapAndReportError EXIT + InitializeDotNetCli $restore BuildSolution @@ -293,4 +298,3 @@ if [[ "$test_core_clr" == true ]]; then fi ExitWithExitCode 0 -