Repository navigation
Enable ILLink caching and post-build purging in CI #135067
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
+172
−11
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
aa2d448
Add experimental ILLink task caching and cache maintenance
sbomer 64b6860
Fix ILLink cache analyzer diagnostics
sbomer 37c5219
Fix ILLink cache purge test on case-insensitive filesystems
sbomer 9f2118f
Simplify ILLink cache last-used marker update
sbomer 72f0f94
Fall back to directory creation time for invalid ILLink cache markers
sbomer 0932cf7
Remove redundant ILLink ExtraArgs cache-key test case
sbomer 896eb0b
Support ILLink caching in runtime library builds
sbomer 2edf5de
Enable ILLink caching and post-build purging in CI
sbomer 1182903
Support ILLink caching in runtime library builds
sbomer 645e0a7
Separate Debug and Release ILLink CI cache snapshots
sbomer babee1b
Merge updated ILLink runtime cache into CI cache branch
sbomer 66a06f1
Scope ILLink CI cache to linker build and reuse purge tool
sbomer 81b1728
Merge main into ILLink runtime cache integration
sbomer f106de4
Merge updated ILLink runtime cache parent into CI cache branch
sbomer 7858226
Merge main into ILLink CI cache branch
sbomer 04b3e80
Remove obsolete cache purge ordering comment
sbomer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| parameters: | ||
| osGroup: 'linux' | ||
|
|
||
| steps: | ||
| - ${{ if ne(parameters.osGroup, 'windows') }}: | ||
| - script: | | ||
| set -euo pipefail | ||
|
|
||
| if [[ -z "${ILLINK_EXPERIMENTAL_CACHE_PATH:-}" || | ||
| -z "${ILLINK_CACHE_BUILD_START:-}" ]]; then | ||
| echo "##vso[task.logissue type=warning]ILLink cache configuration or build-start timestamp is unavailable; skipping purge." | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [[ ! -e "$ILLINK_EXPERIMENTAL_CACHE_PATH/v1" ]]; then | ||
| echo "No ILLink cache entries were created; skipping purge." | ||
| exit 0 | ||
| fi | ||
|
|
||
| dotnet="$(Build.SourcesDirectory)/.dotnet/dotnet" | ||
| if [[ ! -x "$dotnet" ]]; then | ||
| echo "##vso[task.logissue type=warning]The build SDK is unavailable; skipping ILLink cache purge." | ||
| exit 0 | ||
| fi | ||
|
|
||
| tool="" | ||
| for candidate in "$(Build.SourcesDirectory)"/artifacts/bin/ILLink.CacheTool/*/net*/dotnet-illink-cache.dll; do | ||
| if [[ -f "$candidate" ]]; then | ||
| tool="$candidate" | ||
| break | ||
| fi | ||
| done | ||
|
|
||
| if [[ -z "$tool" ]]; then | ||
| echo "##vso[task.logissue type=warning]The ILLink cache maintenance tool was not built; skipping purge." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! "$dotnet" "$tool" purge \ | ||
| --cache-directory "$ILLINK_EXPERIMENTAL_CACHE_PATH" \ | ||
| --before "$ILLINK_CACHE_BUILD_START"; then | ||
| echo "##vso[task.logissue type=warning]ILLink cache purge failed; see the tool diagnostics above." | ||
| fi | ||
| displayName: Purge unused ILLink cache entries | ||
| condition: and(succeeded(), eq(variables['ILLINK_EXPERIMENTAL_CACHE'], 'true')) | ||
| continueOnError: true | ||
|
|
||
| - ${{ if eq(parameters.osGroup, 'windows') }}: | ||
| - pwsh: | | ||
| if ([string]::IsNullOrEmpty($env:ILLINK_EXPERIMENTAL_CACHE_PATH) -or | ||
| [string]::IsNullOrEmpty($env:ILLINK_CACHE_BUILD_START)) { | ||
| Write-Host "##vso[task.logissue type=warning]ILLink cache configuration or build-start timestamp is unavailable; skipping purge." | ||
| exit 0 | ||
| } | ||
|
|
||
| if (-not (Test-Path -LiteralPath (Join-Path $env:ILLINK_EXPERIMENTAL_CACHE_PATH "v1") -PathType Container)) { | ||
| Write-Host "No ILLink cache entries were created; skipping purge." | ||
| exit 0 | ||
| } | ||
|
|
||
| $dotnet = Join-Path "$(Build.SourcesDirectory)" ".dotnet/dotnet.exe" | ||
| if (-not (Test-Path -LiteralPath $dotnet -PathType Leaf)) { | ||
| Write-Host "##vso[task.logissue type=warning]The build SDK is unavailable; skipping ILLink cache purge." | ||
| exit 0 | ||
| } | ||
|
|
||
| $toolRoot = Join-Path "$(Build.SourcesDirectory)" "artifacts/bin/ILLink.CacheTool" | ||
| if (-not (Test-Path -LiteralPath $toolRoot -PathType Container)) { | ||
| Write-Host "##vso[task.logissue type=warning]The ILLink cache maintenance tool was not built; skipping purge." | ||
| exit 1 | ||
| } | ||
|
|
||
| $tool = Get-ChildItem -LiteralPath $toolRoot -Filter "dotnet-illink-cache.dll" -File -Recurse | | ||
| Sort-Object FullName | Select-Object -First 1 | ||
| if ($null -eq $tool) { | ||
| Write-Host "##vso[task.logissue type=warning]The ILLink cache maintenance tool was not built; skipping purge." | ||
| exit 1 | ||
| } | ||
|
|
||
| & $dotnet $tool.FullName purge ` | ||
| --cache-directory $env:ILLINK_EXPERIMENTAL_CACHE_PATH ` | ||
| --before $env:ILLINK_CACHE_BUILD_START | ||
| if ($LASTEXITCODE -ne 0) { | ||
| Write-Host "##vso[task.logissue type=warning]ILLink cache purge failed; see the tool diagnostics above." | ||
| } | ||
|
sbomer marked this conversation as resolved.
|
||
| displayName: Purge unused ILLink cache entries | ||
| condition: and(succeeded(), eq(variables['ILLINK_EXPERIMENTAL_CACHE'], 'true')) | ||
| continueOnError: true | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| parameters: | ||
| archType: 'x64' | ||
| osGroup: 'linux' | ||
| nameSuffix: '' | ||
| osSubgroup: '' | ||
|
|
||
| steps: | ||
| - ${{ if or(eq(parameters.osGroup, 'windows'), and(in(parameters.osGroup, 'linux', 'freebsd', 'openbsd', 'osx'), in(parameters.archType, 'x64', 'arm64'))) }}: | ||
| # Use the same branch-scoped restore policy as the compiler caches. Each job | ||
| # works on its own restored copy, so post-build purge cannot affect another job. | ||
| # Keep Debug and Release snapshots separate in rolling builds. | ||
| - task: Cache@2 | ||
| displayName: ILLink task cache | ||
| continueOnError: true | ||
| inputs: | ||
| key: illink | v1 | ${{ parameters.osGroup }}${{ parameters.osSubgroup }} | ${{ parameters.archType }} | ${{ parameters.nameSuffix }} | "$(buildConfigUpper)" | "$(Build.BuildId)" | ||
| path: $(Pipeline.Workspace)/.illink-cache | ||
| restoreKeys: | | ||
| illink | v1 | ${{ parameters.osGroup }}${{ parameters.osSubgroup }} | ${{ parameters.archType }} | ${{ parameters.nameSuffix }} | "$(buildConfigUpper)" | ||
|
|
||
| - ${{ if ne(parameters.osGroup, 'windows') }}: | ||
| - script: | | ||
| set -euo pipefail | ||
| mkdir -p "$(Pipeline.Workspace)/.illink-cache" | ||
| buildStart="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" | ||
| echo "##vso[task.setvariable variable=ILLINK_EXPERIMENTAL_CACHE_PATH]$(Pipeline.Workspace)/.illink-cache" | ||
| echo "##vso[task.setvariable variable=ILLINK_CACHE_BUILD_START]$buildStart" | ||
| echo "##vso[task.setvariable variable=ILLINK_EXPERIMENTAL_CACHE]true" | ||
| displayName: Configure experimental ILLink task cache | ||
| continueOnError: true | ||
|
|
||
| - ${{ if eq(parameters.osGroup, 'windows') }}: | ||
| - pwsh: | | ||
| $cachePath = Join-Path "$(Pipeline.Workspace)" ".illink-cache" | ||
| New-Item -ItemType Directory -Path $cachePath -Force | Out-Null | ||
| $buildStart = [DateTime]::UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ") | ||
|
|
||
| Write-Host "##vso[task.setvariable variable=ILLINK_EXPERIMENTAL_CACHE_PATH]$cachePath" | ||
| Write-Host "##vso[task.setvariable variable=ILLINK_CACHE_BUILD_START]$buildStart" | ||
| Write-Host "##vso[task.setvariable variable=ILLINK_EXPERIMENTAL_CACHE]true" | ||
| displayName: Configure experimental ILLink task cache | ||
| continueOnError: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.