Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build evaluation report in CI and when enabled #5903

Merged
merged 12 commits into from
Feb 14, 2025
3 changes: 2 additions & 1 deletion eng/pipelines/templates/BuildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ steps:
-configuration ${{ parameters.buildConfig }}
-warnAsError ${{ parameters.warnAsError }}
/bl:${{ parameters.repoLogPath }}/build.binlog
/p:EnableEvaluationReportBuild=true
$(_OfficialBuildIdArgs)
displayName: Build

- ${{ if eq(parameters.isWindows, 'true') }}:
- pwsh: |
$(Build.SourcesDirectory)/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/azure-devops-report/build.ps1 -OutputPath $(Build.ArtifactStagingDirectory)\VSIX
$(Build.SourcesDirectory)/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/azure-devops-report/build.ps1 -OutputPath $(Build.Arcade.ArtifactsPath)/packages
displayName: Build Azure DevOps plugin

- ${{ if ne(parameters.skipTests, 'true') }}:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />

<!-- Generate a version constant that can be accessed from the C# code. -->
<Target Name="GenerateVersionConstant" BeforeTargets="CoreCompile">
<PropertyGroup>
<_ConstantsFilePath>$(IntermediateOutputPath)Constants.g.cs</_ConstantsFilePath>
<_Lines>
// <auto-generated>
// This file is auto-generated by MSBuild.
// </auto-generated>

namespace $(RootNamespace)%3B

internal static class Constants
{
public const string Version = "$(Version)"%3B
}
</_Lines>
</PropertyGroup>

<Message Text="Generating $(_ConstantsFilePath)." Importance="high" />

<WriteLinesToFile File="$(_ConstantsFilePath)"
Lines="$(_Lines)"
Overwrite="true"
WriteOnlyWhenDifferent="true" />

<ItemGroup>
<Compile Include="$(_ConstantsFilePath)" />
</ItemGroup>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,4 @@
<ItemGroup>
<InternalsVisibleToTest Include="Microsoft.Extensions.AI.Evaluation.Console.Tests" />
</ItemGroup>

<!-- Generate a version constant that can be accessed from the C# code. -->
<Target Name="GenerateVersionConstant" BeforeTargets="CoreCompile">
<PropertyGroup>
<ConstantsFilePath>$(IntermediateOutputPath)Constants.g.cs</ConstantsFilePath>
<Lines>
// <auto-generated>
// This file is auto-generated by MSBuild.
// </auto-generated>

namespace Microsoft.Extensions.AI.Evaluation.Console%3B

internal static class Constants
{
public const string Version = "$(Version)"%3B
}
</Lines>
</PropertyGroup>

<Message Text="Generating $(ConstantsFilePath)." Importance="high" />

<WriteLinesToFile File="$(ConstantsFilePath)"
Lines="$(Lines)"
Overwrite="true"
WriteOnlyWhenDifferent="true" />

<ItemGroup>
<Compile Include="$(ConstantsFilePath)" />
</ItemGroup>
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<!--
NOTE: To build and test the TypeScript code that this project depends on, set the 'EnableEvaluationReportBuild'
environment variable to 'true'. Note that the TypeScript build depends on Node.js tools. So you will need to
install the latest version of Node.js from https://nodejs.org/ as a prerequisite before setting the
'EnableEvaluationReportBuild' environment variable.
-->

<PropertyGroup>
<Description>A library for aggregating and reporting evaluation data. This library also includes support for caching LLM responses.</Description>
<TargetFrameworks>$(TargetFrameworks);netstandard2.0</TargetFrameworks>
Expand All @@ -23,7 +30,8 @@
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="..\TypeScript\html-report\dist\index.html" Visible="false">
<EmbeddedResource Condition="'$(EnableEvaluationReportBuild)'=='true'"
Include="..\TypeScript\html-report\dist\index.html" Visible="false">
<LogicalName>Reporting.HTML.index.html</LogicalName>
</EmbeddedResource>
</ItemGroup>
Expand All @@ -33,59 +41,4 @@
<InternalsVisibleToTest Include="Microsoft.Extensions.AI.Evaluation.Reporting.Tests" />
</ItemGroup>

<!-- Build the report code before this, so it can be embedded.
Setting the BeforeTargets=DispatchToInnerBuilds allows it to build only once before
the multiple parallel builds are invoked for each target framework. -->
<Target Name="BuildTypescriptBundle"
BeforeTargets="DispatchToInnerBuilds"
Outputs="..\TypeScript\html-report\dist\index.html">
<Message Text="Build the Typescript bundle" Importance="high" />
<Exec Command="npm install" WorkingDirectory="..\TypeScript" />
<Exec Command="node build-if-out-of-date.js" WorkingDirectory="..\TypeScript" />
</Target>

<!-- Generate a version constant that can be accessed from the C# code. -->
<Target Name="GenerateVersionConstant" BeforeTargets="CoreCompile">
<PropertyGroup>
<ConstantsFilePath>$(IntermediateOutputPath)Constants.g.cs</ConstantsFilePath>
<Lines>
// <auto-generated>
// This file is auto-generated by MSBuild.
// </auto-generated>

