Update actions/upload-artifact action to v7.0.1 (#931) #2144
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
| name: 🏭 Build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - 'v*.*' | |
| - validate/* | |
| pull_request: | |
| workflow_dispatch: | |
| env: | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
| BUILDCONFIGURATION: Release | |
| NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages/ | |
| jobs: | |
| build: | |
| name: 🏭 Build | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-24.04 | |
| rid: linux-x64 | |
| - os: macos-15 | |
| rid: osx-arm64 | |
| - os: windows-2025 | |
| rid: win-x64 | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 # avoid shallow clone so nbgv can do its work. | |
| - name: ⚙ Install prerequisites | |
| run: | | |
| ./init.ps1 -UpgradePrerequisites -NoNuGetCredProvider | |
| dotnet --info | |
| # Print mono version if it is present. | |
| if (Get-Command mono -ErrorAction SilentlyContinue) { | |
| mono --version | |
| } | |
| shell: pwsh | |
| - name: ⚙️ Set pipeline variables based on source | |
| run: tools/variables/_define.ps1 | |
| shell: pwsh | |
| - name: 🛠 build | |
| run: dotnet build tools/dirs.proj -t:build,pack,publish --no-restore -c ${{ env.BUILDCONFIGURATION }} -warnAsError -warnNotAsError:NU1901,NU1902,NU1903,NU1904 /bl:"${{ runner.temp }}/_artifacts/build_logs/build.binlog" | |
| - name: 🧪 test | |
| run: tools/dotnet-test-cloud.ps1 -Configuration ${{ env.BUILDCONFIGURATION }} -Agent ${{ runner.os }} -IncludeNativeAOT | |
| shell: pwsh | |
| - name: 🏭 Verify NativeAOT image size | |
| run: | | |
| Function GetSizeInMB($Path) { | |
| if (!($IsMacOS -or $IsLinux)) { $Path += '.exe' } | |
| $FileName = Split-Path $Path -Leaf | |
| (gci $Path).Length / 1024 / 1024 | |
| } | |
| $Path = './bin/AotNativeConsole/${{ env.BUILDCONFIGURATION }}/net10.0/${{ matrix.rid }}/publish/AotNativeConsole' | |
| $ActualSize = GetSizeInMB($Path) | |
| # Allow variance of a small threshold of the expected value. | |
| # Fail even if it's smaller than anticipated so that the expected window can be shrunk in this file. | |
| if ($IsLinux) { | |
| $ExpectedSize = 7.03 | |
| } elseif ($IsMacOS) { | |
| $ExpectedSize = 6.43 | |
| } else { | |
| $ExpectedSize = 6.83 | |
| } | |
| $AllowedVariance = 0.2 | |
| $SizeCheckPassed = [math]::Abs($ActualSize - $ExpectedSize) -le $AllowedVariance | |
| $Result = if ($SizeCheckPassed) { "PASS" } else { "FAIL" } | |
| # Store details for the verify job | |
| $Details = @{ | |
| FileName = Split-Path $Path -Leaf | |
| ActualSize = $ActualSize | |
| ExpectedSize = $ExpectedSize | |
| AllowedVariance = $AllowedVariance | |
| Result = $Result | |
| } | |
| $Details | ConvertTo-Json | Out-File -FilePath "aot-size-result.json" | |
| shell: pwsh | |
| - name: 📤 Upload AOT size result | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: aot-size-${{ matrix.os }}-${{ matrix.rid }} | |
| path: aot-size-result.json | |
| - name: 💅🏻 Verify formatted code | |
| run: dotnet format --verify-no-changes --no-restore --exclude ./samples/AnalyzerDocs/NBMsgPack051.cs | |
| shell: pwsh | |
| if: runner.os == 'Linux' | |
| - name: 📚 Verify docfx build | |
| run: dotnet docfx docfx/docfx.json --warningsAsErrors --disableGitFeatures | |
| env: | |
| DocFx: true # Workaround https://github.com/dotnet/docfx/issues/10808 | |
| if: runner.os == 'Linux' | |
| - name: ⚙ Update pipeline variables based on build outputs | |
| run: tools/variables/_define.ps1 | |
| shell: pwsh | |
| - name: 📢 Publish artifacts | |
| uses: ./.github/actions/publish-artifacts | |
| if: cancelled() == false | |
| - name: 📦 Push CI package | |
| shell: pwsh | |
| run: | | |
| dotnet nuget push ${{ runner.temp }}/_artifacts/deployables/*.nupkg -s https://nuget.pkg.github.com/aarnott/index.json -k ${{ secrets.GITHUB_TOKEN }} | |
| if ('${{ secrets.AZP_TOKEN }}') { | |
| dotnet nuget add source https://pkgs.dev.azure.com/andrewarnott/OSS/_packaging/PublicCI/nuget/v3/index.json -n publicCI -u andrewarnott -p ${{ secrets.AZP_TOKEN }} --store-password-in-clear-text | |
| dotnet nuget push ${{ runner.temp }}/_artifacts/deployables/*.nupkg -s publicCI -k x | |
| } | |
| if: success() && runner.os == 'Linux' && github.event_name != 'pull_request' | |
| continue-on-error: true | |
| - name: 📢 Publish code coverage results to codecov.io | |
| run: | | |
| if ('${{ secrets.CODECOV_TOKEN }}') { | |
| ./tools/publish-CodeCov.ps1 -CodeCovToken '${{ secrets.CODECOV_TOKEN }}' -PathToCodeCoverage "${{ runner.temp }}/_artifacts/coverageResults" -Name "${{ runner.os }} Coverage Results" -Flags "${{ runner.os }}" | |
| } | |
| shell: pwsh | |
| timeout-minutes: 3 | |
| continue-on-error: true | |
| verify-aot-size: | |
| name: 👮🏼 NativeAOT image size guard | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: 📥 Download AOT size results | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| pattern: aot-size-* | |
| path: aot-results | |
| - name: 🧪 Check AOT sizes | |
| run: | | |
| $FailedChecks = @() | |
| # Define the expected combinations | |
| $Combinations = @( | |
| @{ OS = "ubuntu-24.04"; RID = "linux-x64" }, | |
| @{ OS = "macos-15"; RID = "osx-arm64" }, | |
| @{ OS = "windows-2025"; RID = "win-x64" } | |
| ) | |
| "Target | Actual size | Expected size | Verdict | |
| --|--|--|--" >> $env:GITHUB_STEP_SUMMARY | |
| foreach ($Combo in $Combinations) { | |
| $ArtifactName = "aot-size-$($Combo.OS)-$($Combo.RID)" | |
| $ResultFile = "aot-results/$ArtifactName/aot-size-result.json" | |
| if (Test-Path $ResultFile) { | |
| $Details = Get-Content $ResultFile | ConvertFrom-Json | |
| $Emoji = if ($Details.Result -eq 'PASS') { "✅" } else { "❌" } | |
| " $($Combo.OS) | {0:0.00} MB | {1:0.00}±{2:0.0} MB | $Emoji" -f $Details.ActualSize, $Details.ExpectedSize, $Details.AllowedVariance >> $env:GITHUB_STEP_SUMMARY | |
| Write-Host "=== $($Combo.RID) ===" | |
| Write-Host ("EXPECTED size: {0:0.00}±{1:0.0} MB" -f $Details.ExpectedSize, $Details.AllowedVariance) | |
| Write-Host ("ACTUAL size: {0:0.00} MB" -f $Details.ActualSize) | |
| Write-Host "AOT size check: $($Details.Result)" | |
| if ($Details.Result -eq "FAIL") { | |
| $FailedChecks += "$($Combo.OS) ($($Combo.RID))" | |
| } else { | |
| Write-Host "NativeAOT image size check passed." | |
| } | |
| Write-Host "" | |
| } else { | |
| Write-Host "Warning: Result file not found for $($Combo.OS) ($($Combo.RID))" | |
| } | |
| } | |
| if ($FailedChecks.Count -gt 0) { | |
| Write-Error "NativeAOT image size check failed for: $($FailedChecks -join ', ')" | |
| exit 1 | |
| } else { | |
| Write-Host "All NativeAOT image size checks passed!" | |
| } | |
| shell: pwsh | |
| codeql: | |
| name: 🔍 CodeQL Security Analysis | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| security-events: write | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 # avoid shallow clone so nbgv can do its work. | |
| - name: 🔍 Initialize CodeQL | |
| uses: github/codeql-action/init@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4.35.2 | |
| with: | |
| languages: csharp | |
| - name: ⚙ Install prerequisites | |
| run: | | |
| ./init.ps1 -UpgradePrerequisites -NoNuGetCredProvider | |
| dotnet --info | |
| shell: pwsh | |
| - name: 🛠 build | |
| run: dotnet pack --no-restore -c ${{ env.BUILDCONFIGURATION }} | |
| - name: 🔍 Perform CodeQL Analysis | |
| uses: github/codeql-action/analyze@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4.35.2 | |
| docs: | |
| name: 📃 Docs | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: 🔗 Markup Link Checker (mlc) | |
| uses: becheran/mlc@7ec24825cefe0c9c8c6bac48430e1f69e3ec356e # v1.2.0 | |
| with: | |
| args: --do-not-warn-for-redirect-to https://learn.microsoft.com*,https://dotnet.microsoft.com/*,https://dev.azure.com/*,https://app.codecov.io/* -p docfx -i https://www.npmjs.com/package/*,https://get.dot.net/,https://dev.azure.com/andrewarnott/OSS/* -i zcash:u1vv2ws6xhs72faugmlrasyeq298l05rrj6wfw8hr3r29y3czev5qt4ugp7kylz6suu04363ze92dfg8ftxf3237js0x9p5r82fgy47xkjnw75tqaevhfh0rnua72hurt22v3w3f7h8yt6mxaa0wpeeh9jcm359ww3rl6fj5ylqqv54uuwrs8q4gys9r3cxdm3yslsh3rt6p7wznzhky7 |