Skip to content

Use -noBuild in second build steps of test jobs #39998

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

Merged
merged 2 commits into from
Feb 8, 2022

Conversation

dougbu
Copy link
Contributor

@dougbu dougbu commented Feb 4, 2022

  • building again in Publish target adds nothing in most cases
  • use -noBuildRepoTasks more consistently
    • again, building the repo tasks wastefully repeated work done in previous build step
  • use -noBuildJava more consistently in quarantined pipelines
    • Java tests aren't worth testing or building in these pipelines because they cannot be quarantined
  • remove -noRestore and -noBuildDeps when -noBuild specified; redundant
  • work around dotnet publish --no-build over-publishes from referenced projects #43835
    • do not publish .cshtml files of most test asset projects when $(NoBuild) is set
  • update FunctionalTestWithAssets.targets to help Publish succeed when $(NoBuild) is set
    • fixes build jobs in quarantined-pr pipeline where --no-build was already specified
  • for IIS test assets, perform all builds needed for their profiles within Build target
    • move ReferenceTestTasks=false and comments about it to where property matters
    • merge separate targets in FunctionalTest.props to make items available during (now separate) Publish

nits:

  • touch up RunHelix.ps1 console output
  • reorder command line arguments for consistency in changed parts of the YAML files
  • move NoBuild=true setting out of FunctionalTestWithAssets.props
  • use BeforeTargets in FunctionalTest.props to improve determinism

@ghost ghost added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Feb 4, 2022
@dougbu dougbu force-pushed the dougbu/dont.repeat.yourself branch 8 times, most recently from b8f2192 to c8780f0 Compare February 6, 2022 07:25
@dougbu dougbu changed the title Do not build when publishing in Helix CI jobs Use -noBuild in second build steps of test jobs Feb 6, 2022
@dougbu dougbu force-pushed the dougbu/dont.repeat.yourself branch 4 times, most recently from c182bc9 to 7c1f389 Compare February 7, 2022 19:31
@dougbu dougbu requested review from HaoK and a team February 7, 2022 21:35
@dougbu dougbu marked this pull request as ready for review February 7, 2022 21:35
@dougbu
Copy link
Contributor Author

dougbu commented Feb 7, 2022

Reasoning from a sample set of one, I'd say this PR speeds up PR validation significantly. Build #20220207.20 took only 1:20 while rolling builds of 'main' almost-always take 1:40 or more. Will rerun to see if this was a fluke since all that should have been removed was up-to-date checks.

@dougbu
Copy link
Contributor Author

dougbu commented Feb 7, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@dougbu
Copy link
Contributor Author

dougbu commented Feb 7, 2022

/fyi @mmitche (Mr. Build Perf 😺)

@@ -52,7 +52,8 @@ $env:BUILD_REPOSITORY_NAME="aspnetcore"
$env:SYSTEM_TEAMPROJECT="aspnetcore"

Write-Host -ForegroundColor Yellow "If running tests that need the shared Fx, run './build -pack -all' before this."
Write-Host -ForegroundColor Yellow "And if packing for a different platform, add '/p:CrossgenOutput=false'."
Write-Host -ForegroundColor Yellow "If everything is up-to-date, add '/p:NoBuild=true' to this command."
Write-Host -ForegroundColor Yellow "Or, if only the test project is out-of-date, add '/p:BuildProjectReferences=false'."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BrennanConroy these possibilities should speed up use of this script even more than setting $(p:DoNotRequireSharedFxHelix) 😸

@@ -19,7 +19,8 @@
<ProjectReference Include="..\..\shared\Mvc.Core.TestCommon\Microsoft.AspNetCore.Mvc.Core.TestCommon.csproj" />
<ProjectReference Include="..\WebSites\*\*.csproj"
Exclude="..\WebSites\ControllersFromServicesClassLibrary\ControllersFromServicesClassLibrary.csproj;
..\WebSites\RazorBuildWebSite.*\RazorBuildWebSite.*.csproj" />
..\WebSites\RazorBuildWebSite.*\RazorBuildWebSite.*.csproj;
..\WebSites\RazorPagesClassLibrary\RazorPagesClassLibrary.csproj" />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit I noticed while in the neighbourhood

