Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,29 @@ pytest を実行します。
py -m pytest
```

## 半自動チェック

開発中の基本確認をまとめて実行します。

```powershell
.\scripts\dev_check.ps1
```

PR作成前の確認をまとめて表示します。

```powershell
.\scripts\git_preflight.ps1
```

PR本文テンプレートを表示、またはファイルへ保存します。

```powershell
.\scripts\pr_body.ps1
.\scripts\pr_body.ps1 -OutputPath pr_body.md
```

これらのスクリプトは実機通信、`real_device_check.py`、`git push`、PR作成、mergeを自動実行しません。

## mock TCPサーバーの使い方

UTRリーダライタ実機の代わりに、localhost 上で mock TCPサーバーを起動できます。
Expand Down
22 changes: 22 additions & 0 deletions prompts/pr_body_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Summary

-

## Test

- [ ] `.\scripts\dev_check.ps1`
- [ ] pytest completed
- [ ] blocked text scan completed
- [ ] `logs/real_device/` ignore check completed

## Safety

- [ ] No real device communication
- [ ] `real_device_check.py` not executed
- [ ] `logs/real_device/` is excluded from Git
- [ ] `git push` not executed
- [ ] PR creation and merge are manual

## Notes

-
66 changes: 66 additions & 0 deletions scripts/git_preflight.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
$failed = $false

function Invoke-Check {
param(
[Parameter(Mandatory = $true)]
[string]$Title,

[Parameter(Mandatory = $true)]
[scriptblock]$Command
)

Write-Host ""
Write-Host "== $Title =="

try {
$global:LASTEXITCODE = 0
& $Command
if ($LASTEXITCODE -ne 0) {
throw "Exit code $LASTEXITCODE"
}
}
catch {
Write-Host "ERROR: $Title failed: $_" -ForegroundColor Red
$script:failed = $true
}
}

Push-Location $repoRoot
try {
Invoke-Check "current branch" {
git branch --show-current
}

Invoke-Check "git status --short" {
git status --short
}

Invoke-Check "git diff --stat" {
git diff --stat
}

Invoke-Check "git log --oneline --decorate -5" {
git log --oneline --decorate -5
}

$devCheckScript = Join-Path $PSScriptRoot "dev_check.ps1"
Invoke-Check "dev_check.ps1" {
& $devCheckScript
}
}
finally {
Pop-Location
}

if ($failed) {
Write-Host "ERROR: git_preflight failed." -ForegroundColor Red
exit 1
}

Write-Host ""
Write-Host "git_preflight passed."
exit 0
46 changes: 46 additions & 0 deletions scripts/pr_body.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
param(
[string]$OutputPath
)

Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

$body = @'
## Summary

-

## Test

- [ ] `.\scripts\dev_check.ps1`
- [ ] pytest completed
- [ ] blocked text scan completed
- [ ] `logs/real_device/` ignore check completed

## Safety

- [ ] No real device communication
- [ ] `real_device_check.py` not executed
- [ ] `logs/real_device/` is excluded from Git
- [ ] `git push` not executed
- [ ] PR creation and merge are manual

## Notes

-
'@

if ($OutputPath) {
$parent = Split-Path -Parent $OutputPath
if ($parent -and -not (Test-Path -LiteralPath $parent)) {
Write-Error "Output directory does not exist: $parent"
exit 1
}

Set-Content -LiteralPath $OutputPath -Value $body -Encoding UTF8
Write-Host "PR body template written to: $OutputPath"
exit 0
}

Write-Output $body
exit 0
Loading