mirror of
https://github.com/oneclickvirt/ecs.git
synced 2025-09-27 19:52:08 +08:00
Compare commits
99 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
bf44ea9324 | ||
![]() |
191ddfd668 | ||
![]() |
89a99a7428 | ||
![]() |
c474c71091 | ||
![]() |
43b2c8aca3 | ||
![]() |
96117a040e | ||
![]() |
c5aeda45bd | ||
![]() |
0b2ac51f09 | ||
![]() |
ffe1b65a2b | ||
![]() |
a4bfd4d143 | ||
![]() |
edbcf1c245 | ||
![]() |
4c65417ea6 | ||
![]() |
2cf7484881 | ||
![]() |
d5da2a59b6 | ||
![]() |
372deb59eb | ||
![]() |
8e4c6dfd3e | ||
![]() |
8fc828d416 | ||
![]() |
8a3fbd79e6 | ||
![]() |
5628f1bb9c | ||
![]() |
cadbb2a45c | ||
![]() |
56d7560471 | ||
![]() |
75e7eb1b25 | ||
![]() |
24ba56cfa6 | ||
![]() |
ebefd64a3d | ||
![]() |
4d83ffea02 | ||
![]() |
01a4084462 | ||
![]() |
6674093425 | ||
![]() |
6d2e56b1ec | ||
![]() |
2a736d3e70 | ||
![]() |
d02383b8cb | ||
![]() |
0caba0ea60 | ||
![]() |
6f92b8a994 | ||
![]() |
cc34baf9e1 | ||
![]() |
84d8963684 | ||
![]() |
a94e9a6284 | ||
![]() |
06007c191f | ||
![]() |
d013b8f90c | ||
![]() |
42002fdae1 | ||
![]() |
d7628a5a57 | ||
![]() |
e5f3ca1ec3 | ||
![]() |
e70a295a5f | ||
![]() |
58821f2603 | ||
![]() |
33a656304b | ||
![]() |
33d9a3ccb0 | ||
![]() |
1d5758999c | ||
![]() |
94ce394e04 | ||
![]() |
ede04bd2c2 | ||
![]() |
50f6ef1f60 | ||
![]() |
e5129ab244 | ||
![]() |
15b6ba4eb8 | ||
![]() |
6c77f74003 | ||
![]() |
61a1508b53 | ||
![]() |
022284018d | ||
![]() |
1d682213fe | ||
![]() |
649a09b50a | ||
![]() |
0fa2ff9300 | ||
![]() |
b174e5cfa8 | ||
![]() |
afd667db59 | ||
![]() |
d846dcbf4f | ||
![]() |
f47b1e3023 | ||
![]() |
63658bb2dc | ||
![]() |
b1a8368af3 | ||
![]() |
df6d1236cc | ||
![]() |
7c64102581 | ||
![]() |
58cb4f3831 | ||
![]() |
20bddae048 | ||
![]() |
3c0590ca8d | ||
![]() |
a752eeeeb0 | ||
![]() |
630a28f2f2 | ||
![]() |
cfd70e100b | ||
![]() |
9114f5b97a | ||
![]() |
8c0fc16384 | ||
![]() |
2ded570639 | ||
![]() |
42f0cb3399 | ||
![]() |
14adbddeb9 | ||
![]() |
27fd06b007 | ||
![]() |
88db8df827 | ||
![]() |
ec728796f4 | ||
![]() |
147e8c1113 | ||
![]() |
b9b1d5ca76 | ||
![]() |
1500c8342e | ||
![]() |
e523ca3c84 | ||
![]() |
42943370bb | ||
![]() |
7339f0336c | ||
![]() |
54bbe16563 | ||
![]() |
2a66452f40 | ||
![]() |
aab6bf197d | ||
![]() |
9206088bad | ||
![]() |
48e150036d | ||
![]() |
486b767a25 | ||
![]() |
5a2e68bf92 | ||
![]() |
97d05f4b57 | ||
![]() |
4f08a33de8 | ||
![]() |
ff8712a743 | ||
![]() |
abd38554b6 | ||
![]() |
918a9b3a46 | ||
![]() |
d9dac50487 | ||
![]() |
cd65f04433 | ||
![]() |
8b5193eca1 |
84
.back/.goreleaser.old
Normal file
84
.back/.goreleaser.old
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
- go mod tidy -v
|
||||||
|
builds:
|
||||||
|
- id: universal
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
- windows
|
||||||
|
- freebsd
|
||||||
|
goarch:
|
||||||
|
- arm
|
||||||
|
- arm64
|
||||||
|
- 386
|
||||||
|
- amd64
|
||||||
|
- mips
|
||||||
|
- mipsle
|
||||||
|
- s390x
|
||||||
|
- riscv64
|
||||||
|
gomips:
|
||||||
|
- softfloat
|
||||||
|
ignore:
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
- id: darwin-amd64
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
- CC=o64-clang
|
||||||
|
- CXX=o64-clang++
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- darwin
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
- id: darwin-arm64
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
- CC=oa64-clang
|
||||||
|
- CXX=oa64-clang++
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- darwin
|
||||||
|
goarch:
|
||||||
|
- arm64
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
universal_binaries:
|
||||||
|
- name_template: "goecs"
|
||||||
|
replace: false
|
||||||
|
checksum:
|
||||||
|
name_template: "checksums.txt"
|
||||||
|
snapshot:
|
||||||
|
name_template: "goecs"
|
||||||
|
archives:
|
||||||
|
- name_template: "goecs_{{ .Os }}_{{ .Arch }}"
|
||||||
|
format: zip
|
||||||
|
files:
|
||||||
|
- none*
|
||||||
|
changelog:
|
||||||
|
sort: asc
|
||||||
|
filters:
|
||||||
|
exclude:
|
||||||
|
- "^docs:"
|
||||||
|
- "^test:"
|
||||||
|
- "^chore"
|
||||||
|
- Merge pull request
|
||||||
|
- Merge branch
|
||||||
|
- go mod tidy
|
||||||
|
- New translations
|
522
.back/.goreleaser.yaml
Normal file
522
.back/.goreleaser.yaml
Normal file
@@ -0,0 +1,522 @@
|
|||||||
|
version: 2
|
||||||
|
project_name: goecs
|
||||||
|
|
||||||
|
env:
|
||||||
|
- GO111MODULE=on
|
||||||
|
|
||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
- go mod tidy -v
|
||||||
|
|
||||||
|
builds:
|
||||||
|
# Linux AMD64 with CGO
|
||||||
|
- id: linux-amd64-cgo
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
- CC=x86_64-linux-gnu-gcc
|
||||||
|
- CGO_CFLAGS=-O2 -static -fno-stack-protector
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- echo "Starting build for linux/amd64 (CGO)"
|
||||||
|
post:
|
||||||
|
- echo "Successfully built linux/amd64 (CGO)"
|
||||||
|
- echo "---"
|
||||||
|
|
||||||
|
# Linux 386 with CGO - 修复了编译器和标志
|
||||||
|
- id: linux-386-cgo
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
- CC=gcc
|
||||||
|
- CGO_CFLAGS=-m32 -O1 -march=i686 -mtune=generic -fno-stack-protector
|
||||||
|
- CGO_LDFLAGS=-m32
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags="-m32 -static"
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- 386
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- echo "Starting build for linux/386 (CGO)"
|
||||||
|
post:
|
||||||
|
- echo "Successfully built linux/386 (CGO)"
|
||||||
|
- echo "---"
|
||||||
|
|
||||||
|
# Linux ARM64 with CGO
|
||||||
|
- id: linux-arm64-cgo
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
- CC=aarch64-linux-gnu-gcc
|
||||||
|
- CGO_CFLAGS=-O1 -fno-stack-protector
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- arm64
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- echo "Starting build for linux/arm64 (CGO)"
|
||||||
|
post:
|
||||||
|
- echo "Successfully built linux/arm64 (CGO)"
|
||||||
|
- echo "---"
|
||||||
|
|
||||||
|
# Windows AMD64 with CGO
|
||||||
|
- id: windows-amd64-cgo
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
- CC=x86_64-w64-mingw32-gcc
|
||||||
|
- CGO_CFLAGS=-O2 -static-libgcc -static-libstdc++
|
||||||
|
- CGO_LDFLAGS=-static-libgcc -static-libstdc++
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- windows
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- echo "Starting build for windows/amd64 (CGO)"
|
||||||
|
post:
|
||||||
|
- echo "Successfully built windows/amd64 (CGO)"
|
||||||
|
- echo "---"
|
||||||
|
|
||||||
|
# Windows 386 with CGO - 修复了编译器名称
|
||||||
|
- id: windows-386-cgo
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
- CC=i686-w64-mingw32-gcc
|
||||||
|
- CGO_CFLAGS=-O2 -static-libgcc -static-libstdc++
|
||||||
|
- CGO_LDFLAGS=-static-libgcc -static-libstdc++
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- windows
|
||||||
|
goarch:
|
||||||
|
- 386
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- echo "Starting build for windows/386 (CGO)"
|
||||||
|
post:
|
||||||
|
- echo "Successfully built windows/386 (CGO)"
|
||||||
|
- echo "---"
|
||||||
|
|
||||||
|
# Darwin AMD64 with CGO
|
||||||
|
- id: darwin-amd64-cgo
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
- CC=o64-clang
|
||||||
|
- CGO_CFLAGS=-O2 -arch x86_64 -mmacosx-version-min=10.12
|
||||||
|
- CGO_LDFLAGS=-arch x86_64 -mmacosx-version-min=10.12
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- darwin
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- echo "Starting build for darwin/amd64 (CGO)"
|
||||||
|
- echo "Checking osxcross tools..."
|
||||||
|
- which o64-clang || echo "o64-clang not found"
|
||||||
|
- which o64-clang++ || echo "o64-clang++ not found"
|
||||||
|
post:
|
||||||
|
- echo "Successfully built darwin/amd64 (CGO)"
|
||||||
|
- echo "---"
|
||||||
|
|
||||||
|
# Darwin ARM64 with CGO
|
||||||
|
- id: darwin-arm64-cgo
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
- CC=oa64-clang
|
||||||
|
- CGO_CFLAGS=-O2 -arch arm64 -mmacosx-version-min=11.0
|
||||||
|
- CGO_LDFLAGS=-arch arm64 -mmacosx-version-min=11.0
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- darwin
|
||||||
|
goarch:
|
||||||
|
- arm64
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- echo "Starting build for darwin/arm64 (CGO)"
|
||||||
|
- echo "Checking osxcross tools..."
|
||||||
|
- which oa64-clang || echo "oa64-clang not found"
|
||||||
|
- which oa64-clang++ || echo "oa64-clang++ not found"
|
||||||
|
post:
|
||||||
|
- echo "Successfully built darwin/arm64 (CGO)"
|
||||||
|
- echo "---"
|
||||||
|
|
||||||
|
# Linux RISC-V 64 with CGO
|
||||||
|
- id: linux-riscv64-cgo
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
- CC=riscv64-linux-gnu-gcc
|
||||||
|
- CGO_CFLAGS=-O1 -fno-stack-protector
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- riscv64
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- echo "Starting build for linux/riscv64 (CGO)"
|
||||||
|
post:
|
||||||
|
- echo "Successfully built linux/riscv64 (CGO)"
|
||||||
|
- echo "---"
|
||||||
|
|
||||||
|
# Linux MIPS64 with CGO
|
||||||
|
- id: linux-mips64-cgo
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
- CC=mips64-linux-gnuabi64-gcc
|
||||||
|
- CGO_CFLAGS=-O1 -fno-stack-protector
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- mips64
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- echo "Starting build for linux/mips64 (CGO)"
|
||||||
|
post:
|
||||||
|
- echo "Successfully built linux/mips64 (CGO)"
|
||||||
|
- echo "---"
|
||||||
|
|
||||||
|
# Linux MIPS64LE with CGO
|
||||||
|
- id: linux-mips64le-cgo
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
- CC=mips64el-linux-gnuabi64-gcc
|
||||||
|
- CGO_CFLAGS=-O1 -fno-stack-protector
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- mips64le
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- echo "Starting build for linux/mips64le (CGO)"
|
||||||
|
post:
|
||||||
|
- echo "Successfully built linux/mips64le (CGO)"
|
||||||
|
- echo "---"
|
||||||
|
|
||||||
|
# Linux PPC64LE with CGO
|
||||||
|
- id: linux-ppc64le-cgo
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
- CC=powerpc64le-linux-gnu-gcc
|
||||||
|
- CGO_CFLAGS=-O1 -fno-stack-protector
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- ppc64le
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- echo "Starting build for linux/ppc64le (CGO)"
|
||||||
|
post:
|
||||||
|
- echo "Successfully built linux/ppc64le (CGO)"
|
||||||
|
- echo "---"
|
||||||
|
|
||||||
|
# Linux ARM (no CGO)
|
||||||
|
- id: linux-arm-nocgo
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- arm
|
||||||
|
goarm:
|
||||||
|
- "5"
|
||||||
|
- "6"
|
||||||
|
- "7"
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- echo "Starting build for linux/arm (no CGO)"
|
||||||
|
post:
|
||||||
|
- echo "Successfully built linux/arm (no CGO)"
|
||||||
|
- echo "---"
|
||||||
|
|
||||||
|
# Linux S390X (no CGO)
|
||||||
|
- id: linux-s390x-nocgo
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- s390x
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- echo "Starting build for linux/s390x (no CGO)"
|
||||||
|
post:
|
||||||
|
- echo "Successfully built linux/s390x (no CGO)"
|
||||||
|
- echo "---"
|
||||||
|
|
||||||
|
# Linux MIPS (no CGO)
|
||||||
|
- id: linux-mips-nocgo
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- mips
|
||||||
|
gomips:
|
||||||
|
- softfloat
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- echo "Starting build for linux/mips (no CGO)"
|
||||||
|
post:
|
||||||
|
- echo "Successfully built linux/mips (no CGO)"
|
||||||
|
- echo "---"
|
||||||
|
|
||||||
|
# Linux MIPSLE (no CGO)
|
||||||
|
- id: linux-mipsle-nocgo
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- mipsle
|
||||||
|
gomips:
|
||||||
|
- softfloat
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- echo "Starting build for linux/mipsle (no CGO)"
|
||||||
|
post:
|
||||||
|
- echo "Successfully built linux/mipsle (no CGO)"
|
||||||
|
- echo "---"
|
||||||
|
|
||||||
|
# Linux PPC64 (no CGO)
|
||||||
|
- id: linux-ppc64-nocgo
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- ppc64
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- echo "Starting build for linux/ppc64 (no CGO)"
|
||||||
|
post:
|
||||||
|
- echo "Successfully built linux/ppc64 (no CGO)"
|
||||||
|
- echo "---"
|
||||||
|
|
||||||
|
# FreeBSD AMD64 (no CGO)
|
||||||
|
- id: freebsd-amd64-nocgo
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- freebsd
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- echo "Starting build for freebsd/amd64 (no CGO)"
|
||||||
|
post:
|
||||||
|
- echo "Successfully built freebsd/amd64 (no CGO)"
|
||||||
|
- echo "---"
|
||||||
|
|
||||||
|
# FreeBSD ARM64 (no CGO)
|
||||||
|
- id: freebsd-arm64-nocgo
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- freebsd
|
||||||
|
goarch:
|
||||||
|
- arm64
|
||||||
|
main: ./
|
||||||
|
binary: goecs
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- echo "Starting build for freebsd/arm64 (no CGO)"
|
||||||
|
post:
|
||||||
|
- echo "Successfully built freebsd/arm64 (no CGO)"
|
||||||
|
- echo "---"
|
||||||
|
|
||||||
|
universal_binaries:
|
||||||
|
- name_template: "goecs"
|
||||||
|
replace: false
|
||||||
|
ids:
|
||||||
|
- darwin-amd64-cgo
|
||||||
|
- darwin-arm64-cgo
|
||||||
|
|
||||||
|
checksum:
|
||||||
|
name_template: "checksums.txt"
|
||||||
|
algorithm: sha256
|
||||||
|
disable: false
|
||||||
|
ids:
|
||||||
|
- linux-amd64-cgo
|
||||||
|
- linux-386-cgo
|
||||||
|
- linux-arm64-cgo
|
||||||
|
- linux-riscv64-cgo
|
||||||
|
- linux-mips64-cgo
|
||||||
|
- linux-mips64le-cgo
|
||||||
|
- linux-ppc64le-cgo
|
||||||
|
- windows-amd64-cgo
|
||||||
|
- windows-386-cgo
|
||||||
|
- darwin-amd64-cgo
|
||||||
|
- darwin-arm64-cgo
|
||||||
|
- linux-arm-nocgo
|
||||||
|
- linux-s390x-nocgo
|
||||||
|
- linux-mips-nocgo
|
||||||
|
- linux-mipsle-nocgo
|
||||||
|
- linux-ppc64-nocgo
|
||||||
|
- freebsd-amd64-nocgo
|
||||||
|
- freebsd-arm64-nocgo
|
||||||
|
extra_files:
|
||||||
|
- glob: "./goecs.sh"
|
||||||
|
|
||||||
|
snapshot:
|
||||||
|
name_template: "goecs"
|
||||||
|
|
||||||
|
archives:
|
||||||
|
- id: default
|
||||||
|
name_template: "goecs_{{ .Os }}_{{ .Arch }}"
|
||||||
|
format: zip
|
||||||
|
files:
|
||||||
|
- none*
|
||||||
|
allow_different_binary_count: true
|
||||||
|
builds:
|
||||||
|
- linux-amd64-cgo
|
||||||
|
- linux-386-cgo
|
||||||
|
- linux-arm64-cgo
|
||||||
|
- linux-riscv64-cgo
|
||||||
|
- linux-mips64-cgo
|
||||||
|
- linux-mips64le-cgo
|
||||||
|
- linux-ppc64le-cgo
|
||||||
|
- windows-amd64-cgo
|
||||||
|
- windows-386-cgo
|
||||||
|
- darwin-amd64-cgo
|
||||||
|
- darwin-arm64-cgo
|
||||||
|
- linux-arm-nocgo
|
||||||
|
- linux-s390x-nocgo
|
||||||
|
- linux-mips-nocgo
|
||||||
|
- linux-mipsle-nocgo
|
||||||
|
- linux-ppc64-nocgo
|
||||||
|
- freebsd-amd64-nocgo
|
||||||
|
- freebsd-arm64-nocgo
|
||||||
|
|
||||||
|
changelog:
|
||||||
|
sort: asc
|
||||||
|
filters:
|
||||||
|
exclude:
|
||||||
|
- "^docs:"
|
||||||
|
- "^test:"
|
||||||
|
- "^chore"
|
||||||
|
- Merge pull request
|
||||||
|
- Merge branch
|
||||||
|
- go mod tidy
|
||||||
|
- New translations
|
132
.back/build.yaml
Normal file
132
.back/build.yaml
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
name: Goreleaser
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
tags:
|
||||||
|
- "v*.*.*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
goreleaser:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
# 1.20 是 Windows 7/8 Server 2008/2012 最后一个支持版本
|
||||||
|
image: goreleaser/goreleaser-cross:v1.20
|
||||||
|
steps:
|
||||||
|
- name: Configure git safe directory
|
||||||
|
run: |
|
||||||
|
git config --global --add safe.directory /__w/ecs/ecs
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: 1.23.4
|
||||||
|
|
||||||
|
- name: Configure Git for Private Modules
|
||||||
|
run: |
|
||||||
|
git config --global url."https://${{ secrets.GHT }}@github.com/".insteadOf "https://github.com/"
|
||||||
|
git config --global url."git@github.com:".insteadOf "https://github.com/"
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GHT }}
|
||||||
|
|
||||||
|
- name: Install missing cross-compilation tools
|
||||||
|
run: |
|
||||||
|
echo "Installing missing cross-compilation tools..."
|
||||||
|
apt-get update
|
||||||
|
PACKAGES=(
|
||||||
|
gcc-multilib
|
||||||
|
g++-multilib
|
||||||
|
linux-libc-dev
|
||||||
|
linux-libc-dev:i386
|
||||||
|
libc6-dev-i386
|
||||||
|
libc6-dev-i386-cross
|
||||||
|
gcc-aarch64-linux-gnu
|
||||||
|
gcc-riscv64-linux-gnu
|
||||||
|
gcc-mips64-linux-gnuabi64
|
||||||
|
gcc-mips64el-linux-gnuabi64
|
||||||
|
gcc-powerpc64le-linux-gnu
|
||||||
|
gcc-mingw-w64-x86-64
|
||||||
|
gcc-mingw-w64-i686
|
||||||
|
libc6-dev-amd64-cross
|
||||||
|
libc6-dev-arm64-cross
|
||||||
|
libc6-dev-riscv64-cross
|
||||||
|
libc6-dev-mips64-cross
|
||||||
|
libc6-dev-mips64el-cross
|
||||||
|
libc6-dev-ppc64el-cross
|
||||||
|
)
|
||||||
|
for pkg in "${PACKAGES[@]}"; do
|
||||||
|
echo "Installing $pkg..."
|
||||||
|
apt-get install -y "$pkg" || echo "Failed to install $pkg, continuing..."
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Verify cross-compilation tools
|
||||||
|
run: |
|
||||||
|
echo "Checking available cross-compilation tools..."
|
||||||
|
echo "=== GCC compilers ==="
|
||||||
|
which gcc || echo "gcc not found"
|
||||||
|
which x86_64-linux-gnu-gcc || echo "x86_64-linux-gnu-gcc not found"
|
||||||
|
which aarch64-linux-gnu-gcc || echo "aarch64-linux-gnu-gcc not found"
|
||||||
|
which riscv64-linux-gnu-gcc || echo "riscv64-linux-gnu-gcc not found"
|
||||||
|
which mips64-linux-gnuabi64-gcc || echo "mips64-linux-gnuabi64-gcc not found"
|
||||||
|
which mips64el-linux-gnuabi64-gcc || echo "mips64el-linux-gnuabi64-gcc not found"
|
||||||
|
which powerpc64le-linux-gnu-gcc || echo "powerpc64le-linux-gnu-gcc not found"
|
||||||
|
echo "=== MinGW compilers ==="
|
||||||
|
which x86_64-w64-mingw32-gcc || echo "x86_64-w64-mingw32-gcc not found"
|
||||||
|
which i686-w64-mingw32-gcc || echo "i686-w64-mingw32-gcc not found"
|
||||||
|
echo "=== OSXCross compilers ==="
|
||||||
|
which o64-clang || echo "o64-clang not found"
|
||||||
|
which oa64-clang || echo "oa64-clang not found"
|
||||||
|
which o64-clang++ || echo "o64-clang++ not found"
|
||||||
|
which oa64-clang++ || echo "oa64-clang++ not found"
|
||||||
|
echo "=== Clang compilers ==="
|
||||||
|
which clang || echo "clang not found"
|
||||||
|
echo "=== Available gcc binaries ==="
|
||||||
|
ls -la /usr/bin/*gcc* | head -20
|
||||||
|
echo "=== Available clang binaries ==="
|
||||||
|
ls -la /usr/bin/*clang* | head -10
|
||||||
|
echo "=== OSXCross directory ==="
|
||||||
|
ls -la /usr/osxcross/bin/ 2>/dev/null || echo "OSXCross not found in /usr/osxcross/bin/"
|
||||||
|
|
||||||
|
- name: Run GoReleaser
|
||||||
|
uses: goreleaser/goreleaser-action@v6
|
||||||
|
with:
|
||||||
|
distribution: goreleaser
|
||||||
|
version: latest
|
||||||
|
args: release --parallelism 1 --verbose
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GHT }}
|
||||||
|
GOPRIVATE: github.com/oneclickvirt/security
|
||||||
|
|
||||||
|
- name: Update goecs.sh with new version
|
||||||
|
run: |
|
||||||
|
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
|
||||||
|
VERSION="${GITHUB_REF#refs/tags/v}"
|
||||||
|
else
|
||||||
|
VERSION=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.1.37")
|
||||||
|
fi
|
||||||
|
echo "Using version: $VERSION"
|
||||||
|
FILE="goecs.sh"
|
||||||
|
BRANCH="master"
|
||||||
|
git config --global user.name "github-actions[bot]"
|
||||||
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
git config --global --unset url."git@github.com:".insteadOf || true
|
||||||
|
git fetch origin $BRANCH
|
||||||
|
git checkout $BRANCH
|
||||||
|
if [ ! -f "$FILE" ]; then
|
||||||
|
echo "Error: $FILE not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sed -i "s/\(_yellow \"Unable to get version info, using default version \).*\(\".*\)/\1$VERSION\2/" "$FILE"
|
||||||
|
sed -i "s/\(ECS_VERSION=\"\).*\(\"\)/\1$VERSION\2/" "$FILE"
|
||||||
|
if git diff --quiet "$FILE"; then
|
||||||
|
echo "No changes detected in $FILE"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
git add "$FILE"
|
||||||
|
git commit -m "chore: update ECS_VERSION to $VERSION in goecs.sh"
|
||||||
|
git push origin $BRANCH
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GHT }}
|
@@ -1,4 +1,4 @@
|
|||||||
name: goreleaser
|
name: Build and Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
@@ -22,7 +22,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: 1.23.4
|
go-version: 1.24.5
|
||||||
|
|
||||||
- name: Configure Git for Private Modules
|
- name: Configure Git for Private Modules
|
||||||
run: |
|
run: |
|
||||||
@@ -32,10 +32,11 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GHT }}
|
GITHUB_TOKEN: ${{ secrets.GHT }}
|
||||||
|
|
||||||
- name: Run GoReleaser
|
- name: Run GoReleaser
|
||||||
uses: goreleaser/goreleaser-action@v2
|
uses: goreleaser/goreleaser-action@v6
|
||||||
with:
|
with:
|
||||||
distribution: goreleaser
|
distribution: goreleaser
|
||||||
version: latest
|
# version: latest
|
||||||
|
version: '~> v2'
|
||||||
args: release
|
args: release
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GHT }}
|
GITHUB_TOKEN: ${{ secrets.GHT }}
|
467
.github/workflows/build_binary_cgo.old
vendored
Normal file
467
.github/workflows/build_binary_cgo.old
vendored
Normal file
@@ -0,0 +1,467 @@
|
|||||||
|
name: Build and Release
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
tags:
|
||||||
|
- "v*.*.*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Release Check And Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Get latest tag
|
||||||
|
id: tag
|
||||||
|
run: |
|
||||||
|
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0")
|
||||||
|
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||||
|
echo "version=${TAG#v}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Generate changelog
|
||||||
|
id: changelog
|
||||||
|
run: |
|
||||||
|
TAG="${{ steps.tag.outputs.tag }}"
|
||||||
|
PREV_TAG=$(git describe --tags --abbrev=0 "$TAG^" 2>/dev/null || echo "")
|
||||||
|
if [ -z "$PREV_TAG" ]; then
|
||||||
|
CHANGELOG=$(git log --oneline --pretty=format:"* %H %s" "$TAG" | head -20)
|
||||||
|
else
|
||||||
|
CHANGELOG=$(git log --oneline --pretty=format:"* %H %s" "$PREV_TAG..$TAG")
|
||||||
|
fi
|
||||||
|
FULL_CHANGELOG="## Changelog"$'\n'"$CHANGELOG"
|
||||||
|
echo "$FULL_CHANGELOG" > changelog.txt
|
||||||
|
echo "changelog<<EOF" >> $GITHUB_OUTPUT
|
||||||
|
echo "$FULL_CHANGELOG" >> $GITHUB_OUTPUT
|
||||||
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Create or update release
|
||||||
|
run: |
|
||||||
|
TAG="${{ steps.tag.outputs.tag }}"
|
||||||
|
CHANGELOG_BODY=$(cat changelog.txt | jq -Rs .)
|
||||||
|
RELEASE_EXISTS=$(curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG" | jq -r '.id // empty')
|
||||||
|
if [ -z "$RELEASE_EXISTS" ]; then
|
||||||
|
curl -s -X POST -H "Authorization: Bearer ${{ secrets.GHT }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":$CHANGELOG_BODY,\"draft\":false,\"prerelease\":false}" \
|
||||||
|
"https://api.github.com/repos/${{ github.repository }}/releases"
|
||||||
|
else
|
||||||
|
curl -s -X PATCH -H "Authorization: Bearer ${{ secrets.GHT }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"body\":$CHANGELOG_BODY}" \
|
||||||
|
"https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_EXISTS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Delete existing release assets
|
||||||
|
run: |
|
||||||
|
TAG="${{ steps.tag.outputs.tag }}"
|
||||||
|
RELEASE_ID=$(curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG" | jq -r '.id')
|
||||||
|
if [ "$RELEASE_ID" != "null" ]; then
|
||||||
|
ASSETS=$(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets" | jq -r '.[] | .id')
|
||||||
|
for asset in $ASSETS; do
|
||||||
|
curl -s -X DELETE -H "Authorization: Bearer ${{ secrets.GHT }}" "https://api.github.com/repos/${{ github.repository }}/releases/assets/$asset"
|
||||||
|
done
|
||||||
|
sleep 30
|
||||||
|
fi
|
||||||
|
|
||||||
|
release-binary:
|
||||||
|
name: Release Go Binary
|
||||||
|
needs: build
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- goos: linux
|
||||||
|
goarch: amd64
|
||||||
|
cgo_enabled: "1"
|
||||||
|
cc: x86_64-linux-gnu-gcc
|
||||||
|
cflags: "-O2 -static -fno-stack-protector"
|
||||||
|
ldflags: "-extldflags=-static -s -w"
|
||||||
|
packages: "build-essential gcc"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: 386
|
||||||
|
cgo_enabled: "1"
|
||||||
|
cc: x86_64-linux-gnu-gcc
|
||||||
|
cflags: "-m32 -O1 -march=i686 -mtune=generic -fno-stack-protector"
|
||||||
|
ldflags: "-extldflags=-static -s -w"
|
||||||
|
packages: "build-essential gcc-multilib"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm64
|
||||||
|
cgo_enabled: "1"
|
||||||
|
cc: aarch64-linux-gnu-gcc
|
||||||
|
cflags: "-O1 -fno-stack-protector"
|
||||||
|
ldflags: "-extldflags=-static -s -w"
|
||||||
|
packages: "build-essential gcc-aarch64-linux-gnu"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: riscv64
|
||||||
|
cgo_enabled: "1"
|
||||||
|
cc: riscv64-linux-gnu-gcc
|
||||||
|
cflags: "-O1 -fno-stack-protector"
|
||||||
|
ldflags: "-extldflags=-static -s -w"
|
||||||
|
packages: "build-essential gcc-riscv64-linux-gnu"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: mips64
|
||||||
|
cgo_enabled: "1"
|
||||||
|
cc: mips64-linux-gnuabi64-gcc
|
||||||
|
cflags: "-O1 -fno-stack-protector"
|
||||||
|
ldflags: "-extldflags=-static -s -w"
|
||||||
|
packages: "build-essential gcc-mips64-linux-gnuabi64"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: mips64le
|
||||||
|
cgo_enabled: "1"
|
||||||
|
cc: mips64el-linux-gnuabi64-gcc
|
||||||
|
cflags: "-O1 -fno-stack-protector"
|
||||||
|
ldflags: "-extldflags=-static -s -w"
|
||||||
|
packages: "build-essential gcc-mips64el-linux-gnuabi64"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: ppc64le
|
||||||
|
cgo_enabled: "1"
|
||||||
|
cc: powerpc64le-linux-gnu-gcc
|
||||||
|
cflags: "-O1 -fno-stack-protector"
|
||||||
|
ldflags: "-extldflags=-static -s -w"
|
||||||
|
packages: "build-essential gcc-powerpc64le-linux-gnu"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm
|
||||||
|
# goarm: 7
|
||||||
|
cgo_enabled: "1"
|
||||||
|
cc: arm-linux-gnueabihf-gcc
|
||||||
|
cflags: "-O1 -fno-stack-protector"
|
||||||
|
ldflags: "-extldflags=-static -s -w"
|
||||||
|
packages: "build-essential gcc-arm-linux-gnueabihf"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: windows
|
||||||
|
goarch: amd64
|
||||||
|
cgo_enabled: "1"
|
||||||
|
cc: x86_64-w64-mingw32-gcc
|
||||||
|
cflags: "-O2 -static-libgcc -static-libstdc++"
|
||||||
|
ldflags: "-extldflags=-static -s -w"
|
||||||
|
packages: "build-essential gcc-mingw-w64-x86-64"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: windows
|
||||||
|
goarch: 386
|
||||||
|
cgo_enabled: "1"
|
||||||
|
cc: i686-w64-mingw32-gcc
|
||||||
|
cflags: "-O2 -static-libgcc -static-libstdc++"
|
||||||
|
ldflags: "-extldflags=-static -s -w"
|
||||||
|
packages: "build-essential gcc-mingw-w64-i686"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm64
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-extldflags=-static -s -w"
|
||||||
|
packages: "build-essential"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: darwin
|
||||||
|
goarch: amd64
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-s -w"
|
||||||
|
runner: macos-latest
|
||||||
|
|
||||||
|
- goos: darwin
|
||||||
|
goarch: arm64
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-s -w"
|
||||||
|
runner: macos-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: s390x
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-s -w"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: mips
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-s -w"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: mipsle
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-s -w"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: ppc64
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-s -w"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm64
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-s -w"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: amd64
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-s -w"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: arm64
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-s -w"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: 1.24.5
|
||||||
|
|
||||||
|
- name: Configure Git for Private Modules
|
||||||
|
run: |
|
||||||
|
git config --global url."https://${{ secrets.GHT }}@github.com/".insteadOf "https://github.com/"
|
||||||
|
git config --global url."git@github.com:".insteadOf "https://github.com/"
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GHT }}
|
||||||
|
|
||||||
|
- name: Install cross-compilation tools
|
||||||
|
if: matrix.runner != 'macos-latest'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update -qq
|
||||||
|
case "${{ matrix.goos }}-${{ matrix.goarch }}" in
|
||||||
|
linux-386)
|
||||||
|
sudo apt-get install -y build-essential gcc-multilib g++-multilib ;;
|
||||||
|
linux-arm64)
|
||||||
|
sudo apt-get install -y build-essential gcc-aarch64-linux-gnu ;;
|
||||||
|
linux-riscv64)
|
||||||
|
sudo apt-get install -y build-essential gcc-riscv64-linux-gnu ;;
|
||||||
|
linux-mips64)
|
||||||
|
sudo apt-get install -y build-essential gcc-mips64-linux-gnuabi64 ;;
|
||||||
|
linux-mips64le)
|
||||||
|
sudo apt-get install -y build-essential gcc-mips64el-linux-gnuabi64 ;;
|
||||||
|
linux-ppc64le)
|
||||||
|
sudo apt-get install -y build-essential gcc-powerpc64le-linux-gnu ;;
|
||||||
|
linux-arm)
|
||||||
|
sudo apt-get install -y build-essential gcc-arm-linux-gnueabihf ;;
|
||||||
|
windows-amd64|windows-386)
|
||||||
|
sudo apt-get install -y build-essential gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 ;;
|
||||||
|
*)
|
||||||
|
sudo apt-get install -y build-essential ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
- name: Get latest tag
|
||||||
|
id: tag
|
||||||
|
run: |
|
||||||
|
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0")
|
||||||
|
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||||
|
echo "version=${TAG#v}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Build Binary
|
||||||
|
env:
|
||||||
|
CGO_ENABLED: ${{ matrix.cgo_enabled }}
|
||||||
|
GOOS: ${{ matrix.goos }}
|
||||||
|
GOARCH: ${{ matrix.goarch }}
|
||||||
|
CC: ${{ matrix.cc }}
|
||||||
|
CGO_CFLAGS: ${{ matrix.cflags }}
|
||||||
|
CGO_LDFLAGS: ${{ matrix.ldflags }}
|
||||||
|
run: |
|
||||||
|
go clean -cache -modcache -testcache
|
||||||
|
|
||||||
|
# 设置额外的环境变量
|
||||||
|
if [[ -n "${{ matrix.goarm }}" ]]; then
|
||||||
|
export GOARM=${{ matrix.goarm }}
|
||||||
|
fi
|
||||||
|
if [[ -n "${{ matrix.gomips }}" ]]; then
|
||||||
|
export GOMIPS=${{ matrix.gomips }}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 针对 Darwin 的特殊处理
|
||||||
|
if [[ "${{ matrix.cgo_enabled }}" == "1" && "${{ matrix.goos }}" == "darwin" ]]; then
|
||||||
|
if [[ "${{ matrix.goarch }}" == "amd64" ]]; then
|
||||||
|
export CC="x86_64-apple-darwin21.4-clang"
|
||||||
|
export CXX="x86_64-apple-darwin21.4-clang++"
|
||||||
|
elif [[ "${{ matrix.goarch }}" == "arm64" ]]; then
|
||||||
|
export CC="aarch64-apple-darwin21.4-clang"
|
||||||
|
export CXX="aarch64-apple-darwin21.4-clang++"
|
||||||
|
fi
|
||||||
|
export OSXCROSS_ROOT="${OSXCROSS_ROOT}"
|
||||||
|
elif [[ "${{ matrix.cgo_enabled }}" == "1" && "${{ matrix.runner }}" != "macos-latest" ]]; then
|
||||||
|
# 对于 Windows 的特殊处理
|
||||||
|
if [[ "${{ matrix.goos }}" == "windows" ]]; then
|
||||||
|
export CGO_LDFLAGS="-static-libgcc -static-libstdc++"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 测试编译器(仅在启用 CGO 时)
|
||||||
|
if [[ "${{ matrix.cgo_enabled }}" == "1" && -n "$CC" ]]; then
|
||||||
|
echo 'int main() { return 0; }' > test.c
|
||||||
|
$CC $CGO_CFLAGS test.c -o test || exit 1
|
||||||
|
rm -f test.c test
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 清理和准备
|
||||||
|
rm -rf vendor/
|
||||||
|
go mod download
|
||||||
|
go mod tidy
|
||||||
|
mkdir -p bin
|
||||||
|
|
||||||
|
# 设置二进制文件名
|
||||||
|
BINARY_NAME="goecs"
|
||||||
|
if [[ "${{ matrix.goos }}" == "windows" ]]; then
|
||||||
|
BINARY_NAME="${BINARY_NAME}.exe"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 构建 LDFLAGS
|
||||||
|
LDFLAGS="-s -w -X main.version=${{ steps.tag.outputs.version }} -X main.arch=${{ matrix.goarch }}"
|
||||||
|
if [[ "${{ matrix.cgo_enabled }}" == "1" ]]; then
|
||||||
|
LDFLAGS="${LDFLAGS} -checklinkname=0 ${{ matrix.ldflags }}"
|
||||||
|
else
|
||||||
|
LDFLAGS="${LDFLAGS} -checklinkname=0 ${{ matrix.ldflags }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 执行构建
|
||||||
|
echo "Building for GOOS=$GOOS GOARCH=$GOARCH CGO_ENABLED=$CGO_ENABLED"
|
||||||
|
go build -a -o bin/$BINARY_NAME -ldflags="$LDFLAGS" -trimpath ./
|
||||||
|
|
||||||
|
# 验证文件是否存在
|
||||||
|
[[ -f "bin/$BINARY_NAME" ]] || exit 1
|
||||||
|
|
||||||
|
# 显示构建信息
|
||||||
|
echo "Built binary: bin/$BINARY_NAME"
|
||||||
|
ls -la bin/
|
||||||
|
if command -v file >/dev/null 2>&1; then
|
||||||
|
file bin/$BINARY_NAME
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Create ZIP archive
|
||||||
|
run: |
|
||||||
|
cd bin
|
||||||
|
BINARY_NAME="goecs"
|
||||||
|
if [[ "${{ matrix.goos }}" == "windows" ]]; then
|
||||||
|
BINARY_NAME="${BINARY_NAME}.exe"
|
||||||
|
fi
|
||||||
|
ZIP_NAME="goecs_${{ matrix.goos }}_${{ matrix.goarch }}"
|
||||||
|
if [[ -n "${{ matrix.goarm }}" ]]; then
|
||||||
|
ZIP_NAME="${ZIP_NAME}v${{ matrix.goarm }}"
|
||||||
|
fi
|
||||||
|
if [[ -n "${{ matrix.gomips }}" ]]; then
|
||||||
|
ZIP_NAME="${ZIP_NAME}_${{ matrix.gomips }}"
|
||||||
|
fi
|
||||||
|
ZIP_NAME="${ZIP_NAME}.zip"
|
||||||
|
zip "$ZIP_NAME" "$BINARY_NAME"
|
||||||
|
|
||||||
|
- name: Upload to Release
|
||||||
|
run: |
|
||||||
|
TAG="${{ steps.tag.outputs.tag }}"
|
||||||
|
RELEASE_ID=$(curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG" | jq -r '.id')
|
||||||
|
cd bin
|
||||||
|
for file in *.zip; do
|
||||||
|
if [[ -f "$file" ]]; then
|
||||||
|
curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" \
|
||||||
|
-H "Content-Type: application/zip" \
|
||||||
|
--data-binary @"$file" \
|
||||||
|
"https://uploads.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=$file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
checksums:
|
||||||
|
name: Generate Checksums
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: release-binary
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Get latest tag
|
||||||
|
id: tag
|
||||||
|
run: |
|
||||||
|
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0")
|
||||||
|
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Download release assets
|
||||||
|
run: |
|
||||||
|
TAG="${{ steps.tag.outputs.tag }}"
|
||||||
|
RELEASE_ID=$(curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG" | jq -r '.id')
|
||||||
|
mkdir -p assets
|
||||||
|
ASSETS=$(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets")
|
||||||
|
echo "$ASSETS" | jq -r '.[] | select(.name | endswith(".zip")) | .browser_download_url' | while read url; do
|
||||||
|
filename=$(basename "$url")
|
||||||
|
curl -L -H "Authorization: Bearer ${{ secrets.GHT }}" "$url" -o "assets/$filename"
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Generate checksums
|
||||||
|
run: |
|
||||||
|
cd assets
|
||||||
|
sha256sum *.zip > checksums.txt
|
||||||
|
if [[ -f "../goecs.sh" ]]; then
|
||||||
|
sha256sum ../goecs.sh >> checksums.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Upload checksums
|
||||||
|
run: |
|
||||||
|
TAG="${{ steps.tag.outputs.tag }}"
|
||||||
|
RELEASE_ID=$(curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG" | jq -r '.id')
|
||||||
|
curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" \
|
||||||
|
-H "Content-Type: text/plain" \
|
||||||
|
--data-binary @assets/checksums.txt \
|
||||||
|
"https://uploads.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=checksums.txt"
|
||||||
|
|
||||||
|
update-script:
|
||||||
|
name: Update Script Version
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: checksums
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Get latest tag
|
||||||
|
id: tag
|
||||||
|
run: |
|
||||||
|
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0")
|
||||||
|
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||||
|
echo "version=${TAG#v}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Update goecs.sh version
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.tag.outputs.version }}"
|
||||||
|
BRANCH="master"
|
||||||
|
git config --global user.name "github-actions[bot]"
|
||||||
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
git config --global --unset url."git@github.com:".insteadOf || true
|
||||||
|
git fetch origin $BRANCH
|
||||||
|
git checkout $BRANCH
|
||||||
|
if [ -f "goecs.sh" ]; then
|
||||||
|
sed -i "s/\(_yellow \"Unable to get version info, using default version \).*\(\".*\)/\1$VERSION\2/" "goecs.sh"
|
||||||
|
sed -i "s/\(ECS_VERSION=\"\).*\(\"\)/\1$VERSION\2/" "goecs.sh"
|
||||||
|
if ! git diff --quiet "goecs.sh"; then
|
||||||
|
git add "goecs.sh"
|
||||||
|
git commit -m "chore: update ECS_VERSION to $VERSION in goecs.sh"
|
||||||
|
git push origin $BRANCH
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GHT }}
|
527
.github/workflows/build_binary_musl.old
vendored
Normal file
527
.github/workflows/build_binary_musl.old
vendored
Normal file
@@ -0,0 +1,527 @@
|
|||||||
|
name: Build and Release
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
tags:
|
||||||
|
- "v*.*.*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Release Check And Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Get latest tag
|
||||||
|
id: tag
|
||||||
|
run: |
|
||||||
|
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0")
|
||||||
|
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||||
|
echo "version=${TAG#v}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Generate changelog
|
||||||
|
id: changelog
|
||||||
|
run: |
|
||||||
|
TAG="${{ steps.tag.outputs.tag }}"
|
||||||
|
PREV_TAG=$(git describe --tags --abbrev=0 "$TAG^" 2>/dev/null || echo "")
|
||||||
|
if [ -z "$PREV_TAG" ]; then
|
||||||
|
CHANGELOG=$(git log --oneline --pretty=format:"* %H %s" "$TAG" | head -20)
|
||||||
|
else
|
||||||
|
CHANGELOG=$(git log --oneline --pretty=format:"* %H %s" "$PREV_TAG..$TAG")
|
||||||
|
fi
|
||||||
|
FULL_CHANGELOG="## Changelog"$'\n'"$CHANGELOG"
|
||||||
|
echo "$FULL_CHANGELOG" > changelog.txt
|
||||||
|
echo "changelog<<EOF" >> $GITHUB_OUTPUT
|
||||||
|
echo "$FULL_CHANGELOG" >> $GITHUB_OUTPUT
|
||||||
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Create or update release
|
||||||
|
run: |
|
||||||
|
TAG="${{ steps.tag.outputs.tag }}"
|
||||||
|
CHANGELOG_BODY=$(cat changelog.txt | jq -Rs .)
|
||||||
|
RELEASE_EXISTS=$(curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG" | jq -r '.id // empty')
|
||||||
|
if [ -z "$RELEASE_EXISTS" ]; then
|
||||||
|
curl -s -X POST -H "Authorization: Bearer ${{ secrets.GHT }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":$CHANGELOG_BODY,\"draft\":false,\"prerelease\":false}" \
|
||||||
|
"https://api.github.com/repos/${{ github.repository }}/releases"
|
||||||
|
else
|
||||||
|
curl -s -X PATCH -H "Authorization: Bearer ${{ secrets.GHT }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"body\":$CHANGELOG_BODY}" \
|
||||||
|
"https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_EXISTS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Delete existing release assets
|
||||||
|
run: |
|
||||||
|
TAG="${{ steps.tag.outputs.tag }}"
|
||||||
|
RELEASE_ID=$(curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG" | jq -r '.id')
|
||||||
|
if [ "$RELEASE_ID" != "null" ]; then
|
||||||
|
ASSETS=$(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets" | jq -r '.[] | .id')
|
||||||
|
for asset in $ASSETS; do
|
||||||
|
curl -s -X DELETE -H "Authorization: Bearer ${{ secrets.GHT }}" "https://api.github.com/repos/${{ github.repository }}/releases/assets/$asset"
|
||||||
|
done
|
||||||
|
sleep 30
|
||||||
|
fi
|
||||||
|
|
||||||
|
build-musl-toolchain:
|
||||||
|
name: Build musl Cross-Compiler Toolchain
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
target:
|
||||||
|
- x86_64-linux-musl
|
||||||
|
- i686-linux-musl
|
||||||
|
- aarch64-linux-musl
|
||||||
|
- riscv64-linux-musl
|
||||||
|
- mips64-linux-musl
|
||||||
|
- mips64el-linux-musl
|
||||||
|
- powerpc64le-linux-musl
|
||||||
|
- arm-linux-musleabihf
|
||||||
|
steps:
|
||||||
|
- name: Install build dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update -qq
|
||||||
|
sudo apt-get install -y build-essential curl
|
||||||
|
|
||||||
|
- name: Cache musl toolchain
|
||||||
|
id: cache-musl
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: /opt/musl-${{ matrix.target }}
|
||||||
|
key: musl-toolchain-${{ matrix.target }}-v2
|
||||||
|
|
||||||
|
- name: Build musl cross-compiler
|
||||||
|
if: steps.cache-musl.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
# Clone musl-cross-make
|
||||||
|
git clone https://github.com/richfelker/musl-cross-make.git
|
||||||
|
cd musl-cross-make
|
||||||
|
|
||||||
|
# Create config for target
|
||||||
|
cat > config.mak << EOF
|
||||||
|
TARGET = ${{ matrix.target }}
|
||||||
|
OUTPUT = /opt/musl-${{ matrix.target }}
|
||||||
|
COMMON_CONFIG += --disable-nls
|
||||||
|
GCC_CONFIG += --enable-languages=c,c++
|
||||||
|
GCC_CONFIG += --disable-libquadmath --disable-decimal-float
|
||||||
|
GCC_CONFIG += --disable-libitm --disable-fixed-point
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Build the toolchain
|
||||||
|
make -j$(nproc)
|
||||||
|
sudo make install
|
||||||
|
|
||||||
|
# Verify installation
|
||||||
|
ls -la /opt/musl-${{ matrix.target }}/bin/
|
||||||
|
/opt/musl-${{ matrix.target }}/bin/${{ matrix.target }}-gcc --version
|
||||||
|
|
||||||
|
- name: Create toolchain artifact
|
||||||
|
run: |
|
||||||
|
sudo tar -czf musl-${{ matrix.target }}-toolchain.tar.gz -C /opt musl-${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Upload toolchain artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: musl-${{ matrix.target }}-toolchain
|
||||||
|
path: musl-${{ matrix.target }}-toolchain.tar.gz
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
release-binary:
|
||||||
|
name: Release Go Binary
|
||||||
|
needs: [build, build-musl-toolchain]
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- goos: linux
|
||||||
|
goarch: amd64
|
||||||
|
cgo_enabled: "1"
|
||||||
|
musl_target: x86_64-linux-musl
|
||||||
|
cflags: "-O2 -static -fno-stack-protector"
|
||||||
|
ldflags: "-extldflags=-static"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: 386
|
||||||
|
cgo_enabled: "1"
|
||||||
|
musl_target: i686-linux-musl
|
||||||
|
cflags: "-O1 -march=i686 -mtune=generic -fno-stack-protector"
|
||||||
|
ldflags: "-extldflags=-static"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm64
|
||||||
|
cgo_enabled: "1"
|
||||||
|
musl_target: aarch64-linux-musl
|
||||||
|
cflags: "-O1 -fno-stack-protector"
|
||||||
|
ldflags: "-extldflags=-static"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: riscv64
|
||||||
|
cgo_enabled: "1"
|
||||||
|
musl_target: riscv64-linux-musl
|
||||||
|
cflags: "-O1 -fno-stack-protector"
|
||||||
|
ldflags: "-extldflags=-static"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: mips64
|
||||||
|
cgo_enabled: "1"
|
||||||
|
musl_target: mips64-linux-musl
|
||||||
|
cflags: "-O1 -fno-stack-protector"
|
||||||
|
ldflags: "-extldflags=-static"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: mips64le
|
||||||
|
cgo_enabled: "1"
|
||||||
|
musl_target: mips64el-linux-musl
|
||||||
|
cflags: "-O1 -fno-stack-protector"
|
||||||
|
ldflags: "-extldflags=-static"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: ppc64le
|
||||||
|
cgo_enabled: "1"
|
||||||
|
musl_target: powerpc64le-linux-musl
|
||||||
|
cflags: "-O1 -fno-stack-protector"
|
||||||
|
ldflags: "-extldflags=-static"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm
|
||||||
|
cgo_enabled: "1"
|
||||||
|
musl_target: arm-linux-musleabihf
|
||||||
|
cflags: "-O1 -fno-stack-protector"
|
||||||
|
ldflags: "-extldflags=-latomic -static"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: windows
|
||||||
|
goarch: amd64
|
||||||
|
cgo_enabled: "1"
|
||||||
|
cc: x86_64-w64-mingw32-gcc
|
||||||
|
cflags: "-O2 -static-libgcc -static-libstdc++"
|
||||||
|
ldflags: "-extldflags=-static"
|
||||||
|
packages: "build-essential gcc-mingw-w64-x86-64"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: windows
|
||||||
|
goarch: 386
|
||||||
|
cgo_enabled: "1"
|
||||||
|
cc: i686-w64-mingw32-gcc
|
||||||
|
cflags: "-O2 -static-libgcc -static-libstdc++"
|
||||||
|
ldflags: "-extldflags=-static"
|
||||||
|
packages: "build-essential gcc-mingw-w64-i686"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm64
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-s -w"
|
||||||
|
packages: "build-essential"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: darwin
|
||||||
|
goarch: amd64
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-s -w"
|
||||||
|
runner: macos-latest
|
||||||
|
|
||||||
|
- goos: darwin
|
||||||
|
goarch: arm64
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-s -w"
|
||||||
|
runner: macos-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: s390x
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-s -w"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: mips
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-s -w"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: mipsle
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-s -w"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: linux
|
||||||
|
goarch: ppc64
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-s -w"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: amd64
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-s -w"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: arm64
|
||||||
|
cgo_enabled: "0"
|
||||||
|
ldflags: "-s -w"
|
||||||
|
runner: ubuntu-latest
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: 1.24.5
|
||||||
|
|
||||||
|
- name: Configure Git for Private Modules
|
||||||
|
run: |
|
||||||
|
git config --global url."https://${{ secrets.GHT }}@github.com/".insteadOf "https://github.com/"
|
||||||
|
git config --global url."git@github.com:".insteadOf "https://github.com/"
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GHT }}
|
||||||
|
|
||||||
|
- name: Download musl toolchain
|
||||||
|
if: matrix.musl_target != ''
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: musl-${{ matrix.musl_target }}-toolchain
|
||||||
|
|
||||||
|
- name: Setup musl toolchain
|
||||||
|
if: matrix.musl_target != ''
|
||||||
|
run: |
|
||||||
|
sudo tar -xzf musl-${{ matrix.musl_target }}-toolchain.tar.gz -C /opt/
|
||||||
|
echo "/opt/musl-${{ matrix.musl_target }}/bin" >> $GITHUB_PATH
|
||||||
|
|
||||||
|
# Verify toolchain is working
|
||||||
|
/opt/musl-${{ matrix.musl_target }}/bin/${{ matrix.musl_target }}-gcc --version
|
||||||
|
|
||||||
|
# Test compiler
|
||||||
|
echo 'int main() { return 0; }' > test.c
|
||||||
|
/opt/musl-${{ matrix.musl_target }}/bin/${{ matrix.musl_target }}-gcc ${{ matrix.cflags }} test.c -o test
|
||||||
|
rm -f test.c test
|
||||||
|
|
||||||
|
- name: Install cross-compilation tools (non-musl)
|
||||||
|
if: matrix.runner != 'macos-latest' && matrix.musl_target == ''
|
||||||
|
run: |
|
||||||
|
sudo systemctl restart systemd-resolved || true
|
||||||
|
sudo apt-get update -qq || (sleep 10 && sudo apt-get update -qq)
|
||||||
|
|
||||||
|
case "${{ matrix.goos }}-${{ matrix.goarch }}" in
|
||||||
|
windows-amd64|windows-386)
|
||||||
|
for i in 1 2 3; do
|
||||||
|
sudo apt-get install -y build-essential gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 && break || sleep 10
|
||||||
|
done ;;
|
||||||
|
*)
|
||||||
|
sudo systemctl restart systemd-resolved || true
|
||||||
|
for i in 1 2 3; do
|
||||||
|
sudo apt-get install -y build-essential && break || sleep 10
|
||||||
|
done ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
- name: Get latest tag
|
||||||
|
id: tag
|
||||||
|
run: |
|
||||||
|
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0")
|
||||||
|
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||||
|
echo "version=${TAG#v}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Build Binary
|
||||||
|
env:
|
||||||
|
CGO_ENABLED: ${{ matrix.cgo_enabled }}
|
||||||
|
GOOS: ${{ matrix.goos }}
|
||||||
|
GOARCH: ${{ matrix.goarch }}
|
||||||
|
CGO_CFLAGS: ${{ matrix.cflags }}
|
||||||
|
CGO_LDFLAGS: ${{ matrix.ldflags }}
|
||||||
|
run: |
|
||||||
|
go clean -cache -modcache -testcache
|
||||||
|
|
||||||
|
# Set CC based on target
|
||||||
|
if [[ "${{ matrix.musl_target }}" != "" ]]; then
|
||||||
|
export CC="/opt/musl-${{ matrix.musl_target }}/bin/${{ matrix.musl_target }}-gcc"
|
||||||
|
export CXX="/opt/musl-${{ matrix.musl_target }}/bin/${{ matrix.musl_target }}-g++"
|
||||||
|
elif [[ "${{ matrix.cc }}" != "" ]]; then
|
||||||
|
export CC="${{ matrix.cc }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 设置额外的环境变量
|
||||||
|
if [[ -n "${{ matrix.goarm }}" ]]; then
|
||||||
|
export GOARM=${{ matrix.goarm }}
|
||||||
|
fi
|
||||||
|
if [[ -n "${{ matrix.gomips }}" ]]; then
|
||||||
|
export GOMIPS=${{ matrix.gomips }}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 针对 Darwin 的特殊处理
|
||||||
|
if [[ "${{ matrix.cgo_enabled }}" == "1" && "${{ matrix.goos }}" == "darwin" ]]; then
|
||||||
|
if [[ "${{ matrix.goarch }}" == "amd64" ]]; then
|
||||||
|
export CC="x86_64-apple-darwin21.4-clang"
|
||||||
|
export CXX="x86_64-apple-darwin21.4-clang++"
|
||||||
|
elif [[ "${{ matrix.goarch }}" == "arm64" ]]; then
|
||||||
|
export CC="aarch64-apple-darwin21.4-clang"
|
||||||
|
export CXX="aarch64-apple-darwin21.4-clang++"
|
||||||
|
fi
|
||||||
|
export OSXCROSS_ROOT="${OSXCROSS_ROOT}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 清理和准备
|
||||||
|
rm -rf vendor/
|
||||||
|
go mod download
|
||||||
|
go mod tidy
|
||||||
|
mkdir -p bin
|
||||||
|
|
||||||
|
# 设置二进制文件名
|
||||||
|
BINARY_NAME="goecs"
|
||||||
|
if [[ "${{ matrix.goos }}" == "windows" ]]; then
|
||||||
|
BINARY_NAME="${BINARY_NAME}.exe"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 构建 LDFLAGS
|
||||||
|
LDFLAGS="-s -w -X main.version=${{ steps.tag.outputs.version }} -X main.arch=${{ matrix.goarch }}"
|
||||||
|
if [[ "${{ matrix.cgo_enabled }}" == "1" ]]; then
|
||||||
|
LDFLAGS="${LDFLAGS} -checklinkname=0 ${{ matrix.ldflags }}"
|
||||||
|
else
|
||||||
|
LDFLAGS="${LDFLAGS} -checklinkname=0 ${{ matrix.ldflags }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 执行构建
|
||||||
|
echo "Building for GOOS=$GOOS GOARCH=$GOARCH CGO_ENABLED=$CGO_ENABLED"
|
||||||
|
if [[ -n "$CC" ]]; then
|
||||||
|
echo "Using CC=$CC"
|
||||||
|
fi
|
||||||
|
|
||||||
|
go build -a -o bin/$BINARY_NAME -ldflags="$LDFLAGS" -trimpath ./
|
||||||
|
|
||||||
|
# 验证文件是否存在
|
||||||
|
[[ -f "bin/$BINARY_NAME" ]] || exit 1
|
||||||
|
|
||||||
|
# 显示构建信息
|
||||||
|
echo "Built binary: bin/$BINARY_NAME"
|
||||||
|
ls -la bin/
|
||||||
|
if command -v file >/dev/null 2>&1; then
|
||||||
|
file bin/$BINARY_NAME
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Create ZIP archive
|
||||||
|
run: |
|
||||||
|
cd bin
|
||||||
|
BINARY_NAME="goecs"
|
||||||
|
if [[ "${{ matrix.goos }}" == "windows" ]]; then
|
||||||
|
BINARY_NAME="${BINARY_NAME}.exe"
|
||||||
|
fi
|
||||||
|
ZIP_NAME="goecs_${{ matrix.goos }}_${{ matrix.goarch }}"
|
||||||
|
if [[ -n "${{ matrix.goarm }}" ]]; then
|
||||||
|
ZIP_NAME="${ZIP_NAME}v${{ matrix.goarm }}"
|
||||||
|
fi
|
||||||
|
if [[ -n "${{ matrix.gomips }}" ]]; then
|
||||||
|
ZIP_NAME="${ZIP_NAME}_${{ matrix.gomips }}"
|
||||||
|
fi
|
||||||
|
ZIP_NAME="${ZIP_NAME}.zip"
|
||||||
|
zip "$ZIP_NAME" "$BINARY_NAME"
|
||||||
|
|
||||||
|
- name: Upload to Release
|
||||||
|
run: |
|
||||||
|
TAG="${{ steps.tag.outputs.tag }}"
|
||||||
|
RELEASE_ID=$(curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG" | jq -r '.id')
|
||||||
|
cd bin
|
||||||
|
for file in *.zip; do
|
||||||
|
if [[ -f "$file" ]]; then
|
||||||
|
curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" \
|
||||||
|
-H "Content-Type: application/zip" \
|
||||||
|
--data-binary @"$file" \
|
||||||
|
"https://uploads.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=$file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
checksums:
|
||||||
|
name: Generate Checksums
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: release-binary
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Get latest tag
|
||||||
|
id: tag
|
||||||
|
run: |
|
||||||
|
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0")
|
||||||
|
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Download release assets
|
||||||
|
run: |
|
||||||
|
TAG="${{ steps.tag.outputs.tag }}"
|
||||||
|
RELEASE_ID=$(curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG" | jq -r '.id')
|
||||||
|
mkdir -p assets
|
||||||
|
ASSETS=$(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets")
|
||||||
|
echo "$ASSETS" | jq -r '.[] | select(.name | endswith(".zip")) | .browser_download_url' | while read url; do
|
||||||
|
filename=$(basename "$url")
|
||||||
|
curl -L -H "Authorization: Bearer ${{ secrets.GHT }}" "$url" -o "assets/$filename"
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Generate checksums
|
||||||
|
run: |
|
||||||
|
cd assets
|
||||||
|
sha256sum *.zip > checksums.txt
|
||||||
|
if [[ -f "../goecs.sh" ]]; then
|
||||||
|
sha256sum ../goecs.sh >> checksums.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Upload checksums
|
||||||
|
run: |
|
||||||
|
TAG="${{ steps.tag.outputs.tag }}"
|
||||||
|
RELEASE_ID=$(curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG" | jq -r '.id')
|
||||||
|
curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" \
|
||||||
|
-H "Content-Type: text/plain" \
|
||||||
|
--data-binary @assets/checksums.txt \
|
||||||
|
"https://uploads.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=checksums.txt"
|
||||||
|
|
||||||
|
update-script:
|
||||||
|
name: Update Script Version
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: checksums
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Get latest tag
|
||||||
|
id: tag
|
||||||
|
run: |
|
||||||
|
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0")
|
||||||
|
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||||
|
echo "version=${TAG#v}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Update goecs.sh version
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.tag.outputs.version }}"
|
||||||
|
BRANCH="master"
|
||||||
|
git config --global user.name "github-actions[bot]"
|
||||||
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
git config --global --unset url."git@github.com:".insteadOf || true
|
||||||
|
git fetch origin $BRANCH
|
||||||
|
git checkout $BRANCH
|
||||||
|
if [ -f "goecs.sh" ]; then
|
||||||
|
sed -i "s/\(_yellow \"Unable to get version info, using default version \).*\(\".*\)/\1$VERSION\2/" "goecs.sh"
|
||||||
|
sed -i "s/\(ECS_VERSION=\"\).*\(\"\)/\1$VERSION\2/" "goecs.sh"
|
||||||
|
if ! git diff --quiet "goecs.sh"; then
|
||||||
|
git add "goecs.sh"
|
||||||
|
git commit -m "chore: update ECS_VERSION to $VERSION in goecs.sh"
|
||||||
|
git push origin $BRANCH
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GHT }}
|
26
.github/workflows/build_docker.yaml
vendored
26
.github/workflows/build_docker.yaml
vendored
@@ -1,8 +1,10 @@
|
|||||||
name: Build and Push Docker Image
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
workflow_run:
|
||||||
types: [ published ]
|
workflows: ["Build and Release"]
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -26,12 +28,19 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Login to CNB Registry
|
# - name: Login to CNB Registry
|
||||||
|
# uses: docker/login-action@v2
|
||||||
|
# with:
|
||||||
|
# registry: ${{ secrets.CNB_DOCKER_REGISTRY }}
|
||||||
|
# username: ${{ secrets.CNB_USERNAME }}
|
||||||
|
# password: ${{ secrets.CNB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Login to Aliyun Container Registry
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
registry: ${{ secrets.CNB_DOCKER_REGISTRY }}
|
registry: crpi-8tmognxgyb86bm61.cn-guangzhou.personal.cr.aliyuncs.com
|
||||||
username: ${{ secrets.CNB_USERNAME }}
|
username: ${{ secrets.ALIYUN_USERNAME }}
|
||||||
password: ${{ secrets.CNB_TOKEN }}
|
password: ${{ secrets.ALIYUN_PASSWORD }}
|
||||||
|
|
||||||
- name: Build and push Docker images
|
- name: Build and push Docker images
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
@@ -39,8 +48,9 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/riscv64
|
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/riscv64
|
||||||
# linux/mips,linux/mipsle 暂不支持 alpine, linux/s390x 编译卡死
|
# linux/mips,linux/mipsle 暂不支持 alpine, linux/s390x 编译卡死,cnb组织空间不足无法推送
|
||||||
|
# ${{ secrets.CNB_DOCKER_REGISTRY }}/oneclickvirt/ecs:latest
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
${{ secrets.DOCKER_USERNAME }}/goecs:latest
|
${{ secrets.DOCKER_USERNAME }}/goecs:latest
|
||||||
${{ secrets.CNB_DOCKER_REGISTRY }}/oneclickvirt/ecs:latest
|
crpi-8tmognxgyb86bm61.cn-guangzhou.personal.cr.aliyuncs.com/oneclickvirt/ecs:latest
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
name: Public Build
|
name: Public Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
workflow_run:
|
||||||
types: [ published ]
|
workflows: ["Build and Release"]
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -17,7 +19,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.23.4'
|
go-version: '1.24.5'
|
||||||
|
|
||||||
- name: Create public branch
|
- name: Create public branch
|
||||||
run: |
|
run: |
|
||||||
@@ -28,49 +30,21 @@ jobs:
|
|||||||
|
|
||||||
- name: Remove security package references
|
- name: Remove security package references
|
||||||
run: |
|
run: |
|
||||||
# 移除 network 包中对 security 的引用
|
|
||||||
find . -type f -name "*.go" -exec sed -i 's|"github.com/oneclickvirt/security/network"|"github.com/oneclickvirt/basics/network"|g' {} +
|
find . -type f -name "*.go" -exec sed -i 's|"github.com/oneclickvirt/security/network"|"github.com/oneclickvirt/basics/network"|g' {} +
|
||||||
# 修改 back/network/network.go
|
|
||||||
cat > back/network/network.go << 'EOF'
|
|
||||||
package network1
|
|
||||||
|
|
||||||
import "github.com/oneclickvirt/basics/network"
|
|
||||||
|
|
||||||
func NetworkCheck(checkType string, enableSecurityCheck bool, language string) (string, string, error) {
|
|
||||||
ipInfo, _, err := network.NetworkCheck(checkType, false, language)
|
|
||||||
return ipInfo, "", err
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# 修改 utils/utils.go 中的 BasicsAndSecurityCheck 函数
|
|
||||||
sed -i '/SecurityUploadToken/d' utils/utils.go
|
sed -i '/SecurityUploadToken/d' utils/utils.go
|
||||||
sed -i 's|"github.com/oneclickvirt/security/network"|"github.com/oneclickvirt/basics/network"|g' utils/utils.go
|
sed -i 's|"github.com/oneclickvirt/security/network"|"github.com/oneclickvirt/basics/network"|g' utils/utils.go
|
||||||
|
|
||||||
# 在 utils/utils.go 中添加 token 常量(在 import 语句之后)
|
|
||||||
sed -i '/^import/,/^)/{/^)/a\'$'\n''const token = "OvwKx5qgJtf7PZgCKbtyojSU.MTcwMTUxNzY1MTgwMw"'$'\n''}' utils/utils.go
|
sed -i '/^import/,/^)/{/^)/a\'$'\n''const token = "OvwKx5qgJtf7PZgCKbtyojSU.MTcwMTUxNzY1MTgwMw"'$'\n''}' utils/utils.go
|
||||||
|
|
||||||
# 修改 go.mod,移除私有仓库依赖
|
|
||||||
sed -i '/github.com\/oneclickvirt\/security/d' go.mod
|
sed -i '/github.com\/oneclickvirt\/security/d' go.mod
|
||||||
|
|
||||||
# 修改 goecs.go,禁用 security 检测
|
|
||||||
sed -i 's|var securityFlag = flag.Bool("security", true,|var securityFlag = flag.Bool("security", false,|g' goecs.go
|
sed -i 's|var securityFlag = flag.Bool("security", true,|var securityFlag = flag.Bool("security", false,|g' goecs.go
|
||||||
|
|
||||||
# 更新依赖
|
|
||||||
go mod tidy
|
go mod tidy
|
||||||
|
|
||||||
# 修改 README.md 和 README_EN.md 中的敏感信息
|
|
||||||
sed -i 's|但二进制文件编译至 \[securityCheck\].*)|但已开源|g' README.md
|
sed -i 's|但二进制文件编译至 \[securityCheck\].*)|但已开源|g' README.md
|
||||||
sed -i 's|but binary files compiled in \[securityCheck\].*)|but open sourced|g' README_EN.md
|
sed -i 's|but binary files compiled in \[securityCheck\].*)|but open sourced|g' README_EN.md
|
||||||
|
|
||||||
# 修改命令行帮助信息
|
|
||||||
sed -i 's|security.*Enable/Disable security test (default true)|security Enable/Disable security test (default false)|g' README.md
|
sed -i 's|security.*Enable/Disable security test (default true)|security Enable/Disable security test (default false)|g' README.md
|
||||||
sed -i 's|security.*Enable/Disable security test (default true)|security Enable/Disable security test (default false)|g' README_EN.md
|
sed -i 's|security.*Enable/Disable security test (default true)|security Enable/Disable security test (default false)|g' README_EN.md
|
||||||
|
|
||||||
- name: Build and Test
|
- name: Build and Test
|
||||||
run: |
|
run: |
|
||||||
# 构建二进制文件
|
|
||||||
go build -o maintest
|
go build -o maintest
|
||||||
# 测试无菜单模式是否正常运行(禁用 security 检测)
|
|
||||||
./maintest -menu=false -l en -security=false -upload=false || exit 1
|
./maintest -menu=false -l en -security=false -upload=false || exit 1
|
||||||
rm -rf maintest
|
rm -rf maintest
|
||||||
|
|
6
.github/workflows/sync.yaml
vendored
6
.github/workflows/sync.yaml
vendored
@@ -1,8 +1,10 @@
|
|||||||
name: Sync Latest Release
|
name: Sync Latest Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
workflow_run:
|
||||||
types: [published]
|
workflows: ["Build and Release"]
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
@@ -6,9 +6,7 @@ builds:
|
|||||||
env:
|
env:
|
||||||
- CGO_ENABLED=0
|
- CGO_ENABLED=0
|
||||||
ldflags:
|
ldflags:
|
||||||
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||||
flags:
|
|
||||||
- -trimpath
|
|
||||||
goos:
|
goos:
|
||||||
- linux
|
- linux
|
||||||
- windows
|
- windows
|
||||||
@@ -20,6 +18,10 @@ builds:
|
|||||||
- amd64
|
- amd64
|
||||||
- mips
|
- mips
|
||||||
- mipsle
|
- mipsle
|
||||||
|
- mips64
|
||||||
|
- mips64le
|
||||||
|
- ppc64
|
||||||
|
- ppc64le
|
||||||
- s390x
|
- s390x
|
||||||
- riscv64
|
- riscv64
|
||||||
gomips:
|
gomips:
|
||||||
@@ -36,8 +38,6 @@ builds:
|
|||||||
- CXX=o64-clang++
|
- CXX=o64-clang++
|
||||||
ldflags:
|
ldflags:
|
||||||
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||||
flags:
|
|
||||||
- -trimpath
|
|
||||||
goos:
|
goos:
|
||||||
- darwin
|
- darwin
|
||||||
goarch:
|
goarch:
|
||||||
@@ -51,8 +51,6 @@ builds:
|
|||||||
- CXX=oa64-clang++
|
- CXX=oa64-clang++
|
||||||
ldflags:
|
ldflags:
|
||||||
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||||
flags:
|
|
||||||
- -trimpath
|
|
||||||
goos:
|
goos:
|
||||||
- darwin
|
- darwin
|
||||||
goarch:
|
goarch:
|
||||||
|
39
README.md
39
README.md
@@ -1,6 +1,6 @@
|
|||||||
# ECS
|
# ECS
|
||||||
|
|
||||||
[](https://github.com/oneclickvirt/ecs/actions/workflows/main.yaml)
|
[](https://github.com/oneclickvirt/ecs/actions/workflows/build_binary.yaml)
|
||||||
|
|
||||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Foneclickvirt%2Fecs?ref=badge_shield)
|
[](https://app.fossa.com/projects/git%2Bgithub.com%2Foneclickvirt%2Fecs?ref=badge_shield)
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
融合怪测评项目 - GO版本
|
融合怪测评项目 - GO版本
|
||||||
|
|
||||||
(环境安装[非必须]使用shell外无额外shell文件依赖,环境安装只是为了测的更准,极端情况下无环境依赖安装也可全测项目)
|
(仅环境安装[非必须]使用shell外无额外shell文件依赖,环境安装只是为了测的更准,极端情况下无环境依赖安装也可全测项目)
|
||||||
|
|
||||||
如有问题请 [issues](https://github.com/oneclickvirt/ecs/issues) 反馈。
|
如有问题请 [issues](https://github.com/oneclickvirt/ecs/issues) 反馈。
|
||||||
|
|
||||||
@@ -27,19 +27,19 @@ Shell 版本:[https://github.com/spiritLHLS/ecs](https://github.com/spiritLHLS
|
|||||||
## **适配系统和架构**
|
## **适配系统和架构**
|
||||||
|
|
||||||
### **编译与测试支持情况**
|
### **编译与测试支持情况**
|
||||||
| 编译支持的架构 | 测试支持的架构 | 编译支持的系统 | 测试支持的系统 |
|
| 编译支持的架构 | 测试支持的架构 | 编译支持的系统 | 测试支持的系统 |
|
||||||
|---------------------------|-----------|---------|-----------|
|
|---------------------------|--------------|---------------------------|---------------|
|
||||||
| amd64 | amd64 | Linux | Linux |
|
| amd64 | amd64 | Linux | Linux |
|
||||||
| arm | arm | Windows | Windows |
|
| arm64 | arm64 | Windows | Windows |
|
||||||
| arm64 | arm64 | FreeBSD | FreeBSD |
|
| arm | | MacOS(Darwin) | MacOS |
|
||||||
| 386 | 386 | OpenBSD | |
|
| 386 | | FreeBSD | |
|
||||||
| mips | | MacOS | MacOS |
|
| mips,mipsle | | Android | |
|
||||||
| mipsle | | | |
|
| mips64,mips64le | | | |
|
||||||
| s390x | s390x | | |
|
| ppc64,ppc64le | | | |
|
||||||
| riscv64 | | | |
|
| s390x | s390x | | |
|
||||||
|
| riscv64 | | | |
|
||||||
|
|
||||||
|
> 更多架构与系统请自行测试或编译,如有问题请开 issues。
|
||||||
> 更多架构与系统请自行测试,如有问题请开 issues。
|
|
||||||
|
|
||||||
### **待支持的系统**
|
### **待支持的系统**
|
||||||
| 系统 | 说明 |
|
| 系统 | 说明 |
|
||||||
@@ -62,6 +62,7 @@ Shell 版本:[https://github.com/spiritLHLS/ecs](https://github.com/spiritLHLS
|
|||||||
- 三网路由测试:基于 [NTrace-core](https://github.com/nxtrace/NTrace-core),二次开发至 [nt3](https://github.com/oneclickvirt/nt3)
|
- 三网路由测试:基于 [NTrace-core](https://github.com/nxtrace/NTrace-core),二次开发至 [nt3](https://github.com/oneclickvirt/nt3)
|
||||||
- 网速测试:基于 [speedtest.net](https://github.com/spiritLHLS/speedtest.net-CN-ID) 和 [speedtest.cn](https://github.com/spiritLHLS/speedtest.cn-CN-ID) 数据,开发至 [oneclickvirt/speedtest](https://github.com/oneclickvirt/speedtest)
|
- 网速测试:基于 [speedtest.net](https://github.com/spiritLHLS/speedtest.net-CN-ID) 和 [speedtest.cn](https://github.com/spiritLHLS/speedtest.cn-CN-ID) 数据,开发至 [oneclickvirt/speedtest](https://github.com/oneclickvirt/speedtest)
|
||||||
- 三网 Ping 值测试:借鉴 [ecsspeed](https://github.com/spiritLHLS/ecsspeed),二次开发至 [pingtest](https://github.com/oneclickvirt/pingtest)
|
- 三网 Ping 值测试:借鉴 [ecsspeed](https://github.com/spiritLHLS/ecsspeed),二次开发至 [pingtest](https://github.com/oneclickvirt/pingtest)
|
||||||
|
- 支持root或admin环境下测试,支持非root或非admin环境下测试,支持离线环境下进行测试,**暂未**支持无DNS环境下进行测试
|
||||||
|
|
||||||
**本项目初次使用建议查看说明:[跳转](https://github.com/oneclickvirt/ecs/blob/master/README_NEW_USER.md)**
|
**本项目初次使用建议查看说明:[跳转](https://github.com/oneclickvirt/ecs/blob/master/README_NEW_USER.md)**
|
||||||
|
|
||||||
@@ -264,22 +265,24 @@ docker run --rm spiritlhl/goecs:latest -menu=false -l zh
|
|||||||
|
|
||||||
使用Docker执行测试,硬件测试会有一些偏差和虚拟化架构判断失效,还是推荐直接测试而不使用Docker测试。
|
使用Docker执行测试,硬件测试会有一些偏差和虚拟化架构判断失效,还是推荐直接测试而不使用Docker测试。
|
||||||
|
|
||||||
国内镜像地址:https://cnb.cool/oneclickvirt/ecs/-/packages/docker/ecs
|
国内阿里云镜像加速
|
||||||
|
|
||||||
请确保执行下述命令前本机已安装Docker
|
请确保执行下述命令前本机已安装Docker
|
||||||
|
|
||||||
特权模式+host网络
|
特权模式+host网络
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker run --rm --privileged --network host docker.cnb.cool/oneclickvirt/ecs:latest -menu=false -l zh
|
docker run --rm --privileged --network host crpi-8tmognxgyb86bm61.cn-guangzhou.personal.cr.aliyuncs.com/oneclickvirt/ecs:latest -menu=false -l zh
|
||||||
```
|
```
|
||||||
|
|
||||||
非特权模式+非host网络
|
非特权模式+非host网络
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker run --rm docker.cnb.cool/oneclickvirt/ecs:latest -menu=false -l zh
|
docker run --rm crpi-8tmognxgyb86bm61.cn-guangzhou.personal.cr.aliyuncs.com/oneclickvirt/ecs:latest -menu=false -l zh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
实际上还有CNB镜像地址 https://cnb.cool/oneclickvirt/ecs/-/packages/docker/ecs 但很可惜组织空间不足无法推送了,更推荐使用阿里云镜像加速
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -368,7 +371,7 @@ GOOS=darwin GOARCH=amd64 go build -o goecs_darwin
|
|||||||
|
|
||||||
## 致谢
|
## 致谢
|
||||||
|
|
||||||
感谢 [he.net](https://he.net) [bgp.tools](https://bgp.tools) [ipinfo.io](https://ipinfo.io) [ip.sb](https://ip.sb) [cheervision.co](https://cheervision.co) [scamalytics.com](https://scamalytics.com) [abuseipdb.com](https://www.abuseipdb.com/) [virustotal.com](https://www.virustotal.com/) [ip2location.com](https://ip2location.com/) [ip-api.com](https://ip-api.com) [ipregistry.co](https://ipregistry.co/) [ipdata.co](https://ipdata.co/) [ipgeolocation.io](https://ipgeolocation.io) [ipwhois.io](https://ipwhois.io) [ipapi.com](https://ipapi.com/) [ipapi.is](https://ipapi.is/) [ipqualityscore.com](https://www.ipqualityscore.com/) [bigdatacloud.com](https://www.bigdatacloud.com/) 等网站提供的API进行检测,感谢互联网各网站提供的查询资源
|
感谢 [he.net](https://he.net) [bgp.tools](https://bgp.tools) [ipinfo.io](https://ipinfo.io) [maxmind.com](https://www.maxmind.com/en/home) [cloudflare.com](https://www.cloudflare.com/) [ip.sb](https://ip.sb) [scamalytics.com](https://scamalytics.com) [abuseipdb.com](https://www.abuseipdb.com/) [ip2location.com](https://ip2location.com/) [ip-api.com](https://ip-api.com) [ipregistry.co](https://ipregistry.co/) [ipdata.co](https://ipdata.co/) [ipgeolocation.io](https://ipgeolocation.io) [ipwhois.io](https://ipwhois.io) [ipapi.com](https://ipapi.com/) [ipapi.is](https://ipapi.is/) [ipqualityscore.com](https://www.ipqualityscore.com/) [bigdatacloud.com](https://www.bigdatacloud.com/) [dkly.net](https://data.dkly.net) [virustotal.com](https://www.virustotal.com/) 等网站提供的API进行检测,感谢互联网各网站提供的查询资源
|
||||||
|
|
||||||
感谢
|
感谢
|
||||||
|
|
||||||
|
18
README_EN.md
18
README_EN.md
@@ -1,6 +1,6 @@
|
|||||||
# ecs
|
# ecs
|
||||||
|
|
||||||
[](https://github.com/oneclickvirt/ecs/actions/workflows/main.yaml)
|
[](https://github.com/oneclickvirt/ecs/actions/workflows/build_binary.yaml)
|
||||||
|
|
||||||
[](https://hits.spiritlhl.net)
|
[](https://hits.spiritlhl.net)
|
||||||
|
|
||||||
@@ -28,15 +28,16 @@ Shell version: [https://github.com/spiritLHLS/ecs/blob/main/README_EN.md](https:
|
|||||||
| Supported for Compilation | Tested on | Supported OS for Compilation | Tested OS |
|
| Supported for Compilation | Tested on | Supported OS for Compilation | Tested OS |
|
||||||
|---------------------------|-----------|------------------------------|-----------|
|
|---------------------------|-----------|------------------------------|-----------|
|
||||||
| amd64 | amd64 | Linux | Linux |
|
| amd64 | amd64 | Linux | Linux |
|
||||||
| arm | arm | Windows | Windows |
|
| arm64 | arm64 | Windows | Windows |
|
||||||
| arm64 | arm64 | FreeBSD | FreeBSD |
|
| arm | | MacOS(Darwin) | MacOS |
|
||||||
| 386 | 386 | OpenBSD | |
|
| 386 | | FreeBSD | |
|
||||||
| mips | | MacOS | MacOS |
|
| mips,mipsle | | Android | |
|
||||||
| mipsle | | | |
|
| mips64,mips64le | | | |
|
||||||
|
| ppc64,ppc64le | | | |
|
||||||
| s390x | s390x | | |
|
| s390x | s390x | | |
|
||||||
| riscv64 | | | |
|
| riscv64 | | | |
|
||||||
|
|
||||||
> Please test additional architectures and systems yourself. If you encounter any issues, please open an issue.
|
> For more information about the architecture and system, please test or compile it yourself, and open issues if you have any questions.
|
||||||
|
|
||||||
### **Systems Pending Support**
|
### **Systems Pending Support**
|
||||||
| OS | Notes |
|
| OS | Notes |
|
||||||
@@ -58,6 +59,7 @@ Shell version: [https://github.com/spiritLHLS/ecs/blob/main/README_EN.md](https:
|
|||||||
- Three-network route test: Modified from [NTrace-core](https://github.com/nxtrace/NTrace-core) to [nt3](https://github.com/oneclickvirt/nt3)
|
- Three-network route test: Modified from [NTrace-core](https://github.com/nxtrace/NTrace-core) to [nt3](https://github.com/oneclickvirt/nt3)
|
||||||
- Speed test: Based on data from [speedtest.net](https://github.com/spiritLHLS/speedtest.net-CN-ID) and [speedtest.cn](https://github.com/spiritLHLS/speedtest.cn-CN-ID), developed to [oneclickvirt/speedtest](https://github.com/oneclickvirt/speedtest)
|
- Speed test: Based on data from [speedtest.net](https://github.com/spiritLHLS/speedtest.net-CN-ID) and [speedtest.cn](https://github.com/spiritLHLS/speedtest.cn-CN-ID), developed to [oneclickvirt/speedtest](https://github.com/oneclickvirt/speedtest)
|
||||||
- Three-network Ping test: Modified from [ecsspeed](https://github.com/spiritLHLS/ecsspeed) to [pingtest](https://github.com/oneclickvirt/pingtest)
|
- Three-network Ping test: Modified from [ecsspeed](https://github.com/spiritLHLS/ecsspeed) to [pingtest](https://github.com/oneclickvirt/pingtest)
|
||||||
|
- Support root or admin environment testing, support non-root or non-admin environment testing, support offline environment for testing, not support no DNS environment for testing
|
||||||
|
|
||||||
**For first-time users of this project, it is recommended to check the instructions: [Jump to](https://github.com/oneclickvirt/ecs/blob/master/README_NEW_USER.md)**
|
**For first-time users of this project, it is recommended to check the instructions: [Jump to](https://github.com/oneclickvirt/ecs/blob/master/README_NEW_USER.md)**
|
||||||
|
|
||||||
@@ -362,7 +364,7 @@ Note that `goecs` allows you to specify CPU test method via parameters. The defa
|
|||||||
|
|
||||||
## Thanks
|
## Thanks
|
||||||
|
|
||||||
Thank [he.net](https://he.net) [bgp.tools](https://bgp.tools) [ipinfo.io](https://ipinfo.io) [ip.sb](https://ip.sb) [cheervision.co](https://cheervision.co) [scamalytics.com](https://scamalytics.com) [abuseipdb.com](https://www.abuseipdb.com/) [virustotal.com](https://www.virustotal.com/) [ip2location.com](https://ip2location.com/) [ip-api.com](https://ip-api.com) [ipregistry.co](https://ipregistry.co/) [ipdata.co](https://ipdata.co/) [ipgeolocation.io](https://ipgeolocation.io) [ipwhois.io](https://ipwhois.io) [ipapi.com](https://ipapi.com/) [ipapi.is](https://ipapi.is/) [ipqualityscore.com](https://www.ipqualityscore.com/) [bigdatacloud.com](https://www.bigdatacloud.com/) and others for providing APIs for testing, and thanks to various websites on the Internet for providing query resources.
|
Thank [he.net](https://he.net) [bgp.tools](https://bgp.tools) [ipinfo.io](https://ipinfo.io) [maxmind.com](https://www.maxmind.com/en/home) [cloudflare.com](https://www.cloudflare.com/) [ip.sb](https://ip.sb) [scamalytics.com](https://scamalytics.com) [abuseipdb.com](https://www.abuseipdb.com/) [ip2location.com](https://ip2location.com/) [ip-api.com](https://ip-api.com) [ipregistry.co](https://ipregistry.co/) [ipdata.co](https://ipdata.co/) [ipgeolocation.io](https://ipgeolocation.io) [ipwhois.io](https://ipwhois.io) [ipapi.com](https://ipapi.com/) [ipapi.is](https://ipapi.is/) [ipqualityscore.com](https://www.ipqualityscore.com/) [bigdatacloud.com](https://www.bigdatacloud.com/) [dkly.net](https://data.dkly.net) [virustotal.com](https://www.virustotal.com/) and others for providing APIs for testing, and thanks to various websites on the Internet for providing query resources.
|
||||||
|
|
||||||
Thank
|
Thank
|
||||||
|
|
||||||
|
@@ -250,9 +250,9 @@ Load: Displays system load.
|
|||||||
|
|
||||||
Virtualization Architecture: Shows what virtualization architecture the host machine uses. Generally speaking, the recommended order is `Dedicated > KVM > Xen` virtualization. Other virtualization will have performance losses, leading to shared/degraded performance during use. However, this is not definitive. Only dedicated servers have completely independent resource usage; other virtualization methods basically all have resource sharing, depending on whether the host machine seller has a conscience. The specific performance merits still depend on the specialized tests that follow.
|
Virtualization Architecture: Shows what virtualization architecture the host machine uses. Generally speaking, the recommended order is `Dedicated > KVM > Xen` virtualization. Other virtualization will have performance losses, leading to shared/degraded performance during use. However, this is not definitive. Only dedicated servers have completely independent resource usage; other virtualization methods basically all have resource sharing, depending on whether the host machine seller has a conscience. The specific performance merits still depend on the specialized tests that follow.
|
||||||
|
|
||||||
NAT Type: Displays NAT type. Specifically recommended in order: `Full Cone > Restricted Cone > Port Restricted Cone > Symmetric`. When not detectable, it will show `Inconclusive`. Generally speaking, if you're not using it for special purposes (related to special proxy and real-time communication needs), you don't need to pay attention to this metric.
|
NAT Type: Displays NAT type. Specifically recommended in order: ```Full Cone > Restricted Cone > Port Restricted Cone > Symmetric```. When not detectable, it will show ```Inconclusive```. Generally speaking, if you're not using it for special purposes (related to special proxy and real-time communication needs), you don't need to pay attention to this metric.
|
||||||
|
|
||||||
TCP Acceleration Method: Generally this is the `cubic/bbr` congestion control protocol. Generally speaking, using bbr for proxy servers can improve network speed; for ordinary purposes, you don't need to pay attention to this indicator.
|
TCP Acceleration Method: Generally this is the ```cubic/bbr``` congestion control protocol. Generally speaking, using bbr for proxy servers can improve network speed; for ordinary purposes, you don't need to pay attention to this indicator.
|
||||||
|
|
||||||
IPv4/IPv6 ASN: Displays the ASN organization ID and name that the host machine's IP belongs to. The same IDC may have multiple ASNs, and an ASN may have multiple vendors selling servers with different IP segments. The specific upstream and downstream relationships are complex and can be further viewed using bgp.tool.
|
IPv4/IPv6 ASN: Displays the ASN organization ID and name that the host machine's IP belongs to. The same IDC may have multiple ASNs, and an ASN may have multiple vendors selling servers with different IP segments. The specific upstream and downstream relationships are complex and can be further viewed using bgp.tool.
|
||||||
|
|
||||||
@@ -273,17 +273,17 @@ Supports selecting `GeekBench` and `Sysbench` for testing through command line p
|
|||||||
| Test Content | Only tests computational performance, based on prime number calculation | Covers multiple performance tests, weighted score calculation, but some tests are not commonly used in practice |
|
| Test Content | Only tests computational performance, based on prime number calculation | Covers multiple performance tests, weighted score calculation, but some tests are not commonly used in practice |
|
||||||
| Applicable Scenarios | Suitable for quick testing, only tests computational performance | Suitable for comprehensive testing |
|
| Applicable Scenarios | Suitable for quick testing, only tests computational performance | Suitable for comprehensive testing |
|
||||||
|
|
||||||
By default, `Sysbench` is used for testing, with the baseline roughly as follows:
|
By default, ```Sysbench``` is used for testing, with the baseline roughly as follows:
|
||||||
|
|
||||||
CPU test single-core `Sysbench` scores above 5000 can be considered first tier, 4000 to 5000 points second tier, with roughly one tier per 1000 points.
|
CPU test single-core ```Sysbench``` scores above 5000 can be considered first tier, 4000 to 5000 points second tier, with roughly one tier per 1000 points.
|
||||||
|
|
||||||
AMD's 7950x single-core full performance score is around 6500, AMD's 5950x single-core full performance score is around 5700, Intel's ordinary CPUs (E5 series, etc.) are around 1000~800, and single-core CPUs scoring below 500 can be said to have relatively poor performance.
|
AMD's 7950x single-core full performance score is around 6500, AMD's 5950x single-core full performance score is around 5700, Intel's ordinary CPUs (E5 series, etc.) are around 1000~800, and single-core CPUs scoring below 500 can be said to have relatively poor performance.
|
||||||
|
|
||||||
Sometimes multi-core scores are the same as single-core scores, proving that the vendor is limiting program concurrent use of CPU, a typical example being Tencent Cloud.
|
Sometimes multi-core scores are the same as single-core scores, proving that the vendor is limiting program concurrent use of CPU, a typical example being Tencent Cloud.
|
||||||
|
|
||||||
Benchmarks for ```Sysbench`` can be found in the [CPU Performance Ladder For Sysbench](https://sysbench.spiritlhl.net/) ladder chart, with specific scores regardless of the version of sysbench tested.
|
Benchmarks for ```Sysbench``` can be found in the [CPU Performance Ladder For Sysbench](https://sysbench.spiritlhl.net/) ladder chart, with specific scores regardless of the version of sysbench tested.
|
||||||
|
|
||||||
For `GeekBench` baselines, see the [official website](https://browser.geekbench.com/processor-benchmarks/) ladder chart. Specific scores differ for each `GeekBench` version, so note which `GeekBench` version is being used when testing.
|
For ```GeekBench``` baselines, see the [official website](https://browser.geekbench.com/processor-benchmarks/) ladder chart. Specific scores differ for each ```GeekBench``` version, so note which ```GeekBench``` version is being used when testing.
|
||||||
|
|
||||||
As an additional note, many things tested by `GeekBench` are not actually used in server usage processes, so the test is for reference only. Of course, `Sysbench` is very incomplete, but it can roughly compare CPU performance based on the most basic computational performance.
|
As an additional note, many things tested by `GeekBench` are not actually used in server usage processes, so the test is for reference only. Of course, `Sysbench` is very incomplete, but it can roughly compare CPU performance based on the most basic computational performance.
|
||||||
|
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
package cputest
|
package cputest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/oneclickvirt/cputest/cpu"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/oneclickvirt/cputest/cpu"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CpuTest(language, testMethod, testThread string) {
|
func CpuTest(language, testMethod, testThread string) (realTestMethod, res string) {
|
||||||
var res string
|
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
if testMethod != "winsat" && testMethod != "" {
|
if testMethod != "winsat" && testMethod != "" {
|
||||||
res = "Detected host is Windows, using Winsat for testing.\n"
|
// res = "Detected host is Windows, using Winsat for testing.\n"
|
||||||
|
realTestMethod = "winsat"
|
||||||
}
|
}
|
||||||
res += cpu.WinsatTest(language, testThread)
|
res += cpu.WinsatTest(language, testThread)
|
||||||
} else {
|
} else {
|
||||||
@@ -19,21 +19,28 @@ func CpuTest(language, testMethod, testThread string) {
|
|||||||
case "sysbench":
|
case "sysbench":
|
||||||
res = cpu.SysBenchTest(language, testThread)
|
res = cpu.SysBenchTest(language, testThread)
|
||||||
if res == "" {
|
if res == "" {
|
||||||
res = "Sysbench test failed, switching to Geekbench for testing.\n"
|
// res = "Sysbench test failed, switching to Geekbench for testing.\n"
|
||||||
|
realTestMethod = "geekbench"
|
||||||
res += cpu.GeekBenchTest(language, testThread)
|
res += cpu.GeekBenchTest(language, testThread)
|
||||||
|
} else {
|
||||||
|
realTestMethod = "sysbench"
|
||||||
}
|
}
|
||||||
case "geekbench":
|
case "geekbench":
|
||||||
res = cpu.GeekBenchTest(language, testThread)
|
res = cpu.GeekBenchTest(language, testThread)
|
||||||
if res == "" {
|
if res == "" {
|
||||||
res = "Geekbench test failed, switching to Sysbench for testing.\n"
|
// res = "Geekbench test failed, switching to Sysbench for testing.\n"
|
||||||
|
realTestMethod = "sysbench"
|
||||||
res += cpu.SysBenchTest(language, testThread)
|
res += cpu.SysBenchTest(language, testThread)
|
||||||
|
} else {
|
||||||
|
realTestMethod = "geekbench"
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
res = "Invalid test method specified.\n"
|
res = "Invalid test method specified.\n"
|
||||||
|
realTestMethod = "null"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !strings.Contains(res, "\n") && res != "" {
|
if !strings.Contains(res, "\n") && res != "" {
|
||||||
res += "\n"
|
res += "\n"
|
||||||
}
|
}
|
||||||
fmt.Print(res)
|
return
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
package cputest
|
package cputest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test(t *testing.T) {
|
func Test(t *testing.T) {
|
||||||
CpuTest("zh", "sysbench", "1")
|
_, res := CpuTest("zh", "sysbench", "1")
|
||||||
|
fmt.Print(res)
|
||||||
}
|
}
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
package disktest
|
package disktest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/oneclickvirt/disktest/disk"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/oneclickvirt/disktest/disk"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DiskTest(language, testMethod, testPath string, isMultiCheck bool, autoChange bool) {
|
func DiskTest(language, testMethod, testPath string, isMultiCheck bool, autoChange bool) (realTestMethod, res string) {
|
||||||
var res string
|
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
if testMethod != "winsat" && testMethod != "" {
|
if testMethod != "winsat" && testMethod != "" {
|
||||||
res = "Detected host is Windows, using Winsat for testing.\n"
|
// res = "Detected host is Windows, using Winsat for testing.\n"
|
||||||
|
realTestMethod = "winsat"
|
||||||
}
|
}
|
||||||
res = disk.WinsatTest(language, isMultiCheck, testPath)
|
res = disk.WinsatTest(language, isMultiCheck, testPath)
|
||||||
} else {
|
} else {
|
||||||
@@ -19,24 +19,29 @@ func DiskTest(language, testMethod, testPath string, isMultiCheck bool, autoChan
|
|||||||
case "fio":
|
case "fio":
|
||||||
res = disk.FioTest(language, isMultiCheck, testPath)
|
res = disk.FioTest(language, isMultiCheck, testPath)
|
||||||
if res == "" && autoChange {
|
if res == "" && autoChange {
|
||||||
res = "Fio test failed, switching to DD for testing.\n"
|
// res = "Fio test failed, switching to DD for testing.\n"
|
||||||
res += disk.DDTest(language, isMultiCheck, testPath)
|
res += disk.DDTest(language, isMultiCheck, testPath)
|
||||||
|
realTestMethod = "dd"
|
||||||
|
} else {
|
||||||
|
realTestMethod = "fio"
|
||||||
}
|
}
|
||||||
case "dd":
|
case "dd":
|
||||||
res = disk.DDTest(language, isMultiCheck, testPath)
|
res = disk.DDTest(language, isMultiCheck, testPath)
|
||||||
if res == "" && autoChange {
|
if res == "" && autoChange {
|
||||||
res = "DD test failed, switching to Fio for testing.\n"
|
// res = "DD test failed, switching to Fio for testing.\n"
|
||||||
res += disk.FioTest(language, isMultiCheck, testPath)
|
res += disk.FioTest(language, isMultiCheck, testPath)
|
||||||
|
realTestMethod = "fio"
|
||||||
|
} else {
|
||||||
|
realTestMethod = "dd"
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
res = "Unsupported test method specified, switching to DD for testing.\n"
|
// res = "Unsupported test method specified, switching to DD for testing.\n"
|
||||||
res += disk.DDTest(language, isMultiCheck, testPath)
|
res += disk.DDTest(language, isMultiCheck, testPath)
|
||||||
|
realTestMethod = "dd"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//fmt.Println("--------------------------------------------------")
|
|
||||||
if !strings.Contains(res, "\n") && res != "" {
|
if !strings.Contains(res, "\n") && res != "" {
|
||||||
res += "\n"
|
res += "\n"
|
||||||
}
|
}
|
||||||
fmt.Printf("%s", res)
|
return
|
||||||
//fmt.Println("--------------------------------------------------")
|
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,11 @@
|
|||||||
package disktest
|
package disktest
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
func TestDiskIoTest(t *testing.T) {
|
func TestDiskIoTest(t *testing.T) {
|
||||||
DiskTest("zh", "sysbench", "", false, false)
|
_, res := DiskTest("zh", "sysbench", "", false, false)
|
||||||
|
fmt.Print(res)
|
||||||
}
|
}
|
||||||
|
14
go.mod
14
go.mod
@@ -1,24 +1,22 @@
|
|||||||
module github.com/oneclickvirt/ecs
|
module github.com/oneclickvirt/ecs
|
||||||
|
|
||||||
go 1.24.1
|
go 1.24.5
|
||||||
|
|
||||||
toolchain go1.24.2
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/imroc/req/v3 v3.50.0
|
github.com/imroc/req/v3 v3.50.0
|
||||||
github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841
|
github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841
|
||||||
github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053
|
github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053
|
||||||
github.com/oneclickvirt/backtrace v0.0.5-20250629024536
|
github.com/oneclickvirt/backtrace v0.0.5-20250629024536
|
||||||
github.com/oneclickvirt/basics v0.0.13-20250629023612
|
github.com/oneclickvirt/basics v0.0.15-20250726093106
|
||||||
github.com/oneclickvirt/cputest v0.0.10-20250404151448
|
github.com/oneclickvirt/cputest v0.0.12-20250720122317
|
||||||
github.com/oneclickvirt/defaultset v0.0.2-20240624082446
|
github.com/oneclickvirt/defaultset v0.0.2-20240624082446
|
||||||
github.com/oneclickvirt/disktest v0.0.8-20250701092629
|
github.com/oneclickvirt/disktest v0.0.8-20250701092629
|
||||||
github.com/oneclickvirt/gostun v0.0.3-20250329105202
|
github.com/oneclickvirt/gostun v0.0.5-20250722144757
|
||||||
github.com/oneclickvirt/memorytest v0.0.6-20250630141424.0.20250701113027-9edfc91f68e6
|
github.com/oneclickvirt/memorytest v0.0.9-20250720135728
|
||||||
github.com/oneclickvirt/nt3 v0.0.5-20250416131047
|
github.com/oneclickvirt/nt3 v0.0.5-20250416131047
|
||||||
github.com/oneclickvirt/pingtest v0.0.8-20250701125637
|
github.com/oneclickvirt/pingtest v0.0.8-20250701125637
|
||||||
github.com/oneclickvirt/portchecker v0.0.3-20250329125750
|
github.com/oneclickvirt/portchecker v0.0.3-20250329125750
|
||||||
github.com/oneclickvirt/security v0.0.4-20250629033626
|
github.com/oneclickvirt/security v0.0.6-20250726094444
|
||||||
github.com/oneclickvirt/speedtest v0.0.10-20250701123931
|
github.com/oneclickvirt/speedtest v0.0.10-20250701123931
|
||||||
)
|
)
|
||||||
|
|
||||||
|
20
go.sum
20
go.sum
@@ -103,10 +103,10 @@ github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053 h1:Ug8kySZR1weRUcsnGO
|
|||||||
github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053/go.mod h1:yXWIZB6iLS88pEd9m4QJi1GENn+7I91zA72y5ONz2Oc=
|
github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053/go.mod h1:yXWIZB6iLS88pEd9m4QJi1GENn+7I91zA72y5ONz2Oc=
|
||||||
github.com/oneclickvirt/backtrace v0.0.5-20250629024536 h1:caHCa0DHmbYWBFN1bqKxpvPnN0wOxDEqJv1VDvDdLWs=
|
github.com/oneclickvirt/backtrace v0.0.5-20250629024536 h1:caHCa0DHmbYWBFN1bqKxpvPnN0wOxDEqJv1VDvDdLWs=
|
||||||
github.com/oneclickvirt/backtrace v0.0.5-20250629024536/go.mod h1:5AH00bo41hH3d2/JVuCTlBkZUs3AXX4nlKVXb6piZcI=
|
github.com/oneclickvirt/backtrace v0.0.5-20250629024536/go.mod h1:5AH00bo41hH3d2/JVuCTlBkZUs3AXX4nlKVXb6piZcI=
|
||||||
github.com/oneclickvirt/basics v0.0.13-20250629023612 h1:cQg+cGBt2NMRrjhJPH+CbevZrwtMU8pIZIY2Lp6zmt4=
|
github.com/oneclickvirt/basics v0.0.15-20250726093106 h1:FXCBa3xJLf0eotMoOghEEicRjsHuWFn4AePDt3NBpls=
|
||||||
github.com/oneclickvirt/basics v0.0.13-20250629023612/go.mod h1:yN1IEOXN6v/GJqJSA70Pooo6nXBI/6rq72vTY72wJMQ=
|
github.com/oneclickvirt/basics v0.0.15-20250726093106/go.mod h1:vAUF4VBvMUf1Uy4DBMa2Zim3x4BUN1KYzqTuec2O53I=
|
||||||
github.com/oneclickvirt/cputest v0.0.10-20250404151448 h1:ovGtCwFXG0qmpyNDRqcNDIiAmhrtemCjIUXTJ1fPH0o=
|
github.com/oneclickvirt/cputest v0.0.12-20250720122317 h1:toiwAK1hZE5b8klu2mOQ7J4sv5yV9lpPKwgPahfRYBQ=
|
||||||
github.com/oneclickvirt/cputest v0.0.10-20250404151448/go.mod h1:MmaHN9+XMntI3rLycwj8Ne31fG18IfNoa8N2utDK1CY=
|
github.com/oneclickvirt/cputest v0.0.12-20250720122317/go.mod h1:vjlH8tkPFft1tlLOpeNskXVvurxkHaJ3+dgFxQGLXY4=
|
||||||
github.com/oneclickvirt/dd v0.0.2-20250701085922 h1:WiWZwcnCPhRc8hLZdvkjD2kOEpnqn1S31z1j0x3V4l0=
|
github.com/oneclickvirt/dd v0.0.2-20250701085922 h1:WiWZwcnCPhRc8hLZdvkjD2kOEpnqn1S31z1j0x3V4l0=
|
||||||
github.com/oneclickvirt/dd v0.0.2-20250701085922/go.mod h1:tImu9sPTkLWo2tf1dEN1xQzrylWKauj9hbU8PHfyAeU=
|
github.com/oneclickvirt/dd v0.0.2-20250701085922/go.mod h1:tImu9sPTkLWo2tf1dEN1xQzrylWKauj9hbU8PHfyAeU=
|
||||||
github.com/oneclickvirt/defaultset v0.0.2-20240624082446 h1:5Pg3mK/u/vQvSz7anu0nxzrNdELi/AcDAU1mMsmPzyc=
|
github.com/oneclickvirt/defaultset v0.0.2-20240624082446 h1:5Pg3mK/u/vQvSz7anu0nxzrNdELi/AcDAU1mMsmPzyc=
|
||||||
@@ -115,20 +115,20 @@ github.com/oneclickvirt/disktest v0.0.8-20250701092629 h1:B/gA6SOr4qL5pQmVpHl9m5
|
|||||||
github.com/oneclickvirt/disktest v0.0.8-20250701092629/go.mod h1:6YCvGr+Z0tvcP4Ue8bezZqm/GqS/dSyEnSUhvS3Q03o=
|
github.com/oneclickvirt/disktest v0.0.8-20250701092629/go.mod h1:6YCvGr+Z0tvcP4Ue8bezZqm/GqS/dSyEnSUhvS3Q03o=
|
||||||
github.com/oneclickvirt/fio v0.0.2-20250701085933 h1:4P7QcOTxbqyx5DhHdFvyeRSsdNajSo9l/H2XK0vICIc=
|
github.com/oneclickvirt/fio v0.0.2-20250701085933 h1:4P7QcOTxbqyx5DhHdFvyeRSsdNajSo9l/H2XK0vICIc=
|
||||||
github.com/oneclickvirt/fio v0.0.2-20250701085933/go.mod h1:NIq+XYTey68KNERGIy/oRDlzpwLzBVoHOCiqX8didsE=
|
github.com/oneclickvirt/fio v0.0.2-20250701085933/go.mod h1:NIq+XYTey68KNERGIy/oRDlzpwLzBVoHOCiqX8didsE=
|
||||||
github.com/oneclickvirt/gostun v0.0.3-20250329105202 h1:aJ6E91Lp94lq8iWRcCaxpXTjqOOaWvufr5oras6cFtM=
|
github.com/oneclickvirt/gostun v0.0.5-20250722144757 h1:RCEouk5WIJoF52JfsC60Zkqz66JY0JQKrhfd9kqP1OI=
|
||||||
github.com/oneclickvirt/gostun v0.0.3-20250329105202/go.mod h1:f7DPEXAxbmwXSW33dbxtb0/KzqvOBWhTs2Or5xBerQA=
|
github.com/oneclickvirt/gostun v0.0.5-20250722144757/go.mod h1:f7DPEXAxbmwXSW33dbxtb0/KzqvOBWhTs2Or5xBerQA=
|
||||||
github.com/oneclickvirt/mbw v0.0.1-20250630140849 h1:p6RMhOPBnQKAm9+VEQ2axAFsidrdSdrhXMyheIyv2a8=
|
github.com/oneclickvirt/mbw v0.0.1-20250630140849 h1:p6RMhOPBnQKAm9+VEQ2axAFsidrdSdrhXMyheIyv2a8=
|
||||||
github.com/oneclickvirt/mbw v0.0.1-20250630140849/go.mod h1:0Vq6NRpyLmGUdfHfL3uDcFsuZhi7KlG+OCs5ky2757Y=
|
github.com/oneclickvirt/mbw v0.0.1-20250630140849/go.mod h1:0Vq6NRpyLmGUdfHfL3uDcFsuZhi7KlG+OCs5ky2757Y=
|
||||||
github.com/oneclickvirt/memorytest v0.0.6-20250630141424.0.20250701113027-9edfc91f68e6 h1:78/eMk+FGeDxxpKgkTb4GF5KJe76y8UW7Htcwm2hF9I=
|
github.com/oneclickvirt/memorytest v0.0.9-20250720135728 h1:RusZfaESDXK+k5YYfVXTCW5zLeQEd/dYY80a6xievE0=
|
||||||
github.com/oneclickvirt/memorytest v0.0.6-20250630141424.0.20250701113027-9edfc91f68e6/go.mod h1:7xMacjQobvFAtODht2hxTsB9hM2IFS7vZk3gxx+bsjo=
|
github.com/oneclickvirt/memorytest v0.0.9-20250720135728/go.mod h1:7xMacjQobvFAtODht2hxTsB9hM2IFS7vZk3gxx+bsjo=
|
||||||
github.com/oneclickvirt/nt3 v0.0.5-20250416131047 h1:KL0xowq19cW+FMBGMJxdqpRNoeyR+eEmb+jYSubmlTk=
|
github.com/oneclickvirt/nt3 v0.0.5-20250416131047 h1:KL0xowq19cW+FMBGMJxdqpRNoeyR+eEmb+jYSubmlTk=
|
||||||
github.com/oneclickvirt/nt3 v0.0.5-20250416131047/go.mod h1:CVsDJEaIdyyZHn3WKbhU8Wn6GOfmBNvJlC/dDLRqcSQ=
|
github.com/oneclickvirt/nt3 v0.0.5-20250416131047/go.mod h1:CVsDJEaIdyyZHn3WKbhU8Wn6GOfmBNvJlC/dDLRqcSQ=
|
||||||
github.com/oneclickvirt/pingtest v0.0.8-20250701125637 h1:J28Ai5miTq1J0I4gdT8rewJSd3LwzD90L/bNiiaKfHM=
|
github.com/oneclickvirt/pingtest v0.0.8-20250701125637 h1:J28Ai5miTq1J0I4gdT8rewJSd3LwzD90L/bNiiaKfHM=
|
||||||
github.com/oneclickvirt/pingtest v0.0.8-20250701125637/go.mod h1:d3Ntx5m9lMll3a/k3+2B+5emj//vgDh4/NHTxs2qQE8=
|
github.com/oneclickvirt/pingtest v0.0.8-20250701125637/go.mod h1:d3Ntx5m9lMll3a/k3+2B+5emj//vgDh4/NHTxs2qQE8=
|
||||||
github.com/oneclickvirt/portchecker v0.0.3-20250329125750 h1:TTNL0pnQlRsn046kW59I/9UWRpihttFHWnU7Ixycggk=
|
github.com/oneclickvirt/portchecker v0.0.3-20250329125750 h1:TTNL0pnQlRsn046kW59I/9UWRpihttFHWnU7Ixycggk=
|
||||||
github.com/oneclickvirt/portchecker v0.0.3-20250329125750/go.mod h1:HQxSTrqM8/QFqHMTBZ7S8H9eEO5FkUXU1eb7ZX5Mk+k=
|
github.com/oneclickvirt/portchecker v0.0.3-20250329125750/go.mod h1:HQxSTrqM8/QFqHMTBZ7S8H9eEO5FkUXU1eb7ZX5Mk+k=
|
||||||
github.com/oneclickvirt/security v0.0.4-20250629033626 h1:DEchQ7WKKz4CzQpMlweoqA993BGncvmp1rL1ICNDJ2g=
|
github.com/oneclickvirt/security v0.0.6-20250726094444 h1:a4xhcTiBlG9Z3AuQm8PtXfBkd+4+QeytW/MuTQvUTeI=
|
||||||
github.com/oneclickvirt/security v0.0.4-20250629033626/go.mod h1:/5eVnZLvP7RUjwhoI6d8iIMP7msbkHC5So3ZxM+A7Zg=
|
github.com/oneclickvirt/security v0.0.6-20250726094444/go.mod h1:klmmfTFlIw/6rs1PXVRnX16+JG5TPaAMCjxLrCe0Ef8=
|
||||||
github.com/oneclickvirt/speedtest v0.0.10-20250701123931 h1:IMUM0F3trrlCdl9JTO+FBIJ9zc8mbi+oyd66IkO/8mI=
|
github.com/oneclickvirt/speedtest v0.0.10-20250701123931 h1:IMUM0F3trrlCdl9JTO+FBIJ9zc8mbi+oyd66IkO/8mI=
|
||||||
github.com/oneclickvirt/speedtest v0.0.10-20250701123931/go.mod h1:zd5ZgIGslmtQLQehEfRjyumlvgDHTpCSMchKfKXoASI=
|
github.com/oneclickvirt/speedtest v0.0.10-20250701123931/go.mod h1:zd5ZgIGslmtQLQehEfRjyumlvgDHTpCSMchKfKXoASI=
|
||||||
github.com/onsi/ginkgo/v2 v2.22.1 h1:QW7tbJAUDyVDVOM5dFa7qaybo+CRfR7bemlQUN6Z8aM=
|
github.com/onsi/ginkgo/v2 v2.22.1 h1:QW7tbJAUDyVDVOM5dFa7qaybo+CRfR7bemlQUN6Z8aM=
|
||||||
|
191
goecs.go
191
goecs.go
@@ -39,7 +39,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ecsVersion = "v0.1.50"
|
ecsVersion = "v0.1.68"
|
||||||
menuMode bool
|
menuMode bool
|
||||||
onlyChinaTest bool
|
onlyChinaTest bool
|
||||||
input, choice string
|
input, choice string
|
||||||
@@ -347,6 +347,7 @@ func setUnlockOnlyTestStatus() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setHardwareOnlyTestStatus(preCheck utils.NetCheckResult) {
|
func setHardwareOnlyTestStatus(preCheck utils.NetCheckResult) {
|
||||||
|
_ = preCheck
|
||||||
basicStatus = true
|
basicStatus = true
|
||||||
cpuTestStatus = true
|
cpuTestStatus = true
|
||||||
memoryTestStatus = true
|
memoryTestStatus = true
|
||||||
@@ -395,65 +396,77 @@ func handleSignalInterrupt(sig chan os.Signal, startTime *time.Time, output *str
|
|||||||
seconds := int(duration.Seconds()) % 60
|
seconds := int(duration.Seconds()) % 60
|
||||||
currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006")
|
currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006")
|
||||||
outputMutex.Lock()
|
outputMutex.Lock()
|
||||||
*output = utils.PrintAndCapture(func() {
|
timeInfo := utils.PrintAndCapture(func() {
|
||||||
utils.PrintCenteredTitle("", width)
|
utils.PrintCenteredTitle("", width)
|
||||||
fmt.Printf("Cost Time : %d min %d sec\n", minutes, seconds)
|
if language == "zh" {
|
||||||
fmt.Printf("Current Time : %s\n", currentTime)
|
fmt.Printf("花费 : %d 分 %d 秒\n", minutes, seconds)
|
||||||
|
fmt.Printf("时间 : %s\n", currentTime)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("Cost Time : %d min %d sec\n", minutes, seconds)
|
||||||
|
fmt.Printf("Current Time : %s\n", currentTime)
|
||||||
|
}
|
||||||
utils.PrintCenteredTitle("", width)
|
utils.PrintCenteredTitle("", width)
|
||||||
}, tempOutput, *output)
|
}, "", "")
|
||||||
|
*output += timeInfo
|
||||||
|
finalOutput := *output
|
||||||
outputMutex.Unlock()
|
outputMutex.Unlock()
|
||||||
resultChan := make(chan struct {
|
resultChan := make(chan struct {
|
||||||
httpURL string
|
httpURL string
|
||||||
httpsURL string
|
httpsURL string
|
||||||
}, 1)
|
}, 1)
|
||||||
go func() {
|
if enabelUpload {
|
||||||
outputMutex.Lock()
|
go func() {
|
||||||
finalOutput := *output
|
httpURL, httpsURL := utils.ProcessAndUpload(finalOutput, filePath, enabelUpload)
|
||||||
outputMutex.Unlock()
|
resultChan <- struct {
|
||||||
httpURL, httpsURL := utils.ProcessAndUpload(finalOutput, filePath, enabelUpload)
|
httpURL string
|
||||||
resultChan <- struct {
|
httpsURL string
|
||||||
httpURL string
|
}{httpURL, httpsURL}
|
||||||
httpsURL string
|
uploadDone <- true
|
||||||
}{httpURL, httpsURL}
|
}()
|
||||||
uploadDone <- true
|
select {
|
||||||
}()
|
case result := <-resultChan:
|
||||||
select {
|
if result.httpURL != "" || result.httpsURL != "" {
|
||||||
case result := <-resultChan:
|
if language == "en" {
|
||||||
if result.httpURL != "" || result.httpsURL != "" {
|
fmt.Printf("Upload successfully!\nHttp URL: %s\nHttps URL: %s\n", result.httpURL, result.httpsURL)
|
||||||
if language == "en" {
|
} else {
|
||||||
fmt.Printf("Upload successfully!\nHttp URL: %s\nHttps URL: %s\n", result.httpURL, result.httpsURL)
|
fmt.Printf("上传成功!\nHttp URL: %s\nHttps URL: %s\n", result.httpURL, result.httpsURL)
|
||||||
} else {
|
}
|
||||||
fmt.Printf("上传成功!\nHttp URL: %s\nHttps URL: %s\n", result.httpURL, result.httpsURL)
|
|
||||||
}
|
}
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
|
||||||
|
fmt.Println("Press Enter to exit...")
|
||||||
|
fmt.Scanln()
|
||||||
|
}
|
||||||
|
os.Exit(0)
|
||||||
|
case <-time.After(30 * time.Second):
|
||||||
|
if language == "en" {
|
||||||
|
fmt.Println("Upload timeout, program exit")
|
||||||
|
} else {
|
||||||
|
fmt.Println("上传超时,程序退出")
|
||||||
|
}
|
||||||
|
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
|
||||||
|
fmt.Println("Press Enter to exit...")
|
||||||
|
fmt.Scanln()
|
||||||
|
}
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
time.Sleep(100 * time.Millisecond)
|
} else {
|
||||||
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
|
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
|
||||||
fmt.Println("Press Enter to exit...")
|
fmt.Println("Press Enter to exit...")
|
||||||
fmt.Scanln()
|
fmt.Scanln()
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
case <-time.After(30 * time.Second):
|
|
||||||
if language == "en" {
|
|
||||||
fmt.Println("Upload timeout, program exit")
|
|
||||||
} else {
|
|
||||||
fmt.Println("上传超时,程序退出")
|
|
||||||
}
|
|
||||||
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
|
|
||||||
fmt.Println("Press Enter to exit...")
|
|
||||||
fmt.Scanln()
|
|
||||||
}
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func runChineseTests(preCheck utils.NetCheckResult, wg1, wg2, wg3 *sync.WaitGroup, basicInfo, securityInfo, emailInfo, mediaInfo, ptInfo *string, output, tempOutput string, startTime time.Time, outputMutex *sync.Mutex) string {
|
func runChineseTests(preCheck utils.NetCheckResult, wg1, wg2, wg3 *sync.WaitGroup, basicInfo, securityInfo, emailInfo, mediaInfo, ptInfo *string, output *string, tempOutput string, startTime time.Time, outputMutex *sync.Mutex) {
|
||||||
output = runBasicTests(preCheck, basicInfo, securityInfo, output, tempOutput, outputMutex)
|
*output = runBasicTests(preCheck, basicInfo, securityInfo, *output, tempOutput, outputMutex)
|
||||||
output = runCPUTest(output, tempOutput, outputMutex)
|
*output = runCPUTest(*output, tempOutput, outputMutex)
|
||||||
output = runMemoryTest(output, tempOutput, outputMutex)
|
*output = runMemoryTest(*output, tempOutput, outputMutex)
|
||||||
output = runDiskTest(output, tempOutput, outputMutex)
|
*output = runDiskTest(*output, tempOutput, outputMutex)
|
||||||
if (onlyChinaTest || pingTestStatus) && preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
if (onlyChinaTest || pingTestStatus) && preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
||||||
wg3.Add(1)
|
wg3.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
@@ -476,24 +489,24 @@ func runChineseTests(preCheck utils.NetCheckResult, wg1, wg2, wg3 *sync.WaitGrou
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
if preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
if preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
||||||
output = runStreamingTests(wg1, mediaInfo, output, tempOutput, outputMutex)
|
*output = runStreamingTests(wg1, mediaInfo, *output, tempOutput, outputMutex)
|
||||||
output = runSecurityTests(*securityInfo, output, tempOutput, outputMutex)
|
*output = runSecurityTests(*securityInfo, *output, tempOutput, outputMutex)
|
||||||
output = runEmailTests(wg2, emailInfo, output, tempOutput, outputMutex)
|
*output = runEmailTests(wg2, emailInfo, *output, tempOutput, outputMutex)
|
||||||
}
|
}
|
||||||
if runtime.GOOS != "windows" && preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
if runtime.GOOS != "windows" && preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
||||||
output = runNetworkTests(wg3, ptInfo, output, tempOutput, outputMutex)
|
*output = runNetworkTests(wg3, ptInfo, *output, tempOutput, outputMutex)
|
||||||
}
|
}
|
||||||
if preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
if preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
||||||
output = runSpeedTests(output, tempOutput, outputMutex)
|
*output = runSpeedTests(*output, tempOutput, outputMutex)
|
||||||
}
|
}
|
||||||
return appendTimeInfo(output, tempOutput, startTime, outputMutex)
|
*output = appendTimeInfo(*output, tempOutput, startTime, outputMutex)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runEnglishTests(preCheck utils.NetCheckResult, wg1, wg2 *sync.WaitGroup, basicInfo, securityInfo, emailInfo, mediaInfo *string, output, tempOutput string, startTime time.Time, outputMutex *sync.Mutex) string {
|
func runEnglishTests(preCheck utils.NetCheckResult, wg1, wg2 *sync.WaitGroup, basicInfo, securityInfo, emailInfo, mediaInfo *string, output *string, tempOutput string, startTime time.Time, outputMutex *sync.Mutex) {
|
||||||
output = runBasicTests(preCheck, basicInfo, securityInfo, output, tempOutput, outputMutex)
|
*output = runBasicTests(preCheck, basicInfo, securityInfo, *output, tempOutput, outputMutex)
|
||||||
output = runCPUTest(output, tempOutput, outputMutex)
|
*output = runCPUTest(*output, tempOutput, outputMutex)
|
||||||
output = runMemoryTest(output, tempOutput, outputMutex)
|
*output = runMemoryTest(*output, tempOutput, outputMutex)
|
||||||
output = runDiskTest(output, tempOutput, outputMutex)
|
*output = runDiskTest(*output, tempOutput, outputMutex)
|
||||||
if preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
if preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
||||||
if utTestStatus {
|
if utTestStatus {
|
||||||
wg1.Add(1)
|
wg1.Add(1)
|
||||||
@@ -509,15 +522,17 @@ func runEnglishTests(preCheck utils.NetCheckResult, wg1, wg2 *sync.WaitGroup, ba
|
|||||||
*emailInfo = email.EmailCheck()
|
*emailInfo = email.EmailCheck()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
output = runStreamingTests(wg1, mediaInfo, output, tempOutput, outputMutex) // 传递指针
|
*output = runStreamingTests(wg1, mediaInfo, *output, tempOutput, outputMutex)
|
||||||
output = runSecurityTests(*securityInfo, output, tempOutput, outputMutex)
|
*output = runSecurityTests(*securityInfo, *output, tempOutput, outputMutex)
|
||||||
output = runEmailTests(wg2, emailInfo, output, tempOutput, outputMutex)
|
*output = runEmailTests(wg2, emailInfo, *output, tempOutput, outputMutex)
|
||||||
output = runEnglishSpeedTests(output, tempOutput, outputMutex)
|
*output = runEnglishSpeedTests(*output, tempOutput, outputMutex)
|
||||||
}
|
}
|
||||||
return appendTimeInfo(output, tempOutput, startTime, outputMutex)
|
*output = appendTimeInfo(*output, tempOutput, startTime, outputMutex)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runBasicTests(preCheck utils.NetCheckResult, basicInfo, securityInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runBasicTests(preCheck utils.NetCheckResult, basicInfo, securityInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
return utils.PrintAndCapture(func() {
|
return utils.PrintAndCapture(func() {
|
||||||
utils.PrintHead(language, width, ecsVersion)
|
utils.PrintHead(language, width, ecsVersion)
|
||||||
if basicStatus || securityTestStatus {
|
if basicStatus || securityTestStatus {
|
||||||
@@ -554,57 +569,72 @@ func runBasicTests(preCheck utils.NetCheckResult, basicInfo, securityInfo *strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runCPUTest(output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runCPUTest(output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
return utils.PrintAndCapture(func() {
|
return utils.PrintAndCapture(func() {
|
||||||
if cpuTestStatus {
|
if cpuTestStatus {
|
||||||
|
realTestMethod, res := cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
|
||||||
if language == "zh" {
|
if language == "zh" {
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", cpuTestMethod), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", realTestMethod), width)
|
||||||
} else {
|
} else {
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("CPU-Test--%s-Method", cpuTestMethod), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("CPU-Test--%s-Method", realTestMethod), width)
|
||||||
}
|
}
|
||||||
cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
|
fmt.Print(res)
|
||||||
}
|
}
|
||||||
}, tempOutput, output)
|
}, tempOutput, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runMemoryTest(output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runMemoryTest(output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
return utils.PrintAndCapture(func() {
|
return utils.PrintAndCapture(func() {
|
||||||
if memoryTestStatus {
|
if memoryTestStatus {
|
||||||
|
realTestMethod, res := memorytest.MemoryTest(language, memoryTestMethod)
|
||||||
if language == "zh" {
|
if language == "zh" {
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", memoryTestMethod), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", realTestMethod), width)
|
||||||
} else {
|
} else {
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("Memory-Test--%s-Method", memoryTestMethod), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("Memory-Test--%s-Method", realTestMethod), width)
|
||||||
}
|
}
|
||||||
memorytest.MemoryTest(language, memoryTestMethod)
|
fmt.Print(res)
|
||||||
}
|
}
|
||||||
}, tempOutput, output)
|
}, tempOutput, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runDiskTest(output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runDiskTest(output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
return utils.PrintAndCapture(func() {
|
return utils.PrintAndCapture(func() {
|
||||||
if diskTestStatus && autoChangeDiskTestMethod {
|
if diskTestStatus && autoChangeDiskTestMethod {
|
||||||
|
realTestMethod, res := disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
||||||
if language == "zh" {
|
if language == "zh" {
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", diskTestMethod), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", realTestMethod), width)
|
||||||
} else {
|
} else {
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("Disk-Test--%s-Method", diskTestMethod), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("Disk-Test--%s-Method", realTestMethod), width)
|
||||||
}
|
}
|
||||||
disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
fmt.Print(res)
|
||||||
} else if diskTestStatus && !autoChangeDiskTestMethod {
|
} else if diskTestStatus && !autoChangeDiskTestMethod {
|
||||||
if language == "zh" {
|
if language == "zh" {
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", "dd"), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", "dd"), width)
|
||||||
disktest.DiskTest(language, "dd", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
_, res := disktest.DiskTest(language, "dd", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
||||||
|
fmt.Print(res)
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", "fio"), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", "fio"), width)
|
||||||
disktest.DiskTest(language, "fio", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
_, res = disktest.DiskTest(language, "fio", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
||||||
|
fmt.Print(res)
|
||||||
} else {
|
} else {
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("Disk-Test--%s-Method", "dd"), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("Disk-Test--%s-Method", "dd"), width)
|
||||||
disktest.DiskTest(language, "dd", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
_, res := disktest.DiskTest(language, "dd", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
||||||
|
fmt.Print(res)
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("Disk-Test--%s-Method", "fio"), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("Disk-Test--%s-Method", "fio"), width)
|
||||||
disktest.DiskTest(language, "fio", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
_, res = disktest.DiskTest(language, "fio", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
||||||
|
fmt.Print(res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, tempOutput, output)
|
}, tempOutput, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runStreamingTests(wg1 *sync.WaitGroup, mediaInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runStreamingTests(wg1 *sync.WaitGroup, mediaInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
return utils.PrintAndCapture(func() {
|
return utils.PrintAndCapture(func() {
|
||||||
if language == "zh" {
|
if language == "zh" {
|
||||||
if commTestStatus && !onlyChinaTest {
|
if commTestStatus && !onlyChinaTest {
|
||||||
@@ -625,6 +655,8 @@ func runStreamingTests(wg1 *sync.WaitGroup, mediaInfo *string, output, tempOutpu
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runSecurityTests(securityInfo, output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runSecurityTests(securityInfo, output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
return utils.PrintAndCapture(func() {
|
return utils.PrintAndCapture(func() {
|
||||||
if securityTestStatus {
|
if securityTestStatus {
|
||||||
if language == "zh" {
|
if language == "zh" {
|
||||||
@@ -638,6 +670,8 @@ func runSecurityTests(securityInfo, output, tempOutput string, outputMutex *sync
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runEmailTests(wg2 *sync.WaitGroup, emailInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runEmailTests(wg2 *sync.WaitGroup, emailInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
return utils.PrintAndCapture(func() {
|
return utils.PrintAndCapture(func() {
|
||||||
if emailTestStatus {
|
if emailTestStatus {
|
||||||
wg2.Wait()
|
wg2.Wait()
|
||||||
@@ -652,6 +686,8 @@ func runEmailTests(wg2 *sync.WaitGroup, emailInfo *string, output, tempOutput st
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runNetworkTests(wg3 *sync.WaitGroup, ptInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runNetworkTests(wg3 *sync.WaitGroup, ptInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
output = utils.PrintAndCapture(func() {
|
output = utils.PrintAndCapture(func() {
|
||||||
if backtraceStatus && !onlyChinaTest {
|
if backtraceStatus && !onlyChinaTest {
|
||||||
utils.PrintCenteredTitle("三网回程线路检测", width)
|
utils.PrintCenteredTitle("三网回程线路检测", width)
|
||||||
@@ -678,6 +714,8 @@ func runNetworkTests(wg3 *sync.WaitGroup, ptInfo *string, output, tempOutput str
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runSpeedTests(output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runSpeedTests(output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
return utils.PrintAndCapture(func() {
|
return utils.PrintAndCapture(func() {
|
||||||
if speedTestStatus {
|
if speedTestStatus {
|
||||||
utils.PrintCenteredTitle("就近节点测速", width)
|
utils.PrintCenteredTitle("就近节点测速", width)
|
||||||
@@ -698,6 +736,8 @@ func runSpeedTests(output, tempOutput string, outputMutex *sync.Mutex) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runEnglishSpeedTests(output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runEnglishSpeedTests(output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
return utils.PrintAndCapture(func() {
|
return utils.PrintAndCapture(func() {
|
||||||
if speedTestStatus {
|
if speedTestStatus {
|
||||||
utils.PrintCenteredTitle("Speed-Test", width)
|
utils.PrintCenteredTitle("Speed-Test", width)
|
||||||
@@ -709,6 +749,8 @@ func runEnglishSpeedTests(output, tempOutput string, outputMutex *sync.Mutex) st
|
|||||||
}
|
}
|
||||||
|
|
||||||
func appendTimeInfo(output, tempOutput string, startTime time.Time, outputMutex *sync.Mutex) string {
|
func appendTimeInfo(output, tempOutput string, startTime time.Time, outputMutex *sync.Mutex) string {
|
||||||
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
endTime := time.Now()
|
endTime := time.Now()
|
||||||
duration := endTime.Sub(startTime)
|
duration := endTime.Sub(startTime)
|
||||||
minutes := int(duration.Minutes())
|
minutes := int(duration.Minutes())
|
||||||
@@ -752,6 +794,9 @@ func main() {
|
|||||||
handleMenuMode(preCheck)
|
handleMenuMode(preCheck)
|
||||||
}
|
}
|
||||||
handleLanguageSpecificSettings()
|
handleLanguageSpecificSettings()
|
||||||
|
if !preCheck.Connected {
|
||||||
|
enabelUpload = false
|
||||||
|
}
|
||||||
var (
|
var (
|
||||||
wg1, wg2, wg3 sync.WaitGroup
|
wg1, wg2, wg3 sync.WaitGroup
|
||||||
basicInfo, securityInfo, emailInfo, mediaInfo, ptInfo string
|
basicInfo, securityInfo, emailInfo, mediaInfo, ptInfo string
|
||||||
@@ -765,13 +810,15 @@ func main() {
|
|||||||
go handleSignalInterrupt(sig, &startTime, &output, tempOutput, uploadDone, &outputMutex)
|
go handleSignalInterrupt(sig, &startTime, &output, tempOutput, uploadDone, &outputMutex)
|
||||||
switch language {
|
switch language {
|
||||||
case "zh":
|
case "zh":
|
||||||
output = runChineseTests(preCheck, &wg1, &wg2, &wg3, &basicInfo, &securityInfo, &emailInfo, &mediaInfo, &ptInfo, output, tempOutput, startTime, &outputMutex)
|
runChineseTests(preCheck, &wg1, &wg2, &wg3, &basicInfo, &securityInfo, &emailInfo, &mediaInfo, &ptInfo, &output, tempOutput, startTime, &outputMutex)
|
||||||
case "en":
|
case "en":
|
||||||
output = runEnglishTests(preCheck, &wg1, &wg2, &basicInfo, &securityInfo, &emailInfo, &mediaInfo, output, tempOutput, startTime, &outputMutex)
|
runEnglishTests(preCheck, &wg1, &wg2, &basicInfo, &securityInfo, &emailInfo, &mediaInfo, &output, tempOutput, startTime, &outputMutex)
|
||||||
default:
|
default:
|
||||||
fmt.Println("Unsupported language")
|
fmt.Println("Unsupported language")
|
||||||
}
|
}
|
||||||
handleUploadResults(output)
|
if preCheck.Connected {
|
||||||
|
handleUploadResults(output)
|
||||||
|
}
|
||||||
finish = true
|
finish = true
|
||||||
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
|
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
|
||||||
fmt.Println("Press Enter to exit...")
|
fmt.Println("Press Enter to exit...")
|
||||||
|
6
goecs.sh
6
goecs.sh
@@ -143,7 +143,7 @@ goecs_check() {
|
|||||||
os=$(uname -s 2>/dev/null || echo "Unknown")
|
os=$(uname -s 2>/dev/null || echo "Unknown")
|
||||||
arch=$(uname -m 2>/dev/null || echo "Unknown")
|
arch=$(uname -m 2>/dev/null || echo "Unknown")
|
||||||
check_china
|
check_china
|
||||||
ECS_VERSION="0.1.49"
|
ECS_VERSION="0.1.67"
|
||||||
for api in \
|
for api in \
|
||||||
"https://api.github.com/repos/oneclickvirt/ecs/releases/latest" \
|
"https://api.github.com/repos/oneclickvirt/ecs/releases/latest" \
|
||||||
"https://githubapi.spiritlhl.workers.dev/repos/oneclickvirt/ecs/releases/latest" \
|
"https://githubapi.spiritlhl.workers.dev/repos/oneclickvirt/ecs/releases/latest" \
|
||||||
@@ -155,8 +155,8 @@ goecs_check() {
|
|||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
if [ -z "$ECS_VERSION" ]; then
|
if [ -z "$ECS_VERSION" ]; then
|
||||||
_yellow "Unable to get version info, using default version 0.1.49"
|
_yellow "Unable to get version info, using default version 0.1.67"
|
||||||
ECS_VERSION="0.1.49"
|
ECS_VERSION="0.1.67"
|
||||||
fi
|
fi
|
||||||
version_output=""
|
version_output=""
|
||||||
for cmd_path in "goecs" "./goecs" "/usr/bin/goecs" "/usr/local/bin/goecs"; do
|
for cmd_path in "goecs" "./goecs" "/usr/bin/goecs" "/usr/local/bin/goecs"; do
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
package memorytest
|
package memorytest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/oneclickvirt/memorytest/memory"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/oneclickvirt/memorytest/memory"
|
||||||
)
|
)
|
||||||
|
|
||||||
func MemoryTest(language, testMethod string) {
|
func MemoryTest(language, testMethod string) (realTestMethod, res string) {
|
||||||
var res string
|
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
if testMethod != "winsat" && testMethod != "" {
|
if testMethod != "winsat" && testMethod != "" {
|
||||||
res = "Detected host is Windows, using Winsat for testing.\n"
|
// res = "Detected host is Windows, using Winsat for testing.\n"
|
||||||
|
realTestMethod = "winsat"
|
||||||
}
|
}
|
||||||
res += memory.WinsatTest(language)
|
res += memory.WinsatTest(language)
|
||||||
} else {
|
} else {
|
||||||
@@ -19,18 +19,23 @@ func MemoryTest(language, testMethod string) {
|
|||||||
case "sysbench":
|
case "sysbench":
|
||||||
res = memory.SysBenchTest(language)
|
res = memory.SysBenchTest(language)
|
||||||
if res == "" {
|
if res == "" {
|
||||||
res = "sysbench test failed, switch to use dd test.\n"
|
// res = "sysbench test failed, switch to use dd test.\n"
|
||||||
res += memory.DDTest(language)
|
res += memory.DDTest(language)
|
||||||
|
realTestMethod = "dd"
|
||||||
|
} else {
|
||||||
|
realTestMethod = "sysbench"
|
||||||
}
|
}
|
||||||
case "dd":
|
case "dd":
|
||||||
res = memory.DDTest(language)
|
res = memory.DDTest(language)
|
||||||
|
realTestMethod = "dd"
|
||||||
default:
|
default:
|
||||||
res = "Unsupported test method, switch to use dd test.\n"
|
// res = "Unsupported test method, switch to use dd test.\n"
|
||||||
res += memory.DDTest(language)
|
res += memory.DDTest(language)
|
||||||
|
realTestMethod = "dd"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !strings.Contains(res, "\n") && res != "" {
|
if !strings.Contains(res, "\n") && res != "" {
|
||||||
res += "\n"
|
res += "\n"
|
||||||
}
|
}
|
||||||
fmt.Printf("%s", res)
|
return
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
package memorytest
|
package memorytest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test(t *testing.T) {
|
func Test(t *testing.T) {
|
||||||
MemoryTest("zh", "sysbench")
|
_, res := MemoryTest("zh", "sysbench")
|
||||||
|
fmt.Print(res)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user