Add crazy badges to README

This commit is contained in:
世界 2024-07-06 09:03:50 +08:00
parent d7af8bd589
commit 6ada0cc22e
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
8 changed files with 87 additions and 48 deletions

View File

@ -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 ./...

View File

@ -1,4 +1,4 @@
name: Lint name: lint
on: on:
push: push:
@ -20,16 +20,20 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version: ^1.22 go-version: ^1.22
- name: golangci-lint - name: Cache go module
uses: golangci/golangci-lint-action@v4 uses: actions/cache@v4
with: with:
version: latest path: |
args: --timeout=30m ~/go/pkg/mod
install-mode: binary key: go-${{ hashFiles('**/go.sum') }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest

64
.github/workflows/test.yml vendored Normal file
View File

@ -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

View File

@ -5,7 +5,6 @@ linters:
- govet - govet
- gci - gci
- staticcheck - staticcheck
- paralleltest
linters-settings: linters-settings:
gci: gci:
@ -14,5 +13,3 @@ linters-settings:
- standard - standard
- prefix(github.com/sagernet/) - prefix(github.com/sagernet/)
- default - default
staticcheck:
go: '1.20'

View File

@ -35,6 +35,9 @@ lint:
lint_install: lint_install:
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest
test:
go test ./...
release: release:
goreleaser release --clean --skip publish goreleaser release --clean --skip publish
mkdir dist/release mkdir dist/release

View File

@ -1,5 +1,8 @@
# serenity # 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. The configuration generator for sing-box.
## Documentation ## Documentation

View File

@ -7,7 +7,7 @@ import (
"github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common/json" "github.com/sagernet/sing/common/json"
"github.com/sagernet/sing/common/rw" "github.com/sagernet/sing/common/varbin"
) )
type Subscription struct { type Subscription struct {
@ -23,7 +23,7 @@ func (c *Subscription) MarshalBinary() ([]byte, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
err = rw.WriteUVariant(&buffer, uint64(len(content))) _, err = varbin.WriteUvarint(&buffer, uint64(len(content)))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -35,7 +35,7 @@ func (c *Subscription) MarshalBinary() ([]byte, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
err = rw.WriteVString(&buffer, c.LastEtag) err = varbin.Write(&buffer, binary.BigEndian, c.LastEtag)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -49,7 +49,7 @@ func (c *Subscription) UnmarshalBinary(data []byte) error {
return err return err
} }
_ = version _ = version
contentLength, err := rw.ReadUVariant(reader) contentLength, err := binary.ReadUvarint(reader)
if err != nil { if err != nil {
return err return err
} }
@ -68,7 +68,7 @@ func (c *Subscription) UnmarshalBinary(data []byte) error {
return err return err
} }
c.LastUpdated = time.Unix(lastUpdatedUnix, 0) c.LastUpdated = time.Unix(lastUpdatedUnix, 0)
c.LastEtag, err = rw.ReadVString(reader) err = varbin.Read(reader, binary.BigEndian, &c.LastEtag)
if err != nil { if err != nil {
return err return err
} }

View File

@ -12,6 +12,7 @@ import (
) )
func TestFilter1100(t *testing.T) { func TestFilter1100(t *testing.T) {
t.Parallel()
options := &option.Options{ options := &option.Options{
DNS: &option.DNSOptions{ DNS: &option.DNSOptions{
Rules: []option.DNSRule{ Rules: []option.DNSRule{