From 6ada0cc22e78ba581faccd0fca44bc7d69439167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sat, 6 Jul 2024 09:03:50 +0800 Subject: [PATCH] Add crazy badges to README --- .github/workflows/debug.yml | 33 ---------------- .github/workflows/lint.yml | 18 +++++---- .github/workflows/test.yml | 64 ++++++++++++++++++++++++++++++++ .golangci.yml | 3 -- Makefile | 3 ++ README.md | 3 ++ common/cachefile/subscription.go | 10 ++--- template/filter/filter_test.go | 1 + 8 files changed, 87 insertions(+), 48 deletions(-) delete mode 100644 .github/workflows/debug.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml deleted file mode 100644 index 1f90f7b..0000000 --- a/.github/workflows/debug.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Debug build - -on: - push: - branches: - - main - - dev - paths-ignore: - - '**.md' - - '.github/**' - - '!.github/workflows/debug.yml' - pull_request: - branches: - - main - - dev - -jobs: - build: - name: Debug build - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: ^1.22 - continue-on-error: true - - name: Run Test - run: | - go test -v ./... \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c1547d5..81b3435 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: Lint +name: lint on: push: @@ -20,16 +20,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Go uses: actions/setup-go@v5 with: go-version: ^1.22 - - name: golangci-lint - uses: golangci/golangci-lint-action@v4 + - name: Cache go module + uses: actions/cache@v4 with: - version: latest - args: --timeout=30m - install-mode: binary \ No newline at end of file + path: | + ~/go/pkg/mod + key: go-${{ hashFiles('**/go.sum') }} + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: latest \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..d243abe --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,64 @@ +name: test + +on: + push: + branches: + - main + - dev + paths-ignore: + - '**.md' + - '.github/**' + - '!.github/workflows/debug.yml' + pull_request: + branches: + - main + - dev + +jobs: + build: + name: Linux + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ^1.22 + - name: Build + run: | + make test + build_windows: + name: Windows + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ^1.22 + continue-on-error: true + - name: Build + run: | + make test + build_darwin: + name: macOS + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ^1.22 + continue-on-error: true + - name: Build + run: | + make test \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index 58f7fe1..5f1dcd0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,7 +5,6 @@ linters: - govet - gci - staticcheck - - paralleltest linters-settings: gci: @@ -14,5 +13,3 @@ linters-settings: - standard - prefix(github.com/sagernet/) - default - staticcheck: - go: '1.20' diff --git a/Makefile b/Makefile index 84b8995..0846a56 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,9 @@ lint: lint_install: go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest +test: + go test ./... + release: goreleaser release --clean --skip publish mkdir dist/release diff --git a/README.md b/README.md index b8fac01..408923a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # serenity +![test](https://github.com/sagernet/sing/actions/workflows/test.yml/badge.svg) +![lint](https://github.com/sagernet/sing/actions/workflows/lint.yml/badge.svg) + The configuration generator for sing-box. ## Documentation diff --git a/common/cachefile/subscription.go b/common/cachefile/subscription.go index b257f37..8c41785 100644 --- a/common/cachefile/subscription.go +++ b/common/cachefile/subscription.go @@ -7,7 +7,7 @@ import ( "github.com/sagernet/sing-box/option" "github.com/sagernet/sing/common/json" - "github.com/sagernet/sing/common/rw" + "github.com/sagernet/sing/common/varbin" ) type Subscription struct { @@ -23,7 +23,7 @@ func (c *Subscription) MarshalBinary() ([]byte, error) { if err != nil { return nil, err } - err = rw.WriteUVariant(&buffer, uint64(len(content))) + _, err = varbin.WriteUvarint(&buffer, uint64(len(content))) if err != nil { return nil, err } @@ -35,7 +35,7 @@ func (c *Subscription) MarshalBinary() ([]byte, error) { if err != nil { return nil, err } - err = rw.WriteVString(&buffer, c.LastEtag) + err = varbin.Write(&buffer, binary.BigEndian, c.LastEtag) if err != nil { return nil, err } @@ -49,7 +49,7 @@ func (c *Subscription) UnmarshalBinary(data []byte) error { return err } _ = version - contentLength, err := rw.ReadUVariant(reader) + contentLength, err := binary.ReadUvarint(reader) if err != nil { return err } @@ -68,7 +68,7 @@ func (c *Subscription) UnmarshalBinary(data []byte) error { return err } c.LastUpdated = time.Unix(lastUpdatedUnix, 0) - c.LastEtag, err = rw.ReadVString(reader) + err = varbin.Read(reader, binary.BigEndian, &c.LastEtag) if err != nil { return err } diff --git a/template/filter/filter_test.go b/template/filter/filter_test.go index 199004c..d61b6a0 100644 --- a/template/filter/filter_test.go +++ b/template/filter/filter_test.go @@ -12,6 +12,7 @@ import ( ) func TestFilter1100(t *testing.T) { + t.Parallel() options := &option.Options{ DNS: &option.DNSOptions{ Rules: []option.DNSRule{