Skip to content

Commit 672a876

Browse files
committed
fix: ci & doc: optimize repr
1 parent 4f68535 commit 672a876

File tree

9 files changed

+57
-54
lines changed

9 files changed

+57
-54
lines changed

.github/workflows/lib_run.yml

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
real_run:
2222
name: Run on ${{ matrix.os }}
2323
runs-on: ${{ matrix.os }}
24-
timeout-minutes: 2
24+
timeout-minutes: ${{ matrix.os == 'windows-latest' && 10 || 2 }}
2525
strategy:
2626
matrix:
2727
os: [ubuntu-latest, windows-latest, macos-latest]
@@ -39,16 +39,22 @@ jobs:
3939
fetch-depth: ${{ inputs.fetch-depth }}
4040
submodules: ${{ inputs.submodules }}
4141

42-
- name: Prepare Necessary Runtime Files
42+
- name: Prepare and Build
43+
shell: bash
4344
run: |
4445
go generate main.go
4546
go mod tidy
47+
if [[ "$RUNNER_OS" == "Windows" ]]; then
48+
go build -o testbin.exe .
49+
else
50+
go build -o testbin .
51+
fi
4652
4753
- name: Run the Program (Unix)
4854
if: runner.os != 'Windows'
4955
shell: bash
5056
run: |
51-
go run main.go > output.log 2>&1 &
57+
./testbin > output.log 2>&1 &
5258
PID=$!
5359
FOUND=false
5460
for i in $(seq 1 60); do
@@ -76,23 +82,44 @@ jobs:
7682
if: runner.os == 'Windows'
7783
shell: pwsh
7884
run: |
79-
$proc = Start-Process -FilePath "go" -ArgumentList "run", "main.go" -NoNewWindow -PassThru -RedirectStandardOutput "stdout.log" -RedirectStandardError "stderr.log"
85+
$logFile = Join-Path $PWD "output.log"
86+
$env:DEBUG_MODE = "1"
87+
$proc = Start-Process -FilePath ".\testbin.exe" -NoNewWindow -PassThru -RedirectStandardOutput "$logFile" -RedirectStandardError (Join-Path $PWD "stderr.log")
8088
$found = $false
8189
for ($i = 0; $i -lt 60; $i++) {
8290
Start-Sleep -Seconds 1
83-
$content = ""
84-
if (Test-Path "stdout.log") { $content += Get-Content "stdout.log" -Raw -ErrorAction SilentlyContinue }
85-
if (Test-Path "stderr.log") { $content += Get-Content "stderr.log" -Raw -ErrorAction SilentlyContinue }
86-
if ($content -match '\[ws\] 连接到Websocket服务器') {
87-
$found = $true
88-
break
89-
}
91+
try {
92+
$content = ""
93+
foreach ($f in @($logFile, (Join-Path $PWD "stderr.log"))) {
94+
if (Test-Path $f) {
95+
$fs = [System.IO.FileStream]::new($f, [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::ReadWrite)
96+
$sr = [System.IO.StreamReader]::new($fs)
97+
$content += $sr.ReadToEnd()
98+
$sr.Close()
99+
$fs.Close()
100+
}
101+
}
102+
if ($content -match '\[ws\] 连接到Websocket服务器') {
103+
$found = $true
104+
break
105+
}
106+
} catch {}
90107
}
91-
taskkill /F /T /PID $proc.Id 2>$null
108+
try { Stop-Process -Id $proc.Id -Force -ErrorAction SilentlyContinue } catch {}
109+
try { taskkill /F /T /PID $proc.Id 2>$null } catch {}
92110
Write-Host ""
93111
Write-Host "Run log:"
94-
if (Test-Path "stdout.log") { Get-Content "stdout.log" }
95-
if (Test-Path "stderr.log") { Get-Content "stderr.log" }
112+
foreach ($f in @($logFile, (Join-Path $PWD "stderr.log"))) {
113+
if (Test-Path $f) {
114+
try {
115+
$fs = [System.IO.FileStream]::new($f, [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::ReadWrite)
116+
$sr = [System.IO.StreamReader]::new($fs)
117+
Write-Host $sr.ReadToEnd()
118+
$sr.Close()
119+
$fs.Close()
120+
} catch {}
121+
}
122+
}
96123
Write-Host ""
97124
if ($found) {
98125
Write-Host "Success: Found target output"

.github/workflows/push.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ name: PushLint
22
on:
33
push:
44
branches:
5-
- master
5+
- main
66
tags:
77
- 'v*'
88
jobs:
99
golangci:
1010
uses: ./.github/workflows/lib_lint.yml
1111
with:
12-
ref: master
12+
ref: main
1313
commit_back: true
1414

1515
runmain:
1616
needs: golangci
1717
if: ${{ !contains(github.event.pull_request.title, '.go') }}
1818
uses: ./.github/workflows/lib_run.yml
1919
with:
20-
ref: master
20+
ref: main

.github/workflows/release.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

README-en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ZeroBot-Plugin-Playground
2-
English | [简体中文](https://github.com/FloatTech/ZeroBot-Plugin-Playground/blob/main/README.md)
2+
English | [简体中文](README.md)
33

44
Welcome~ Here are our playground to test and modify plugins written on Zerobot Framework.
55

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ZeroBot-Plugin-Playground
2-
[English](https://github.com/FloatTech/ZeroBot-Plugin-Playground/blob/main/README-en.md) | 简体中文
2+
[English](README-en.md) | 简体中文
33

44
快来这里上传你的奇思妙想吧!好的想法将会被合并入主仓库哦~
55

@@ -21,7 +21,7 @@
2121

2222
目前提供的样板有 example 中的
2323

24-
- [江林版本](https://github.com/FloatTech/ZeroBot-Plugin-Playground/blob/main/example/JiangRed/message.go)
25-
- [小锅饭版本](https://github.com/FloatTech/ZeroBot-Plugin-Playground/blob/main/example/xiaoguofan/example.go)
24+
- [江林版本](example/JiangRed/message.go)
25+
- [小锅饭版本](example/xiaoguofan/example.go)
2626
- [小锅饭的ZerobotCourse](https://github.com/guohuiyuan/ZerobotCourse)
27-
- [夹子的版本(半成品)](https://github.com/FloatTech/ZeroBot-Plugin-Playground/tree/main/tutorial)
27+
- [夹子的版本(半成品)](doc)

abineundo/console_windows.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ func init() {
7171
stdout := windows.Handle(os.Stdout.Fd())
7272
err = windows.GetConsoleMode(stdout, &mode)
7373
if err != nil {
74+
if debugMode {
75+
logrus.Warnf("调试模式下忽略控制台模式获取失败: %v", err)
76+
logrus.SetFormatter(&logFormat{hasColor: false})
77+
return
78+
}
7479
panic(err)
7580
}
7681

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
这边咱就教你如何使用并且编写自己想要的插件呢~
1212

13-
- [**ep1: Hey ya~ Hello World~**](https://github.com/FloatTech/ZeroBot-Plugin-Playground/blob/main/tutorial/zero.md)
13+
- [**ep1: Hey ya~ Hello World~**](doc/zero.md)
1414

15-
- [**ep2:浅尝辄止~尝试做一个好看的拼盘吧w**](https://github.com/FloatTech/ZeroBot-Plugin-Playground/blob/main/tutorial/first.md)
15+
- [**ep2:浅尝辄止~尝试做一个好看的拼盘吧w**](doc/first.md)
1616

1717
## 既然有了一个想法~那么我们应该整点小工具去做这些工作
1818

@@ -39,5 +39,5 @@
3939
## 引用
4040

4141
- [ZerobotCourse](https://github.com/guohuiyuan/ZerobotCourse)
42-
- [example/JiangRed](https://github.com/FloatTech/ZeroBot-Plugin-Playground/blob/main/example/JiangRed/message.go)
42+
- [example/JiangRed](example/JiangRed/message.go)
4343
- [khl.py](https://github.com/TWT233/khl.py)
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)