Skip to content

Commit a677183

Browse files
committed
chore: require PowerShell 7 for repository tools
1 parent b5562eb commit a677183

8 files changed

Lines changed: 212 additions & 117 deletions

File tree

‎docs/development.md‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Go 1.26 or later
88
- Git
9+
- PowerShell 7 or later for repository scripts
910
- `github.com/akavel/rsrc` only when regenerating Windows resources
1011

1112
IdleTrigger targets Windows 10 / Windows Server 2016 and later. The repository produces both `windows/amd64` and `windows/386` binaries.
@@ -35,15 +36,24 @@ go build -trimpath "-ldflags=$ldflags" -o $output ./cmd/idletrigger
3536

3637
## Verify
3738

38-
Run the standard local checks in Windows PowerShell 5.1 or later:
39+
Run the standard local checks in PowerShell 7 or later:
3940

4041
```powershell
4142
.\tools\check.ps1
4243
```
4344

44-
The check script covers normal, `devtools`, and `tools` build-tag variants.
45-
`golangci-lint` is run when installed; otherwise the script prints `SKIPPED`.
46-
Run the optional vulnerability scan while online:
45+
The default command is the quick development check: module verification,
46+
formatting, working-tree whitespace, the short test suite, normal vet, and
47+
dependency boundaries. Native Win32 integration and resource-cycle tests stay
48+
in the full suite. Before a release or broad change, run the full build-tag
49+
matrix and `golangci-lint` (when installed):
50+
51+
```powershell
52+
.\tools\check.ps1 -Full
53+
```
54+
55+
Run the optional vulnerability scan while online; it can be combined with
56+
`-Full`:
4757

4858
```powershell
4959
.\tools\check.ps1 -Vulncheck

‎docs/development.zh-CN.md‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Go 1.26 或更高版本
88
- Git
9+
- 仓库脚本要求 PowerShell 7 或更高版本
910
- 仅重新生成 Windows 资源时需要 `github.com/akavel/rsrc`
1011

1112
IdleTrigger 面向 Windows 10 / Windows Server 2016 及以上系统,仓库同时产出 `windows/amd64` 和 `windows/386`。
@@ -35,15 +36,22 @@ go build -trimpath "-ldflags=$ldflags" -o $output ./cmd/idletrigger
3536

3637
## 验证
3738

38-
在 Windows PowerShell 5.1 或更高版本中执行本地标准检查:
39+
在 PowerShell 7 或更高版本中执行本地标准检查:
3940

4041
```powershell
4142
.\tools\check.ps1
4243
```
4344

44-
检查脚本会覆盖普通、`devtools` 和 `tools` 三种构建标签组合。已安装
45-
`golangci-lint` 时脚本会执行它;未安装时会明确打印 `SKIPPED`。
46-
联网时可执行可选漏洞扫描:
45+
默认命令执行适合日常开发的轻量检查:模块校验、格式、工作区空白错误、短测试集、
46+
普通 vet 和依赖边界。真实 Win32 集成及资源循环测试保留在完整模式中。发布前或较大
47+
范围改动后,使用完整模式覆盖 `devtools`、`tools` 构建标签,并在已安装时执行
48+
`golangci-lint`:
49+
50+
```powershell
51+
.\tools\check.ps1 -Full
52+
```
53+
54+
联网时可执行可选漏洞扫描;该参数可与 `-Full` 组合使用:
4755

4856
```powershell
4957
.\tools\check.ps1 -Vulncheck

‎docs/roadmap.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 发布检查清单
44

5-
- [ ] `.\tools\check.ps1` 核心检查通过,并确认 `SKIPPED` / `NOT RUN` 项符合本次发布预期
5+
- [ ] `.\tools\check.ps1 -Full -Vulncheck` 完整检查通过,并确认 `SKIPPED` 项符合本次发布预期
66
- [ ] 386 / amd64 Windows GUI 构建通过
77
- [ ] 两种架构 EXE 均包含应用图标和 manifest
88
- [ ] CLI、控制面板、自动任务/进程选择器、IPC、热键和两类预警做一次人工冒烟测试

‎internal/ui/automationpanel/automationpanel_test.go‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,15 @@ func TestRuleSummaryIncludesEffectiveDays(t *testing.T) {
8585
}
8686
}
8787

