Repository navigation
380 lines (323 loc) · 12.3 KB
/
Copy pathtests.yml
File metadata and controls
380 lines (323 loc) · 12.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
name: Run Tests
on:
push:
branches:
- main
- master
- legacy/1.x
paths-ignore:
- '**/*.md'
- '**/*.txt'
- '.github/**'
- '**/.gitignore'
pull_request:
branches:
- main
- master
- legacy/1.x
paths-ignore:
- '**/*.md'
- '**/*.txt'
- '.github/**'
- '**/.gitignore'
defaults:
run:
shell: cmd
permissions:
contents: read
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
launcher-tests:
name: Launcher regression tests (${{ matrix.platform }})
runs-on: windows-latest
strategy:
matrix:
platform: [Win32, x64]
steps:
- uses: actions/checkout@v7
- uses: microsoft/setup-msbuild@v3
- name: Build launcher regression tests
run: msbuild launcher\tests\CmderLauncherTests.vcxproj /p:Configuration=Release /p:Platform=${{ matrix.platform }} /verbosity:minimal
- name: Run launcher regression tests
run: launcher\tests\bin\${{ matrix.platform }}\CmderLauncherTests.exe
tests:
runs-on: windows-latest
continue-on-error: false
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Check trailing whitespace
shell: pwsh
run: .\scripts\check-trailing-whitespace.ps1
- name: Test vendor update helper
shell: pwsh
run: .\scripts\test-update.ps1
- name: Test Git directory layouts
shell: pwsh
run: .\scripts\test-git-layout.ps1
- name: Test Git directory layouts on Windows PowerShell 5.1
shell: powershell
run: .\scripts\test-git-layout.ps1
- name: Test vendor release badge helpers
shell: pwsh
run: .\scripts\test-vendor-badges.ps1
- name: Test build helper argument and path safety
shell: pwsh
run: .\scripts\test-build-helpers.ps1
- name: Test build helpers on Windows PowerShell 5.1
shell: powershell
run: .\scripts\test-build-helpers.ps1
- name: Test TCC shell compatibility defaults
shell: pwsh
run: .\scripts\test-shell-detection.ps1
- name: Summary - Test execution started
shell: pwsh
env:
HEAD_REF: ${{ github.head_ref }}
run: |
# Get Cmder version
. scripts/utils.ps1
$cmderVersion = Get-VersionStr
$refName = "${{ github.ref_name }}"
$headRef = $env:HEAD_REF
$eventName = "${{ github.event_name }}"
$prNumber = $null
$actualBranchName = $refName
$branchLink = "https://github.com/${{ github.repository }}/tree/$refName"
$prLink = ""
$workflowLink = "https://github.com/${{ github.repository }}/blob/${{ github.sha }}/.github/workflows/tests.yml"
$runLink = "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
if ($refName -match '^(\d+)/(merge|head)$') {
$prNumber = $Matches[1]
# Use head_ref for the actual branch name if available
if ($headRef) {
$actualBranchName = $headRef
}
$branchLink = "https://github.com/${{ github.repository }}/tree/$actualBranchName"
$prLink = "https://github.com/${{ github.repository }}/pull/$prNumber"
} elseif ($eventName -eq "pull_request") {
# This is a pull request event
$prNumber = "${{ github.event.pull_request.number }}"
if ($headRef) {
$actualBranchName = $headRef
}
$branchLink = "https://github.com/${{ github.repository }}/tree/$actualBranchName"
$prLink = "https://github.com/${{ github.repository }}/pull/$prNumber"
}
$summary = @"
## ✅ Run Tests - Workflow Summary
### Test Environment
| Property | Value |
| --- | --- |
| Repository | [``${{ github.repository }}``](https://github.com/${{ github.repository }}) |
| Source Branch | [``$actualBranchName``]($branchLink) |
"@
if ($prNumber) {
$summary += "| Pull Request | [#$prNumber]($prLink) |`n"
}
$summary += @"
| Commit | [``${{ github.sha }}``](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) |
| Workflow | [``${{ github.workflow }}``]($workflowLink) |
| Run | [``${{ github.run_id }}``]($runLink) |
| Runner OS | ``${{ runner.os }}`` |
| Cmder Version | **$cmderVersion** |
| PowerShell Version | **$($PSVersionTable.PSVersion)** |
| Event | ``$eventName`` |
"@
$summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
- name: Initialize vendors
shell: pwsh
working-directory: scripts
run: .\build.ps1 -Verbose
- name: Summary - Vendor initialization
if: success()
shell: pwsh
run: |
# Get vendor versions from sources.json
$vendorInfo = @()
$sources = Get-Content "vendor\sources.json" -Raw | ConvertFrom-Json
foreach ($source in $sources) {
$dir = $source.name
if (-not $dir) {
continue
}
$versionFile = "vendor/$dir/.cmderver"
if (Test-Path $versionFile) {
$version = Get-Content $versionFile -Raw
$vendorInfo += "- **$dir**: $($version.Trim())"
}
}
$summary = @"
### ⚙️ Vendor Initialization
✅ Vendor dependencies initialized successfully.
**Vendor Versions:**
"@
$(
if ($vendorInfo.Count -eq 0) {
$summary += "_No vendor version information available._"
} else {
$summary += $vendorInfo -join "`n"
}
)
$summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
- name: Summary - Test results table header
if: success()
shell: pwsh
run: |
$summary = @"
### 📋 Test Results
| Test | Status | Duration |
| --- | --- | --- |
"@
$summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
- name: Testing Command Script Extensions
id: test-command-script-extensions
shell: pwsh
run: |
$startTime = Get-Date
$allowedBatFiles = @(
"Cmder.bat",
"vendor/init.bat"
)
$trackedBatFiles = @(git ls-files "*.bat")
$unexpectedBatFiles = @($trackedBatFiles | Where-Object { $allowedBatFiles -notcontains $_ })
if ($unexpectedBatFiles.Count -gt 0) {
$message = @(
"Unexpected tracked .bat files were found.",
"Use .cmd for command scripts unless the file is explicitly allowed.",
"",
($unexpectedBatFiles | ForEach-Object { "- $_" }) -join "`n"
) -join "`n"
throw $message
}
$duration = [math]::Round(((Get-Date) - $startTime).TotalSeconds, 2)
echo "duration=$duration" >> $env:GITHUB_OUTPUT
- name: Summary - Command script extension test
if: success()
shell: pwsh
run: |
$duration = "${{ steps.test-command-script-extensions.outputs.duration }}"
if ($duration) {
$duration = "$duration s"
} else {
$duration = "N/A"
}
"| Command Script Extensions | ✅ Passed | $duration |" | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
- name: Testing init.bat Compatibility Shim
id: test-init-bat-compatibility-shim
shell: pwsh
run: |
$startTime = Get-Date
$repoRoot = $PWD.Path
$initShim = Join-Path $PWD "vendor\init.bat"
$shimRoot = Join-Path $env:RUNNER_TEMP "cmder-init-shim"
if (-not (Test-Path $initShim)) {
throw "Expected tracked init.bat compatibility shim at '$initShim'."
}
try {
Remove-Item -Path $shimRoot -Recurse -Force -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Path $shimRoot | Out-Null
$shimContent = Get-Content -Path $initShim -Raw
if ($shimContent -notmatch "Please update your Cmder task or shell configuration" -or $shimContent -notmatch "call .*init\.cmd") {
throw "The tracked init.bat shim did not contain the expected notice and init.cmd call."
}
$shimOutput = cmd /d /c "set `"CMDER_ROOT=$repoRoot`"&& set `"cmder_root=$repoRoot`"&& set CMDER_USER_CONFIG=&& set CMDER_CONFIGURED=&& call vendor\init.bat /f /c `"$shimRoot`"" 2>&1
$shimOutputText = $shimOutput -join "`n"
if ($LASTEXITCODE -ne 0) {
throw "Generated init.bat shim exited with code $LASTEXITCODE.`n$shimOutputText"
}
if ($shimOutputText -notmatch "Please update your Cmder task or shell configuration" -or $shimOutputText -notmatch "init\.cmd") {
throw "Generated init.bat shim did not display the expected migration notice."
}
if (-not (Test-Path (Join-Path $shimRoot "config\user_init.cmd"))) {
throw "Tracked init.bat shim did not load init.cmd and create user_init.cmd."
}
} finally {
Remove-Item -Path $shimRoot -Recurse -Force -ErrorAction SilentlyContinue
}
$duration = [math]::Round(((Get-Date) - $startTime).TotalSeconds, 2)
echo "duration=$duration" >> $env:GITHUB_OUTPUT
- name: Summary - init.bat compatibility shim test
if: success()
shell: pwsh
run: |
$duration = "${{ steps.test-init-bat-compatibility-shim.outputs.duration }}"
if ($duration) {
$duration = "$duration s"
} else {
$duration = "N/A"
}
"| init.bat Compatibility Shim | ✅ Passed | $duration |" | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
- name: Testing Clink Shell
id: test-clink
shell: pwsh
run: |
$startTime = Get-Date
cmd /c vendor\init.cmd /v /d /t
$duration = [math]::Round(((Get-Date) - $startTime).TotalSeconds, 2)
echo "duration=$duration" >> $env:GITHUB_OUTPUT
- name: Summary - Clink Shell test
if: success()
shell: pwsh
run: |
$duration = "${{ steps.test-clink.outputs.duration }}"
if ($duration) {
$duration = "$duration s"
} else {
$duration = "N/A"
}
"| Clink Shell | ✅ Passed | $duration |" | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
- name: Testing PowerShell
id: test-powershell
shell: pwsh
run: |
$startTime = Get-Date
PowerShell.exe -ExecutionPolicy Bypass -NoLogo -NoProfile -Command "$env:CMDER_DEBUG='1'; . 'vendor\profile.ps1'"
$duration = [math]::Round(((Get-Date) - $startTime).TotalSeconds, 2)
echo "duration=$duration" >> $env:GITHUB_OUTPUT
- name: Summary - PowerShell test
if: success()
shell: pwsh
run: |
$duration = "${{ steps.test-powershell.outputs.duration }}"
if ($duration) {
$duration = "$duration s"
} else {
$duration = "N/A"
}
"| PowerShell | ✅ Passed | $duration |" | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
- name: Testing Bash
id: test-bash
shell: pwsh
run: |
$startTime = Get-Date
bash vendor/cmder.sh
$duration = [math]::Round(((Get-Date) - $startTime).TotalSeconds, 2)
echo "duration=$duration" >> $env:GITHUB_OUTPUT
- name: Summary - Bash test
if: success()
shell: pwsh
run: |
$duration = "${{ steps.test-bash.outputs.duration }}"
if ($duration) {
$duration = "$duration s"
} else {
$duration = "N/A"
}
"| Bash | ✅ Passed | $duration |" | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
- name: Summary - All tests completed
if: success()
shell: pwsh
run: |
$summary = @"
### ✅ All Tests Completed
All shell environments tested successfully!
**Test Coverage:**
- ✅ Clink shell environment (Windows cmd.exe with Clink)
- ✅ PowerShell environment (with Cmder profile)
- ✅ Bash environment (Git Bash integration)
"@
$summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8