Skip to content

Commit 4f68535

Browse files
committed
feat: import latest changes from main repo
1 parent b1df852 commit 4f68535

File tree

46 files changed

+792
-363
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+792
-363
lines changed

.github/workflows/lib_lint.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Lint Library
2+
on:
3+
workflow_call:
4+
inputs:
5+
commit_back:
6+
required: true
7+
type: boolean
8+
ref:
9+
required: true
10+
type: string
11+
go-version:
12+
required: false
13+
type: string
14+
default: '^1.25'
15+
fetch-depth:
16+
required: false
17+
type: number
18+
default: 0
19+
submodules:
20+
required: false
21+
type: string
22+
default: 'recursive'
23+
jobs:
24+
golangci:
25+
name: Run Lint
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Set up Go
29+
uses: actions/setup-go@master
30+
with:
31+
go-version: "${{ inputs.go-version }}"
32+
33+
- name: Check out code into the Go module directory
34+
uses: actions/checkout@master
35+
with:
36+
ref: ${{ inputs.ref }}
37+
fetch-depth: ${{ inputs.fetch-depth }}
38+
submodules: ${{ inputs.submodules }}
39+
40+
- name: Prepare Necessary Runtime Files
41+
run: |
42+
go generate main.go
43+
go mod tidy
44+
45+
- name: Run Lint
46+
uses: golangci/golangci-lint-action@master
47+
with:
48+
version: latest
49+
50+
- name: Commit back
51+
if: ${{ inputs.commit_back }}
52+
continue-on-error: true
53+
run: |
54+
git config --local user.name 'github-actions[bot]'
55+
git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com'
56+
git add --all
57+
git commit -m "chore(lint): 改进代码样式"
58+
59+
- name: Create Pull Request
60+
if: ${{ inputs.commit_back }}
61+
continue-on-error: true
62+
uses: peter-evans/create-pull-request@v8
63+
with:
64+
title: "chore(lint): 改进代码样式"

.github/workflows/lib_run.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Run Library
2+
on:
3+
workflow_call:
4+
inputs:
5+
ref:
6+
required: true
7+
type: string
8+
go-version:
9+
required: false
10+
type: string
11+
default: '^1.25'
12+
fetch-depth:
13+
required: false
14+
type: number
15+
default: 0
16+
submodules:
17+
required: false
18+
type: string
19+
default: 'recursive'
20+
jobs:
21+
real_run:
22+
name: Run on ${{ matrix.os }}
23+
runs-on: ${{ matrix.os }}
24+
timeout-minutes: 2
25+
strategy:
26+
matrix:
27+
os: [ubuntu-latest, windows-latest, macos-latest]
28+
fail-fast: true
29+
steps:
30+
- name: Set up Go
31+
uses: actions/setup-go@master
32+
with:
33+
go-version: "${{ inputs.go-version }}"
34+
35+
- name: Check out code into the Go module directory
36+
uses: actions/checkout@master
37+
with:
38+
ref: ${{ inputs.ref }}
39+
fetch-depth: ${{ inputs.fetch-depth }}
40+
submodules: ${{ inputs.submodules }}
41+
42+
- name: Prepare Necessary Runtime Files
43+
run: |
44+
go generate main.go
45+
go mod tidy
46+
47+
- name: Run the Program (Unix)
48+
if: runner.os != 'Windows'
49+
shell: bash
50+
run: |
51+
go run main.go > output.log 2>&1 &
52+
PID=$!
53+
FOUND=false
54+
for i in $(seq 1 60); do
55+
if grep -q '\[ws\] 连接到Websocket服务器' output.log 2>/dev/null; then
56+
FOUND=true
57+
break
58+
fi
59+
sleep 1
60+
done
61+
kill $PID 2>/dev/null || true
62+
wait $PID 2>/dev/null || true
63+
echo ""
64+
echo "Run log:"
65+
cat output.log
66+
echo ""
67+
if [ "$FOUND" = true ]; then
68+
echo "Success: Found target output"
69+
exit 0
70+
else
71+
echo "Failure: Timeout after 60s without finding target output"
72+
exit 1
73+
fi
74+
75+
- name: Run the Program (Windows)
76+
if: runner.os == 'Windows'
77+
shell: pwsh
78+
run: |
79+
$proc = Start-Process -FilePath "go" -ArgumentList "run", "main.go" -NoNewWindow -PassThru -RedirectStandardOutput "stdout.log" -RedirectStandardError "stderr.log"
80+
$found = $false
81+
for ($i = 0; $i -lt 60; $i++) {
82+
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+
}
90+
}
91+
taskkill /F /T /PID $proc.Id 2>$null
92+
Write-Host ""
93+
Write-Host "Run log:"
94+
if (Test-Path "stdout.log") { Get-Content "stdout.log" }
95+
if (Test-Path "stderr.log") { Get-Content "stderr.log" }
96+
Write-Host ""
97+
if ($found) {
98+
Write-Host "Success: Found target output"
99+
exit 0
100+
} else {
101+
Write-Host "Failure: Timeout after 60s without finding target output"
102+
exit 1
103+
}

.github/workflows/nightly.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: 最新版
22

3-
on: [push, pull_request]
3+
on:
4+
workflow_run:
5+
workflows: [PushLint, PullLint]
6+
types:
7+
- completed
48