<Project>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.targets))\Directory.Build.targets" />

<!-- Work around https://github.com/dotnet/sdk/issues/23777. Reset ContentWithTargetPath items if not building. -->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugly bug I noticed while working on this PR and this workaround likely doesn't cover all the real-world cases. /cc @marcpopMSFT @dsplaisted

<ItemGroup>
<Content Include="..\Common.FunctionalTests\Infrastructure\*.config" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<Target Name="BuildAssets" AfterTargets="Build" Condition="'$(ExcludeFromBuild)' != 'true'">
<MSBuild Projects="@(ProjectReference)" Targets="PublishTestsAssets" SkipNonexistentTargets="true" BuildInParallel="True">
<Target Name="CopyAssets" BeforeTargets="Publish" Condition=" '$(ExcludeFromBuild)' != true ">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doing the two parts in separate targets worked when Publish always depended on Build

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any noticeable change here in behavior that we need to be aware of or is this just implementation details?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing I could detect because the published files from the test assets aren't used in local tests.

@@ -59,4 +63,13 @@
</PackageReference>
<Reference Include="xunit.assert" />
</ItemGroup>

<!-- Repeat Build target for win-x64 to allow later Publish w/ NoBuild=true. -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just confirming that this already covers the Win32/arm64 cases as well, or if I'll need to revisit this section for arm64 later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you add an arm64 profile to the @(TestAssetPublishProfile) item group, will need another target here too. Not sure how much the Condition will need to change w/o seeing what profile(s) you need to test. Of course, tests might have enough coverage w/o doing the self-contained thing for each possible Windows platform.

@dougbu
Copy link
Contributor Author

dougbu commented Feb 8, 2022

Speed-up much less noticeable in build #20220207.25. That ran for 1:44 which at least is below the 2w average for these builds.

- building again in Publish target adds nothing in most cases
- use `-noBuildRepoTasks` more consistently
  - again, building the repo tasks wastefully repeated work done in previous build step
- use `-noBuildJava` more consistently in quarantined pipelines
  - Java tests aren't worth testing _or building_ in these pipelines because they cannot be quarantined
- remove `-noRestore` and `-noBuildDeps` when `-noBuild` specified; redundant
- work around https://github.com/dotnet/sdk/issues/23777
  - do not publish .cshtml files of most test asset projects when `$(NoBuild)` is set
- update FunctionalTestWithAssets.targets to help Publish succeed when `$(NoBuild)` is set
  - fixes build jobs in quarantined-pr pipeline where `--no-build` was already specified
- for IIS test assets, perform all builds needed for their profiles within Build target
  - move `ReferenceTestTasks=false` and comments about it to where property matters
  - merge separate targets in FunctionalTest.props to make items available during (now separate) Publish

nits:
- touch up RunHelix.ps1 console output
- reorder command line arguments for consistency in changed parts of the YAML files
- move `NoBuild=true` setting out of FunctionalTestWithAssets.props
- use `BeforeTargets` in FunctionalTest.props to improve determinism
@dougbu dougbu force-pushed the dougbu/dont.repeat.yourself branch from 7c1f389 to 898347f Compare February 8, 2022 00:26
@dougbu dougbu enabled auto-merge (squash) February 8, 2022 00:29
@dougbu dougbu merged commit 633b3d7 into dotnet:main Feb 8, 2022
@dougbu dougbu deleted the dougbu/dont.repeat.yourself branch February 8, 2022 02:06
@ghost ghost added this to the 7.0-preview2 milestone Feb 8, 2022
@dougbu
Copy link
Contributor Author

dougbu commented Feb 8, 2022

/fyi all, last validation build #20220207.35 took 1:29 overall (including waiting 6 minutes to get the Helix job a build agent). Seems there's some speed-up here but, like the old world, the builds don't all take the same amount of time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants