From dce122e7617081ce3c192d24dfc2f471be7378aa Mon Sep 17 00:00:00 2001 From: Flier Lu Date: Sun, 1 Dec 2024 19:30:25 +0800 Subject: [PATCH 01/14] remove chimera build tag --- .github/workflows/ci.yml | 8 ++++---- bench/go/chimera_test.go | 3 --- chimera/api.go | 3 --- chimera/api_test.go | 3 --- chimera/block.go | 3 --- chimera/common.go | 3 --- chimera/common_test.go | 3 --- chimera/compile.go | 3 --- chimera/compile_test.go | 3 --- chimera/doc.go | 3 --- chimera/example_api_test.go | 3 --- chimera/example_compile_test.go | 3 --- chimera/example_runtime_test.go | 3 --- chimera/pattern.go | 3 --- chimera/pattern_test.go | 3 --- chimera/runtime.go | 3 --- chimera/runtime_test.go | 3 --- chimera/scratch.go | 3 --- internal/ch/allocator.go | 3 --- internal/ch/allocator_test.go | 3 --- internal/ch/common.go | 3 --- internal/ch/common_test.go | 3 --- internal/ch/compile.go | 3 --- internal/ch/compile_test.go | 3 --- internal/ch/error.go | 3 --- internal/ch/link.go | 3 --- internal/ch/runtime.go | 3 --- internal/ch/runtime_test.go | 3 --- internal/ch/scratch.go | 3 --- internal/ch/scratch_test.go | 3 --- 30 files changed, 4 insertions(+), 91 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 659a26b..730a780 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: strategy: matrix: os: [ubuntu-22.04, ubuntu-20.04, macos-12, macos-11] - go: [stable, 1.20.x, 1.19.x, 1.18.x] + go: [stable, 1.22.x, 1.18.x] name: Go ${{ matrix.go }} tests @ ${{ matrix.os }} for hyperscan runs-on: ${{ matrix.os }} steps: @@ -34,7 +34,7 @@ jobs: run: | brew install hyperscan pkg-config libpcap - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install Golang ${{ matrix.go }} uses: actions/setup-go@v4 @@ -94,7 +94,7 @@ jobs: CGO_CFLAGS: -I${{ github.workspace }}/dist/include/hs CGO_LDFLAGS: -L${{ github.workspace }}/dist/lib steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install Hyperscan ${{ matrix.hyperscan }} with PCRE ${{ matrix.pcre_version }} uses: flier/install-hyperscan@main @@ -142,7 +142,7 @@ jobs: - uses: actions/setup-go@v3 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: golangci-lint uses: golangci/golangci-lint-action@v3 diff --git a/bench/go/chimera_test.go b/bench/go/chimera_test.go index d784dc5..84b2504 100644 --- a/bench/go/chimera_test.go +++ b/bench/go/chimera_test.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package scan_test import ( diff --git a/chimera/api.go b/chimera/api.go index 97ef1cb..3e730b7 100644 --- a/chimera/api.go +++ b/chimera/api.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package chimera import ( diff --git a/chimera/api_test.go b/chimera/api_test.go index ee391fc..6d5d770 100644 --- a/chimera/api_test.go +++ b/chimera/api_test.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package chimera_test import ( diff --git a/chimera/block.go b/chimera/block.go index e2d8cd4..f621005 100644 --- a/chimera/block.go +++ b/chimera/block.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package chimera import ( diff --git a/chimera/common.go b/chimera/common.go index f55abc7..6f1a691 100644 --- a/chimera/common.go +++ b/chimera/common.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package chimera import ( diff --git a/chimera/common_test.go b/chimera/common_test.go index eef5ac1..fc0ae96 100644 --- a/chimera/common_test.go +++ b/chimera/common_test.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package chimera_test import ( diff --git a/chimera/compile.go b/chimera/compile.go index a013fe5..4c37e1e 100644 --- a/chimera/compile.go +++ b/chimera/compile.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package chimera import ( diff --git a/chimera/compile_test.go b/chimera/compile_test.go index dd9e1ae..c62c784 100644 --- a/chimera/compile_test.go +++ b/chimera/compile_test.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package chimera_test import ( diff --git a/chimera/doc.go b/chimera/doc.go index 7976d0c..75593e7 100644 --- a/chimera/doc.go +++ b/chimera/doc.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - // Chimera is a software regular expression matching engine that is a hybrid of Hyperscan and PCRE. // The design goals of Chimera are to fully support PCRE syntax as well as to // take advantage of the high performance nature of Hyperscan. diff --git a/chimera/example_api_test.go b/chimera/example_api_test.go index 4c70785..3102152 100644 --- a/chimera/example_api_test.go +++ b/chimera/example_api_test.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package chimera_test import ( diff --git a/chimera/example_compile_test.go b/chimera/example_compile_test.go index 9a47668..8cf20dd 100644 --- a/chimera/example_compile_test.go +++ b/chimera/example_compile_test.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package chimera_test import ( diff --git a/chimera/example_runtime_test.go b/chimera/example_runtime_test.go index 3b40cb0..0481dfe 100644 --- a/chimera/example_runtime_test.go +++ b/chimera/example_runtime_test.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package chimera_test import ( diff --git a/chimera/pattern.go b/chimera/pattern.go index d24db6f..c6b88df 100644 --- a/chimera/pattern.go +++ b/chimera/pattern.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package chimera import ( diff --git a/chimera/pattern_test.go b/chimera/pattern_test.go index 01b7123..6c5856d 100644 --- a/chimera/pattern_test.go +++ b/chimera/pattern_test.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package chimera_test import ( diff --git a/chimera/runtime.go b/chimera/runtime.go index 42eac20..1b4b885 100644 --- a/chimera/runtime.go +++ b/chimera/runtime.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package chimera import ( diff --git a/chimera/runtime_test.go b/chimera/runtime_test.go index 7499319..bc255d9 100644 --- a/chimera/runtime_test.go +++ b/chimera/runtime_test.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package chimera_test import ( diff --git a/chimera/scratch.go b/chimera/scratch.go index a6e1299..dbbfd0f 100644 --- a/chimera/scratch.go +++ b/chimera/scratch.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package chimera import ( diff --git a/internal/ch/allocator.go b/internal/ch/allocator.go index 126969a..ddb7d71 100644 --- a/internal/ch/allocator.go +++ b/internal/ch/allocator.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package ch import "unsafe" diff --git a/internal/ch/allocator_test.go b/internal/ch/allocator_test.go index 6065805..e04c80a 100644 --- a/internal/ch/allocator_test.go +++ b/internal/ch/allocator_test.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package ch_test import ( diff --git a/internal/ch/common.go b/internal/ch/common.go index 5e8ba69..730fc2c 100644 --- a/internal/ch/common.go +++ b/internal/ch/common.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package ch import ( diff --git a/internal/ch/common_test.go b/internal/ch/common_test.go index 450f54e..413a2b5 100644 --- a/internal/ch/common_test.go +++ b/internal/ch/common_test.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package ch_test import ( diff --git a/internal/ch/compile.go b/internal/ch/compile.go index 692f3f0..c4052ba 100644 --- a/internal/ch/compile.go +++ b/internal/ch/compile.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package ch import ( diff --git a/internal/ch/compile_test.go b/internal/ch/compile_test.go index 4849b7b..500b8f5 100644 --- a/internal/ch/compile_test.go +++ b/internal/ch/compile_test.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package ch_test import ( diff --git a/internal/ch/error.go b/internal/ch/error.go index 61c9f66..52d6b28 100644 --- a/internal/ch/error.go +++ b/internal/ch/error.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package ch // #include diff --git a/internal/ch/link.go b/internal/ch/link.go index 9b6a3b4..13bce5e 100644 --- a/internal/ch/link.go +++ b/internal/ch/link.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package ch /* diff --git a/internal/ch/runtime.go b/internal/ch/runtime.go index 274c5b5..33a7900 100644 --- a/internal/ch/runtime.go +++ b/internal/ch/runtime.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package ch import ( diff --git a/internal/ch/runtime_test.go b/internal/ch/runtime_test.go index 4807286..7df4f12 100644 --- a/internal/ch/runtime_test.go +++ b/internal/ch/runtime_test.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package ch_test import ( diff --git a/internal/ch/scratch.go b/internal/ch/scratch.go index c23a6a2..e08f268 100644 --- a/internal/ch/scratch.go +++ b/internal/ch/scratch.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package ch // #include diff --git a/internal/ch/scratch_test.go b/internal/ch/scratch_test.go index 5ef62b1..40b18cd 100644 --- a/internal/ch/scratch_test.go +++ b/internal/ch/scratch_test.go @@ -1,6 +1,3 @@ -//go:build chimera -// +build chimera - package ch_test import ( From 33d4d878b8c996c0d5f0338df80203c809eb1ebd Mon Sep 17 00:00:00 2001 From: Flier Lu Date: Sun, 1 Dec 2024 19:52:03 +0800 Subject: [PATCH 02/14] remove hyperscan_v4 test --- .github/workflows/docker.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8c1807c..668df04 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -19,23 +19,18 @@ jobs: - ubuntu_version: 22.04 hyperscan_version: 5.4.2 pcre_version: 8.45 - go_version: 1.20.3 + go_version: 1.23.3 build_flags: -tags hyperscan_v54,chimera - - ubuntu_version: 20.04 + - ubuntu_version: 22.04 hyperscan_version: 5.2.1 pcre_version: 8.45 - go_version: 1.19.8 + go_version: 1.22.9 build_flags: -tags hyperscan_v52,chimera - ubuntu_version: 20.04 hyperscan_version: 5.1.1 - pcre_version: 8.45 + pcre_version: 8.41 build_flags: -tags chimera - go_version: 1.18.10 - - ubuntu_version: 18.04 - hyperscan_version: 4.7.0 - pcre_version: 8.42 - go_version: 1.18.10 - build_flags: -tags hyperscan_v4 + go_version: 1.21.13 name: tests @ ubuntu ${{ matrix.ubuntu_version }} for hyperscan ${{ matrix.hyperscan_version }} w/ ${{ matrix.build_flags }} env: LATEST_TAG: flier/gohs:${{ matrix.hyperscan_version }} From eae7b522301f636525b88e3aea49ac6f1bb821cb Mon Sep 17 00:00:00 2001 From: Flier Lu Date: Sun, 1 Dec 2024 21:23:29 +0800 Subject: [PATCH 03/14] fix golangci-lint warnings --- .golangci.yml | 20 +++++++++----------- chimera/api.go | 2 +- chimera/block.go | 2 +- chimera/common.go | 9 ++++----- chimera/compile.go | 12 +++++++----- chimera/runtime.go | 2 +- chimera/runtime_test.go | 4 ++-- chimera/scratch.go | 12 +++++++----- hyperscan/common.go | 2 +- hyperscan/pattern.go | 2 +- internal/ch/error.go | 2 +- internal/ch/runtime.go | 2 +- 12 files changed, 36 insertions(+), 35 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index f216fd1..dcaf454 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -10,11 +10,12 @@ run: issues-exit-code: 1 # include test files or not, default is true - tests: true + tests: false # list of build tags, all linters use it. Default is empty list. build-tags: - !privileged_tests + - chimera # default is true. Enables skipping of directories: # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ @@ -68,27 +69,24 @@ linters-settings: linters: enable-all: true disable: - - deadcode + - copyloopvar + - depguard - dupword - exhaustive - - exhaustivestruct - exhaustruct + - exportloopref - gci - gochecknoglobals - gochecknoinits - gocritic - godox - - golint - - ifshort - - interfacer + - gofumpt + - gosec + - intrange - ireturn - - maligned - nlreturn - nonamedreturns - - nosnakecase - paralleltest - - scopelint - - structcheck - - varcheck + - revive - varnamelen - wsl diff --git a/chimera/api.go b/chimera/api.go index 3e730b7..6710549 100644 --- a/chimera/api.go +++ b/chimera/api.go @@ -33,7 +33,7 @@ func Match(pattern string, data []byte) (bool, error) { h := &ch.MatchRecorder{} if err = db.Scan(data, s, h, nil); err != nil { - return false, err // nolint: wrapcheck + return false, err //nolint: wrapcheck } return h.Matched(), h.Err diff --git a/chimera/block.go b/chimera/block.go index f621005..1486620 100644 --- a/chimera/block.go +++ b/chimera/block.go @@ -95,7 +95,7 @@ func (bs *blockScanner) Scan(data []byte, s *Scratch, h Handler, ctx interface{} }() } - return ch.Scan(bs.db, data, 0, s.s, h.OnMatch, h.OnError, ctx) // nolint: wrapcheck + return ch.Scan(bs.db, data, 0, s.s, h.OnMatch, h.OnError, ctx) //nolint: wrapcheck } type blockMatcher struct { diff --git a/chimera/common.go b/chimera/common.go index 6f1a691..e095958 100644 --- a/chimera/common.go +++ b/chimera/common.go @@ -38,8 +38,7 @@ const ( ) // DbInfo identify the version and platform information for the supplied database. -// nolint: stylecheck -type DbInfo string +type DbInfo string //nolint: stylecheck // parse `Chimera Version: 5.4.0 Features: AVX2 Mode: BLOCK`. var regexDBInfo = regexp.MustCompile(`^Chimera Version: (\d+\.\d+\.\d+) Features: ([\w\s]+)? Mode: (\w+)$`) @@ -77,7 +76,7 @@ func (i DbInfo) Mode() (hyperscan.ModeFlag, error) { return 0, err } - return hyperscan.ParseModeFlag(mode) // nolint: wrapcheck + return hyperscan.ParseModeFlag(mode) //nolint: wrapcheck } // Database is an immutable database that can be used by the Chimera scanning API. @@ -104,7 +103,7 @@ func newDatabase(db ch.Database) *baseDatabase { return &baseDatabase{db} } func (d *baseDatabase) c() ch.Database { return d.db } -func (d *baseDatabase) Size() (int, error) { return ch.DatabaseSize(d.db) } // nolint: wrapcheck +func (d *baseDatabase) Size() (int, error) { return ch.DatabaseSize(d.db) } //nolint: wrapcheck func (d *baseDatabase) Info() (DbInfo, error) { i, err := ch.DatabaseInfo(d.db) @@ -115,7 +114,7 @@ func (d *baseDatabase) Info() (DbInfo, error) { return DbInfo(i), nil } -func (d *baseDatabase) Close() error { return ch.FreeDatabase(d.db) } // nolint: wrapcheck +func (d *baseDatabase) Close() error { return ch.FreeDatabase(d.db) } //nolint: wrapcheck // Version identify this release version. // diff --git a/chimera/compile.go b/chimera/compile.go index 4c37e1e..f1cc944 100644 --- a/chimera/compile.go +++ b/chimera/compile.go @@ -144,20 +144,22 @@ func (b *DatabaseBuilder) Build() (Database, error) { db, err := ch.CompileExtMulti(b.Patterns, b.Mode, platform, b.MatchLimit, b.MatchLimitRecursion) if err != nil { - return nil, err // nolint: wrapcheck + return nil, err //nolint: wrapcheck } return newBlockDatabase(db), nil } // NewBlockDatabase compile expressions into a pattern database. -func NewBlockDatabase(patterns ...*Pattern) (BlockDatabase, error) { - db, err := Patterns(patterns).Build(Groups) +func NewBlockDatabase(patterns ...*Pattern) (bdb BlockDatabase, err error) { + var db Database + db, err = Patterns(patterns).Build(Groups) if err != nil { return nil, err } - return db.(BlockDatabase), err + bdb, _ = db.(*blockDatabase) + return } // NewManagedBlockDatabase is a wrapper for NewBlockDatabase that @@ -181,7 +183,7 @@ func NewManagedBlockDatabase(patterns ...*Pattern) (BlockDatabase, error) { func Compile(expr string) (Database, error) { db, err := ch.Compile(expr, 0, ch.Groups, nil) if err != nil { - return nil, err // nolint: wrapcheck + return nil, err //nolint: wrapcheck } return newBlockDatabase(db), nil diff --git a/chimera/runtime.go b/chimera/runtime.go index 1b4b885..db2938e 100644 --- a/chimera/runtime.go +++ b/chimera/runtime.go @@ -17,7 +17,7 @@ const ( type Capture = ch.Capture // Type used to differentiate the errors raised with the `ErrorEventHandler` callback. -type ErrorEvent = ch.ErrorEvent +type ErrorEvent = ch.ErrorEvent //nolint: errname const ( // PCRE hits its match limit and reports PCRE_ERROR_MATCHLIMIT. diff --git a/chimera/runtime_test.go b/chimera/runtime_test.go index bc255d9..7ec216c 100644 --- a/chimera/runtime_test.go +++ b/chimera/runtime_test.go @@ -20,7 +20,7 @@ var blockDatabaseConstructors = map[string]BlockDatabaseConstructor{ func TestBlockScanner(t *testing.T) { for dbType, dbConstructor := range blockDatabaseConstructors { Convey("Given a "+dbType+" block database", t, func() { - bdb, err := dbConstructor(chimera.NewPattern(`\d+`, 0)) // nolint: scopelint + bdb, err := dbConstructor(chimera.NewPattern(`\d+`, 0)) //nolint: scopelint So(err, ShouldBeNil) So(bdb, ShouldNotBeNil) @@ -48,7 +48,7 @@ func TestBlockScanner(t *testing.T) { func TestBlockMatcher(t *testing.T) { for dbType, dbConstructor := range blockDatabaseConstructors { Convey("Given a "+dbType+" block database", t, func() { - bdb, err := dbConstructor(chimera.NewPattern(`\d+`, 0)) // nolint: scopelint + bdb, err := dbConstructor(chimera.NewPattern(`\d+`, 0)) //nolint: scopelint So(err, ShouldBeNil) So(bdb, ShouldNotBeNil) diff --git a/chimera/scratch.go b/chimera/scratch.go index dbbfd0f..c15ef38 100644 --- a/chimera/scratch.go +++ b/chimera/scratch.go @@ -17,7 +17,7 @@ type Scratch struct { func NewScratch(db Database) (*Scratch, error) { s, err := ch.AllocScratch(db.(database).c()) if err != nil { - return nil, err // nolint: wrapcheck + return nil, err //nolint: wrapcheck } return &Scratch{s}, nil @@ -39,22 +39,24 @@ func NewManagedScratch(db Database) (*Scratch, error) { } // Size provides the size of the given scratch space. -func (s *Scratch) Size() (int, error) { return ch.ScratchSize(s.s) } // nolint: wrapcheck +func (s *Scratch) Size() (int, error) { return ch.ScratchSize(s.s) } //nolint: wrapcheck // Realloc reallocate the scratch for another database. func (s *Scratch) Realloc(db Database) error { - return ch.ReallocScratch(db.(database).c(), &s.s) // nolint: wrapcheck + r, _ := db.(database) + + return ch.ReallocScratch(r.c(), &s.s) //nolint: wrapcheck } // Clone allocate a scratch space that is a clone of an existing scratch space. func (s *Scratch) Clone() (*Scratch, error) { cloned, err := ch.CloneScratch(s.s) if err != nil { - return nil, err // nolint: wrapcheck + return nil, err //nolint: wrapcheck } return &Scratch{cloned}, nil } // Free a scratch block previously allocated. -func (s *Scratch) Free() error { return ch.FreeScratch(s.s) } // nolint: wrapcheck +func (s *Scratch) Free() error { return ch.FreeScratch(s.s) } //nolint: wrapcheck diff --git a/hyperscan/common.go b/hyperscan/common.go index 9c17143..aad21e1 100644 --- a/hyperscan/common.go +++ b/hyperscan/common.go @@ -57,7 +57,7 @@ type Database interface { Marshal() ([]byte, error) // Reconstruct a pattern database from a stream of bytes at a given memory location. - Unmarshal([]byte) error + Unmarshal(b []byte) error } // DbInfo identify the version and platform information for the supplied database. diff --git a/hyperscan/pattern.go b/hyperscan/pattern.go index 4ad59fc..d6aef3a 100644 --- a/hyperscan/pattern.go +++ b/hyperscan/pattern.go @@ -147,7 +147,7 @@ func ParseExprExt(s string) (ext *ExprExt, err error) { var n int if n, err = strconv.Atoi(value); err != nil { - return + return ext, fmt.Errorf("parse value, %w", err) } switch key { diff --git a/internal/ch/error.go b/internal/ch/error.go index 52d6b28..f0a6151 100644 --- a/internal/ch/error.go +++ b/internal/ch/error.go @@ -21,7 +21,7 @@ const ( ErrCompileError Error = C.CH_COMPILER_ERROR // ErrDatabaseVersionError is the error returned if the given database was built for a different version of Hyperscan. ErrDatabaseVersionError Error = C.CH_DB_VERSION_ERROR - // ErrDatabasePlatformError is the error returned if the given database was built for a different platform (i.e., CPU type). + // ErrDatabasePlatformError is the error returned if the given database was built for a different platform. ErrDatabasePlatformError Error = C.CH_DB_PLATFORM_ERROR // ErrDatabaseModeError is the error returned if the given database was built for a different mode of operation. ErrDatabaseModeError Error = C.CH_DB_MODE_ERROR diff --git a/internal/ch/runtime.go b/internal/ch/runtime.go index 33a7900..96eeccf 100644 --- a/internal/ch/runtime.go +++ b/internal/ch/runtime.go @@ -51,7 +51,7 @@ type Capture struct { type MatchEventHandler func(id uint, from, to uint64, flags uint, captured []*Capture, context interface{}) Callback // Type used to differentiate the errors raised with the `ErrorEventHandler` callback. -type ErrorEvent C.ch_error_event_t // nolint: errname +type ErrorEvent C.ch_error_event_t //nolint: errname const ( // PCRE hits its match limit and reports PCRE_ERROR_MATCHLIMIT. From 009f3eda370b7a753ac1a9957400b97e7b0571e8 Mon Sep 17 00:00:00 2001 From: Flier Lu Date: Sun, 1 Dec 2024 21:34:09 +0800 Subject: [PATCH 04/14] remove macos-latest with M1 chips --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 730a780..0e3b163 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,7 +56,7 @@ jobs: strategy: matrix: include: - - os: macos-latest + - os: macos-13 go: stable hyperscan_version: 5.4.1 pcre_version: 8.45 From cef54b1c09bfac712a83af7a02fa6fa871f31790 Mon Sep 17 00:00:00 2001 From: Flier Lu Date: Sun, 1 Dec 2024 22:02:13 +0800 Subject: [PATCH 05/14] remove the chimera build tag --- .github/workflows/ci.yml | 20 ++++++++++---------- .github/workflows/docker.yml | 6 +++--- README.md | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e3b163..19eb294 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,32 +60,32 @@ jobs: go: stable hyperscan_version: 5.4.1 pcre_version: 8.45 - build_flags: -tags hyperscan_v54,chimera + build_flags: -tags hyperscan_v54 chimera: true - os: macos-12 go: stable hyperscan_version: 5.2.1 pcre_version: 8.45 - build_flags: -tags hyperscan_v52,chimera + build_flags: -tags hyperscan_v52 chimera: true - os: macos-11 go: stable hyperscan_version: 5.1.1 pcre_version: 8.45 - build_flags: -tags chimera + build_flags: chimera: true - os: ubuntu-22.04 go: stable hyperscan_version: 5.4.1 pcre_version: 8.45 - build_flags: -tags hyperscan_v54,chimera + build_flags: -tags hyperscan_v54 chimera: true coverage: true - os: ubuntu-20.04 go: stable hyperscan_version: 5.2.1 pcre_version: 8.45 - build_flags: -tags hyperscan_v52,chimera + build_flags: -tags hyperscan_v52 chimera: true name: Go ${{ matrix.go }} tests @ ${{ matrix.os }} for hyperscan ${{ matrix.hyperscan_version }} runs-on: ${{ matrix.os }} @@ -107,7 +107,7 @@ jobs: cache_key: ${{ runner.os }}-build-hyperscan-${{ matrix.hyperscan_version }}-pcre-${{ matrix.pcre_version }} - name: Install Golang ${{ matrix.go }} - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} cache: true @@ -133,19 +133,19 @@ jobs: golangci: name: lint - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - name: Install Linux dependencies run: | sudo apt-get update sudo apt-get install -yq libhyperscan-dev libpcap-dev - - uses: actions/setup-go@v3 - - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v6 with: version: latest working-directory: hyperscan diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 668df04..4d5eb48 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -20,16 +20,16 @@ jobs: hyperscan_version: 5.4.2 pcre_version: 8.45 go_version: 1.23.3 - build_flags: -tags hyperscan_v54,chimera + build_flags: -tags hyperscan_v54 - ubuntu_version: 22.04 hyperscan_version: 5.2.1 pcre_version: 8.45 go_version: 1.22.9 - build_flags: -tags hyperscan_v52,chimera + build_flags: -tags hyperscan_v52 - ubuntu_version: 20.04 hyperscan_version: 5.1.1 pcre_version: 8.41 - build_flags: -tags chimera + build_flags: go_version: 1.21.13 name: tests @ ubuntu ${{ matrix.ubuntu_version }} for hyperscan ${{ matrix.hyperscan_version }} w/ ${{ matrix.build_flags }} env: diff --git a/README.md b/README.md index 34636e3..5ff0937 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ It is recommended to compile and link Chimera using static libraries. $ mkdir build && cd build $ cmake .. -G Ninja -DBUILD_STATIC_LIBS=on $ ninja && ninja install -$ go get -u -tags chimera github.com/flier/gohs/hyperscan +$ go get -u github.com/flier/gohs/hyperscan ``` ### Note From d8213e29104b27f0132304a4cada5dd05e1e4144 Mon Sep 17 00:00:00 2001 From: Flier Lu Date: Sun, 1 Dec 2024 22:09:16 +0800 Subject: [PATCH 06/14] upgrade actions/setup-go --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 19eb294..251d41d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Golang ${{ matrix.go }} - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} cache: true From d5546f3e034563ab832f9d9acd2d821d0b91e528 Mon Sep 17 00:00:00 2001 From: Flier Lu Date: Sun, 1 Dec 2024 22:15:12 +0800 Subject: [PATCH 07/14] upgrade actions --- .github/workflows/docker.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4d5eb48..4e9dfce 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -36,16 +36,16 @@ jobs: LATEST_TAG: flier/gohs:${{ matrix.hyperscan_version }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: load: true build-args: | From 439a3482f4a8e9a9e75bd08e78c636c0cafcea9c Mon Sep 17 00:00:00 2001 From: Flier Lu Date: Sun, 1 Dec 2024 22:17:34 +0800 Subject: [PATCH 08/14] fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5ff0937..b91ea80 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ $ go get -u github.com/flier/gohs/hyperscan You need to download the PCRE library source code to build Chimera, see [Chimera Requirements](https://intel.github.io/hyperscan/dev-reference/chimera.html#requirements) for more details -### Vectorscan +## Vectorscan The Intel's Hyperscan relies on the SSE/AVX instruction set for x86 platform. If you need to use it on other platforms such as ARM, you can install [Vectorscan](https://github.com/VectorCamp/vectorscan) which is a portable fork of Hyperscan that supports the ARM NEON/ASIMD and Power VSX. From 0ea0873b67d2dd4012a7ae6f101d11452283531d Mon Sep 17 00:00:00 2001 From: Flier Lu Date: Sun, 1 Dec 2024 22:17:45 +0800 Subject: [PATCH 09/14] remove missed chimera tag --- internal/ch/error_v54.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/ch/error_v54.go b/internal/ch/error_v54.go index 439bf78..17e9086 100644 --- a/internal/ch/error_v54.go +++ b/internal/ch/error_v54.go @@ -1,5 +1,5 @@ -//go:build hyperscan_v54 && chimera -// +build hyperscan_v54,chimera +//go:build hyperscan_v54 +// +build hyperscan_v54 package ch From f6f1b22c27f705112c66edf9e22f66a6e4b62422 Mon Sep 17 00:00:00 2001 From: Flier Lu Date: Sun, 1 Dec 2024 22:27:25 +0800 Subject: [PATCH 10/14] remove macos-11 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 251d41d..9a5e0f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: test: strategy: matrix: - os: [ubuntu-22.04, ubuntu-20.04, macos-12, macos-11] + os: [ubuntu-22.04, ubuntu-20.04, macos-13, macos-12] go: [stable, 1.22.x, 1.18.x] name: Go ${{ matrix.go }} tests @ ${{ matrix.os }} for hyperscan runs-on: ${{ matrix.os }} From d43d1b874aaba03076d4511b702a303c04fdf05c Mon Sep 17 00:00:00 2001 From: Flier Lu Date: Sun, 1 Dec 2024 22:35:44 +0800 Subject: [PATCH 11/14] disable fat runtime --- .github/workflows/docker.yml | 2 +- Dockerfile | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4e9dfce..3fd4a0f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: include: - - ubuntu_version: 22.04 + - ubuntu_version: 24.04 hyperscan_version: 5.4.2 pcre_version: 8.45 go_version: 1.23.3 diff --git a/Dockerfile b/Dockerfile index 0a89ac7..35cd7fe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 -ARG UBUNTU_VERSION=22.04 +ARG UBUNTU_VERSION=24.04 FROM ubuntu:${UBUNTU_VERSION} as build @@ -29,7 +29,7 @@ EOT # Download Hyperscan -ARG HYPERSCAN_VERSION=5.4.1 +ARG HYPERSCAN_VERSION=5.4.2 ENV HYPERSCAN_DIR=/hyperscan @@ -65,6 +65,7 @@ RUN < Date: Sun, 1 Dec 2024 22:52:22 +0800 Subject: [PATCH 12/14] remove macos-11 --- .github/workflows/ci.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a5e0f5..59160d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: test: strategy: matrix: - os: [ubuntu-22.04, ubuntu-20.04, macos-13, macos-12] + os: [ubuntu-24.04, ubuntu-22.04, macos-13, macos-12] go: [stable, 1.22.x, 1.18.x] name: Go ${{ matrix.go }} tests @ ${{ matrix.os }} for hyperscan runs-on: ${{ matrix.os }} @@ -68,20 +68,14 @@ jobs: pcre_version: 8.45 build_flags: -tags hyperscan_v52 chimera: true - - os: macos-11 - go: stable - hyperscan_version: 5.1.1 - pcre_version: 8.45 - build_flags: - chimera: true - - os: ubuntu-22.04 + - os: ubuntu-24.04 go: stable hyperscan_version: 5.4.1 pcre_version: 8.45 build_flags: -tags hyperscan_v54 chimera: true coverage: true - - os: ubuntu-20.04 + - os: ubuntu-22.04 go: stable hyperscan_version: 5.2.1 pcre_version: 8.45 From 87b3bc10adf71b828fff81580bd33a0a2510a9c4 Mon Sep 17 00:00:00 2001 From: Flier Lu Date: Sun, 1 Dec 2024 23:18:40 +0800 Subject: [PATCH 13/14] use python3 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 35cd7fe..47c7dac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ RUN < Date: Sun, 1 Dec 2024 23:42:20 +0800 Subject: [PATCH 14/14] remove old versions --- .github/workflows/docker.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3fd4a0f..17895ed 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -21,16 +21,16 @@ jobs: pcre_version: 8.45 go_version: 1.23.3 build_flags: -tags hyperscan_v54 - - ubuntu_version: 22.04 - hyperscan_version: 5.2.1 - pcre_version: 8.45 - go_version: 1.22.9 - build_flags: -tags hyperscan_v52 - - ubuntu_version: 20.04 - hyperscan_version: 5.1.1 - pcre_version: 8.41 - build_flags: - go_version: 1.21.13 + # - ubuntu_version: 22.04 + # hyperscan_version: 5.2.1 + # pcre_version: 8.45 + # go_version: 1.22.9 + # build_flags: -tags hyperscan_v52 + # - ubuntu_version: 20.04 + # hyperscan_version: 5.1.1 + # pcre_version: 8.41 + # build_flags: + # go_version: 1.21.13 name: tests @ ubuntu ${{ matrix.ubuntu_version }} for hyperscan ${{ matrix.hyperscan_version }} w/ ${{ matrix.build_flags }} env: LATEST_TAG: flier/gohs:${{ matrix.hyperscan_version }}