59
env:
610
BINARY_PREFIX: "zbppg_"
@@ -12,6 +16,7 @@ jobs:
1216
build:
1317
name: Build binary CI
1418
runs-on: ubuntu-latest
19+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1520
strategy:
1621
matrix:
1722
# build and publish in parallel: linux/386, linux/amd64, windows/386, windows/amd64, darwin/amd64, darwin/arm64
@@ -27,10 +32,12 @@ jobs:
2732
fail-fast: true
2833
steps:
2934
- uses: actions/checkout@master
35+
with:
36+
fetch-depth: 0
3037
- name: Setup Go environment
3138
uses: actions/setup-go@master
3239
with:
33-
go-version: '1.20'
40+
go-version: '^1.25'
3441
- name: Cache downloaded module
3542
uses: actions/cache@master
3643
continue-on-error: true
@@ -45,6 +52,7 @@ jobs:
4552
GOARCH: ${{ matrix.goarch }}
4653
IS_PR: ${{ !!github.head_ref }}
4754
run: |
55+
GOOS= GOARCH= go generate ./...
4856
if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi
4957
if $IS_PR ; then echo $PR_PROMPT; fi
5058
export BINARY_NAME="$BINARY_PREFIX$GOOS_$GOARCH$BINARY_SUFFIX"

.github/workflows/pull.yml

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,33 @@ on:
33
pull_request_target:
44
types: [assigned, opened, synchronize, reopened]
55
jobs:
6-
golangci:
7-
name: lint
6+
# This workflow closes invalid PR
7+
close-pr:
8+
name: closepr
9+
# The type of runner that the job will run on
810
runs-on: ubuntu-latest
9-
steps:
10-
- name: Set up Go
11-
uses: actions/setup-go@master
12-
with:
13-
go-version: '1.20'
14-
15-
- name: Check out code into the Go module directory
16-
uses: actions/checkout@v4
17-
with:
18-
ref: ${{ github.event.pull_request.head.sha }}
19-
20-
- name: Tidy Modules
21-
run: go mod tidy
11+
permissions: write-all
2212

23-
- name: golangci-lint
24-
uses: golangci/golangci-lint-action@master
13+
# Steps represent a sequence of tasks that will be executed as part of the job
14+
steps:
15+
- name: Close PR if commit message contains ".go"
16+
if: contains(github.event.pull_request.title, '.go')
17+
uses: superbrothers/close-pull-request@v3
2518
with:
26-
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
27-
version: latest
28-
29-
# Optional: working directory, useful for monorepos
30-
# working-directory: somedir
31-
32-
# Optional: golangci-lint command line arguments.
33-
# args: --issues-exit-code=0
19+
# Optional. Post a issue comment just before closing a pull request.
20+
comment: "非法PR. 请`fork`后修改自己的仓库, 而不是向主仓库提交更改. 如果您确信您的PR是为了给主仓库新增功能或修复bug, 请更改默认PR标题. **注意**: 如果您再次触发本提示, 则有可能导致账号被封禁."
3421

35-
# Optional: show only new issues if it's a pull request. The default value is `false`.
36-
# only-new-issues: true
37-
38-
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
39-
# skip-pkg-cache: true
40-
41-
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
42-
# skip-build-cache: true
22+
golangci:
23+
needs: close-pr
24+
if: ${{ !contains(github.event.pull_request.title, '.go') }}
25+
uses: ./.github/workflows/lib_lint.yml
26+
with:
27+
ref: ${{ github.event.pull_request.head.sha }}
28+
commit_back: false
29+
30+
runmain:
31+
needs: golangci
32+
if: ${{ !contains(github.event.pull_request.title, '.go') }}
33+
uses: ./.github/workflows/lib_run.yml
34+
with:
35+
ref: ${{ github.event.pull_request.head.sha }}

.github/workflows/push.yml

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,20 @@
11
name: PushLint
2-
on: [ push ]
2+
on:
3+
push:
4+
branches:
5+
- master
6+
tags:
7+
- 'v*'
38
jobs:
49
golangci:
5-
name: lint
6-
runs-on: ubuntu-latest
7-
steps:
8-
- name: Set up Go
9-
uses: actions/setup-go@master
10-
with:
11-
go-version: '1.20'
10+
uses: ./.github/workflows/lib_lint.yml
11+
with:
12+
ref: master
13+
commit_back: true
1214

13-
- name: Check out code into the Go module directory
14-
uses: actions/checkout@master
15-
16-
- name: Tidy Modules
17-
run: go mod tidy
18-
19-
- name: Run Lint
20-
uses: golangci/golangci-lint-action@master
21-
with:
22-
version: latest
23-
24-
- name: Commit back
25-
if: ${{ !github.head_ref }}
26-
continue-on-error: true
27-
run: |
28-
git config --local user.name 'github-actions[bot]'
29-
git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com'
30-
git add --all
31-
git commit -m "chore(lint): 改进代码样式"
32-
33-
- name: Create Pull Request
34-
if: ${{ !github.head_ref }}
35-
continue-on-error: true
36-
uses: peter-evans/create-pull-request@v4
15+
runmain:
16+
needs: golangci
17+
if: ${{ !contains(github.event.pull_request.title, '.go') }}
18+
uses: ./.github/workflows/lib_run.yml
19+
with:
20+
ref: master

.github/workflows/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: 发行版
2+
on:
3+
workflow_run:
4+
workflows: [最新版]
5+
types:
6+
- completed
7+
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-latest
11+
if: ${{ github.event.workflow_run.conclusion == 'success' && startsWith(github.event.workflow_run.head_branch, 'v') }}
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@master
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@master
20+
with:
21+
go-version: '1.25'
22+
23+
- name: Run GoReleaser
24+
uses: goreleaser/goreleaser-action@master
25+
with:
26+
version: "~> v2"
27+
args: release --clean
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

abineundo/console_ansi.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//go:build !windows
2+
3+
package abineundo
4+
5+
import (
6+
"fmt"
7+
8+
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
9+
)
10+
11+
func init() {
12+
fmt.Print("\033]0;ZeroBot-Blugin " + banner.Version + " " + banner.Copyright + "\007")
13+
}

0 commit comments

Comments
 (0)