namespace Microsoft.Extensions.AI.Evaluation.Reporting%3B

internal static class Constants
{
public const string Version = "$(Version)"%3B
}
</Lines>
</PropertyGroup>

<Message Text="Generating $(ConstantsFilePath)." Importance="high" />

<WriteLinesToFile File="$(ConstantsFilePath)"
Lines="$(Lines)"
Overwrite="true"
WriteOnlyWhenDifferent="true" />

<ItemGroup>
<Compile Include="$(ConstantsFilePath)" />
</ItemGroup>
</Target>

<!-- Generate a version file that can be accessed from the script that builds the Azure DevOps Extension pacakge. -->
<Target Name="StampVSIXPackageVersion" BeforeTargets="CoreCompile">
<PropertyGroup>
<VSIXPackageVersionFile>..\TypeScript\azure-devops-report\VSIXPackageVersion.json</VSIXPackageVersionFile>
<VSIXVersion>$(VersionPrefix).42424242</VSIXVersion>
<VSIXVersion Condition=" '$(VersionSuffixDateStamp)'!='' ">$(VersionPrefix).$(VersionSuffixDateStamp)$(VersionSuffixBuildOfTheDayPadded)</VSIXVersion>
<Lines>{"PackageVersion":"$(VSIXVersion)"}</Lines>
</PropertyGroup>
<WriteLinesToFile File="$(VSIXPackageVersionFile)"
Lines="$(Lines)"
Overwrite="true"
WriteOnlyWhenDifferent="true" />
</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />

<PropertyGroup>
<_TypescriptRootPath>$(MSBuildThisFileDirectory)/TypeScript</_TypescriptRootPath>
<_NpmInstallStampFile>$(_TypescriptRootPath)/node_modules/.installed</_NpmInstallStampFile>
</PropertyGroup>

<Target Name="NpmInstall"
Condition="'$(EnableEvaluationReportBuild)'=='true'"
Inputs="$(_TypescriptRootPath)/package.json"
Outputs="$(_NpmInstallStampFile)">
<Exec Command="npm install" WorkingDirectory="$(_TypescriptRootPath)" />
<Touch Files="$(_NpmInstallStampFile)" AlwaysCreate="true" />
</Target>

<!-- Build the report code before this, so it can be embedded.
Setting the BeforeTargets=DispatchToInnerBuilds allows it to build only once before
the multiple parallel builds are invoked for each target framework. -->
<Target Name="BuildTypescriptBundle"
DependsOnTargets="NpmInstall"
BeforeTargets="DispatchToInnerBuilds"
Condition="'$(EnableEvaluationReportBuild)'=='true'"
Inputs="$(_TypescriptRootPath)/**/*.*"
Outputs="$(_TypescriptRootPath)/html-report/dist/index.html">
<Message Text="Build the Typescript bundle" Importance="high" />
<Exec Command="node build-if-out-of-date.js" WorkingDirectory="$(_TypescriptRootPath)" />
</Target>

<!-- Generate a version constant that can be accessed from the C# code. -->
<Target Name="GenerateVersionConstant" BeforeTargets="CoreCompile">
<PropertyGroup>
<_ConstantsFilePath>$(IntermediateOutputPath)Constants.g.cs</_ConstantsFilePath>
<_Lines>
// <auto-generated>
// This file is auto-generated by MSBuild.
// </auto-generated>

namespace $(RootNamespace)%3B

internal static class Constants
{
public const string Version = "$(Version)"%3B
}
</_Lines>
</PropertyGroup>

<Message Text="Generating $(_ConstantsFilePath)." Importance="high" />

<WriteLinesToFile File="$(_ConstantsFilePath)"
Lines="$(_Lines)"
Overwrite="true"
WriteOnlyWhenDifferent="true" />

<ItemGroup>
<Compile Include="$(_ConstantsFilePath)" />
</ItemGroup>
</Target>

<!-- Generate a version file that can be accessed from the script that builds the Azure DevOps Extension pacakge. -->
<Target Name="StampVSIXPackageVersion" BeforeTargets="CoreCompile">
<PropertyGroup>
<_VSIXPackageVersionFile>$(MSBuildThisFileDirectory)\TypeScript\azure-devops-report\VSIXPackageVersion.json</_VSIXPackageVersionFile>

<_VSIXVersion>$(VersionPrefix).42424242</_VSIXVersion>
<_VSIXVersion Condition=" '$(VersionSuffixDateStamp)'!='' ">$(VersionPrefix).$(VersionSuffixDateStamp)$(VersionSuffixBuildOfTheDayPadded)</_VSIXVersion>

<_Lines>{"PackageVersion":"$(_VSIXVersion)"}</_Lines>
</PropertyGroup>

<WriteLinesToFile File="$(_VSIXPackageVersionFile)"
Lines="$(_Lines)"
Overwrite="true"
WriteOnlyWhenDifferent="true" />
</Target>
</Project>