88+
func requireNativeIntegration(t *testing.T) {
89+
t.Helper()
90+
if testing.Short() {
91+
t.Skip("skipping native Win32 integration test in short mode")
92+
}
93+
}
94+
8895
func TestProcessTooltipBufferRemainsBoundedAcrossRefreshes(t *testing.T) {
96+
requireNativeIntegration(t)
8997
err := Capture(State{}, func(key string) string { return key }, 1, false, true, func(hwnd windows.Handle) error {
9098
p := activePanelForTest(t, hwnd)
9199
p.draft.Processes = []automation.ProcessTarget{{Match: automation.MatchName, Executable: "player.exe"}}
@@ -143,6 +151,7 @@ func TestEditorKeepsDraftBaseWhenExternalStateArrives(t *testing.T) {
143151
}
144152

145153
func TestAutomationWindowsRemainOperableAcrossDPIAndSmallWorkArea(t *testing.T) {
154+
requireNativeIntegration(t)
146155
work := nativeform.Rect{Right: 1366, Bottom: 768}
147156
for _, scale := range []float64{1, 1.25, 1.5, 2} {
148157
for _, editor := range []bool{false, true} {
@@ -195,6 +204,7 @@ func TestManagerLayoutFitsCICompactViewport(t *testing.T) {
195204
}
196205

197206
func TestAutomationWindowsApplySuggestedRectAcrossDPIChanges(t *testing.T) {
207+
requireNativeIntegration(t)
198208
for _, editor := range []bool{false, true} {
199209
t.Run(map[bool]string{false: "manager", true: "editor"}[editor], func(t *testing.T) {
200210
err := Capture(State{}, func(key string) string { return key }, 1, false, editor, func(hwnd windows.Handle) error {
@@ -231,6 +241,7 @@ func TestAutomationWindowsApplySuggestedRectAcrossDPIChanges(t *testing.T) {
231241
}
232242

233243
func TestAutomationWindowsReleaseResourcesAcrossRepresentativeCycles(t *testing.T) {
244+
requireNativeIntegration(t)
234245
const (
235246
stabilizationCycles = 8
236247
measuredCycles = 8

‎internal/ui/processpicker/processpicker_test.go‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,15 @@ func TestSelectionLimitRejectsOnlyTheAdditionalTarget(t *testing.T) {
195195
}
196196
}
197197

198+
func requireNativeIntegration(t *testing.T) {
199+
t.Helper()
200+
if testing.Short() {
201+
t.Skip("skipping native Win32 integration test in short mode")
202+
}
203+
}
204+
198205
func TestProcessPickerRemainsOperableAcrossDPIAndSmallWorkArea(t *testing.T) {
206+
requireNativeIntegration(t)
199207
work := nativeform.Rect{Right: 1366, Bottom: 768}
200208
groups := []processcatalog.Group{{Executable: "player.exe", Description: "Media Player", Count: 2}}
201209
for _, scale := range []float64{1, 1.25, 1.5, 2} {
@@ -224,6 +232,7 @@ func TestProcessPickerRemainsOperableAcrossDPIAndSmallWorkArea(t *testing.T) {
224232
}
225233

226234
func TestProcessPickerAppliesSuggestedRectAcrossDPIChanges(t *testing.T) {
235+
requireNativeIntegration(t)
227236
err := Capture(testPickerOptions(), nil, 1, false, func(hwnd windows.Handle) error {
228237
p := activePickerForTest(t, hwnd)
229238
p.captureScale = 0
@@ -253,6 +262,7 @@ func TestProcessPickerAppliesSuggestedRectAcrossDPIChanges(t *testing.T) {
253262
}
254263

255264
func TestProcessPickerReleasesResourcesAcrossRepresentativeCycles(t *testing.T) {
265+
requireNativeIntegration(t)
256266
const (
257267
stabilizationCycles = 8
258268
measuredCycles = 8
@@ -287,6 +297,7 @@ func TestProcessPickerReleasesResourcesAcrossRepresentativeCycles(t *testing.T)
287297
}
288298

289299
func TestProcessPickerCreationFailuresReleasePartialResources(t *testing.T) {
300+
requireNativeIntegration(t)
290301
if err := Capture(testPickerOptions(), nil, 1, false, nil); err != nil {
291302
t.Fatal(err)
292303
}
@@ -400,6 +411,7 @@ func TestProcessPickerCreationFailuresReleasePartialResources(t *testing.T) {
400411
}
401412

402413
func TestProcessPickerIgnoresCallbacksThatArriveAfterClose(t *testing.T) {
414+
requireNativeIntegration(t)
403415
runtime.LockOSThread()
404416
defer runtime.UnlockOSThread()
405417
originalSnapshot := snapshotNamesForPicker

‎tools/capture-screenshots.ps1‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#requires -Version 7.0
2+
13
[CmdletBinding()]
24
param(
35
[ValidateSet('Readme', 'Review')]
@@ -6,12 +8,15 @@ param(
68
)
79

810
$ErrorActionPreference = 'Stop'
11+
$PSNativeCommandUseErrorActionPreference = $false
12+
Set-StrictMode -Version Latest
913
$repoRoot = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
1014
if ([string]::IsNullOrWhiteSpace($OutputDirectory)) {
1115
$OutputDirectory = if ($CaptureSet -eq 'Readme') { Join-Path $repoRoot 'docs\images' } else { Join-Path $repoRoot 'dist\ui-review' }
1216
}
1317
$outputDirectory = [IO.Path]::GetFullPath($OutputDirectory)
1418
$temporaryDirectory = Join-Path (Join-Path $repoRoot 'dist') ('.screenshot-build-' + $PID)
19+
$captureDirectory = Join-Path $temporaryDirectory 'captured'
1520
$exePath = Join-Path $temporaryDirectory 'IdleTrigger-screenshot.exe'
1621
$files = if ($CaptureSet -eq 'Readme') {
1722
@('panel-en-light.png', 'panel-en-dark.png', 'panel-zh-light.png', 'panel-zh-dark.png')
@@ -24,6 +29,11 @@ $files = if ($CaptureSet -eq 'Readme') {
2429
}
2530
}
2631
}
32+
$previousEnvironment = @{
33+
CGO_ENABLED = [Environment]::GetEnvironmentVariable('CGO_ENABLED', 'Process')
34+
GOARCH = [Environment]::GetEnvironmentVariable('GOARCH', 'Process')
35+
GOCACHE = [Environment]::GetEnvironmentVariable('GOCACHE', 'Process')
36+
}
2737

2838
function Get-PngSize([string]$Path) {
2939
$bytes = [IO.File]::ReadAllBytes($Path)
@@ -46,14 +56,14 @@ try {
4656
go build -tags devtools -trimpath -ldflags '-s -w -H windowsgui -X github.com/JeffioZ/idletrigger/internal/version.Value=screenshot' -o $exePath ./cmd/idletrigger
4757
if ($LASTEXITCODE -ne 0) { throw "go build failed with exit code $LASTEXITCODE" }
4858
$setFlag = if ($CaptureSet -eq 'Readme') { '--readme-set' } else { '--review-set' }
49-
$arguments = @('screenshot', $setFlag, '--output', ('"' + $outputDirectory + '"'))
59+
$arguments = @('screenshot', $setFlag, '--output', ('"' + $captureDirectory + '"'))
5060
$process = Start-Process -FilePath $exePath -ArgumentList $arguments -WindowStyle Hidden -Wait -PassThru
5161
if ($process.ExitCode -ne 0) { throw "screenshot command failed with exit code $($process.ExitCode)" }
5262
} finally { Pop-Location }
5363

5464
$sizes = @{}
5565
foreach ($name in $files) {
56-
$path = Join-Path $outputDirectory $name
66+
$path = Join-Path $captureDirectory $name
5767
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) { throw "Missing screenshot: $path" }
5868
$size = Get-PngSize $path
5969
$sizes[$name] = $size
@@ -71,7 +81,16 @@ try {
7181
}
7282
}
7383
}
84+
85+
New-Item -ItemType Directory -Force -Path $outputDirectory | Out-Null
86+
foreach ($name in $files) {
87+
Copy-Item -LiteralPath (Join-Path $captureDirectory $name) -Destination (Join-Path $outputDirectory $name) -Force
88+
}
7489
} finally {
90+
foreach ($name in $previousEnvironment.Keys) {
91+
[Environment]::SetEnvironmentVariable($name, $previousEnvironment[$name], 'Process')
92+
}
93+
7594
# Windows may briefly retain a handle to a just-exited GUI executable.
7695
# Clean synchronously so the script never leaves a detached cleanup
7796
# process behind.

0 commit comments

Comments
 (0)