Skip to content

Commit d72dc55

Browse files
ci(git-cross-os-benchmark): refactor step summary generation to use array syntax
Replace repetitive Add-Content calls with PowerShell array syntax for improved readability and maintainability. Changes: - Use array syntax with pipeline to Add-Content for step summaries - Add null/empty check for benchmark outcome before display - Extract trigger name to variable for conditional README refresh status Co-Authored-By: Hagicode <noreply@hagicode.com> Signed-off-by: newbe36524 <newbe36524@qq.com>
1 parent 7411758 commit d72dc55

1 file changed

Lines changed: 26 additions & 13 deletions

File tree

.github/workflows/git-cross-os-benchmark.yml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,21 @@ jobs:
103103
- name: Publish per-runner step summary
104104
if: always()
105105
run: |
106-
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "## ${{ matrix.os }}"
107-
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value ""
108-
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "- Compatibility stage: `${{ steps.compatibility.outcome }}`"
109-
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "- Benchmark stage: `${{ steps.benchmark_run.outcome || 'skipped' }}`"
110-
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "- Compatibility artifacts: `${{ steps.paths.outputs.compat_dir }}`"
111-
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "- Benchmark artifacts: `${{ steps.paths.outputs.benchmark_dir }}`"
112-
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value ""
106+
$compatibilityOutcome = "${{ steps.compatibility.outcome }}"
107+
$benchmarkOutcome = "${{ steps.benchmark_run.outcome }}"
108+
if ([string]::IsNullOrWhiteSpace($benchmarkOutcome)) {
109+
$benchmarkOutcome = "skipped"
110+
}
111+
112+
@(
113+
"## ${{ matrix.os }}",
114+
"",
115+
"- Compatibility stage: $compatibilityOutcome",
116+
"- Benchmark stage: $benchmarkOutcome",
117+
"- Compatibility artifacts: ${{ steps.paths.outputs.compat_dir }}",
118+
"- Benchmark artifacts: ${{ steps.paths.outputs.benchmark_dir }}",
119+
""
120+
) | Add-Content -Path $env:GITHUB_STEP_SUMMARY
113121
114122
$compatReport = Join-Path "${{ steps.paths.outputs.compat_dir }}" "compatibility-report.md"
115123
if (Test-Path $compatReport) {
@@ -206,12 +214,17 @@ jobs:
206214
if: always()
207215
run: |
208216
$summaryPath = Join-Path "${{ steps.aggregate.outputs.aggregate_dir }}" "latest-manual-run-summary.md"
209-
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "# Git Cross-OS Benchmark Summary"
210-
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value ""
211-
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "- Trigger: `${{ github.event_name }}`"
212-
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "- README refresh: `$(if ("${{ github.event_name }}" -eq "workflow_dispatch") { "updated in workspace artifact" } else { "skipped" })`"
213-
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "- Aggregate artifacts: `${{ steps.aggregate.outputs.aggregate_dir }}`"
214-
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value ""
217+
$eventName = "${{ github.event_name }}"
218+
$readmeRefreshStatus = if ($eventName -eq "workflow_dispatch") { "updated in workspace artifact" } else { "skipped" }
219+
220+
@(
221+
"# Git Cross-OS Benchmark Summary",
222+
"",
223+
"- Trigger: $eventName",
224+
"- README refresh: $readmeRefreshStatus",
225+
"- Aggregate artifacts: ${{ steps.aggregate.outputs.aggregate_dir }}",
226+
""
227+
) | Add-Content -Path $env:GITHUB_STEP_SUMMARY
215228
216229
if (Test-Path $summaryPath) {
217230
Get-Content $summaryPath | Add-Content -Path $env:GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)