@@ -19,46 +19,56 @@ concurrency:
1919permissions : read-all
2020
2121jobs :
22- test :
23- runs-on : ${{ matrix.os }}
24- continue-on-error : false
25- strategy :
26- fail-fast : false
27- matrix :
28- os : ['ubuntu-latest', 'macos-latest', 'windows-latest']
29- ruby-version : ['3.3', '3.2', '3.1', '3.0', '2.7']
30- name : Ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}
31- steps :
32- - uses : actions/checkout@v5
33- - name : Set up Ruby
34- uses : ruby/setup-ruby@v1
35- with :
36- ruby-version : ${{ matrix.ruby-version }}
37- rubygems : latest
38- - name : Install addons
39- if : ${{ matrix.os == 'ubuntu-latest' }}
40- run : sudo apt-get install libgmp3-dev libcap-ng-dev
41- - name : Install dependencies
42- run : bundle install
43- - name : Run tests
44- run : bundle exec rake test TESTOPTS="-v --report-slow-tests --no-show-detail-immediately"
45-
46- test-windows-service :
22+ repeat-test :
4723 runs-on : windows-latest
48- strategy :
49- fail-fast : false
50- matrix :
51- ruby-version : ['3.3', '3.2', '3.1', '3.0', '2.7']
52- name : Windows service (Ruby ${{ matrix.ruby-version }})
24+
5325 steps :
54- - uses : actions/checkout@v5
55- - name : Set up Ruby
56- uses : ruby/setup-ruby@v1
57- with :
58- ruby-version : ${{ matrix.ruby-version }}
59- - name : Install dependencies
60- run : |
61- bundle install
62- rake install
63- - name : Run tests
64- run : test\scripts\windows_service_test.ps1
26+ - name : Checkout
27+ uses : actions/checkout@v4
28+
29+ - name : Set up Ruby
30+ uses : ruby/setup-ruby@v1
31+ with :
32+ ruby-version : ' 3.2' # プロジェクトに合わせて変更してください
33+ bundler-cache : true # bundle install を高速化
34+
35+ - name : Run tests repeatedly
36+ shell : powershell
37+ run : |
38+ # --- 設定 ---
39+ $command = 'bundle exec ruby -I"lib;test" test\plugin\test_out_forward.rb -v -n "test: Node with security is thread-safe on multi threads"'
40+ $ignorePattern = "RuntimeError: can't find unused port"
41+ $maxRetries = 1000
42+ # -----------
43+
44+ for ($i=1; $i -le $maxRetries; $i++) {
45+ Write-Host "`n=== Run: $i / $maxRetries ===" -ForegroundColor Cyan
46+
47+ # 時間計測開始
48+ $sw = [System.Diagnostics.Stopwatch]::StartNew()
49+
50+ # コマンド実行 (ログを変数に格納しつつ、標準出力とエラー出力をマージ)
51+ $output = Invoke-Expression "$command 2>&1" | Out-String
52+
53+ # 時間計測終了
54+ $sw.Stop()
55+ $duration = "{0:N2}" -f $sw.Elapsed.TotalSeconds
56+ Write-Host "Duration: ${duration} sec" -ForegroundColor Gray
57+
58+ # 判定ロジック
59+ if ($LASTEXITCODE -eq 0) {
60+ Write-Host "Result: Success" -ForegroundColor Green
61+ } else {
62+ # 特定のエラーメッセージが含まれているかチェック
63+ if ($output -match $ignorePattern) {
64+ Write-Host "Result: Port error detected (Ignored)" -ForegroundColor Yellow
65+ # 念のためログを出力して確認できるようにする
66+ Write-Host $output
67+ } else {
68+ Write-Host "Result: Unexpected Failure! Stopping." -ForegroundColor Red
69+ Write-Host $output # 失敗時のログを全表示
70+ exit 1 # アクションを失敗させる
71+ }
72+ }
73+ }
74+ Write-Host "`nAll runs completed." -ForegroundColor Green
0 commit comments