Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove chimera build tag #65

Merged
merged 14 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 17 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
test:
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-20.04, macos-12, macos-11]
go: [stable, 1.20.x, 1.19.x, 1.18.x]
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 }}
steps:
Expand All @@ -34,10 +34,10 @@ 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
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
cache: true
Expand All @@ -56,36 +56,30 @@ jobs:
strategy:
matrix:
include:
- os: macos-latest
- os: macos-13
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
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
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
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 }}
Expand All @@ -94,7 +88,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
Expand All @@ -107,7 +101,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
Expand All @@ -133,19 +127,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/checkout@v3
- 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
39 changes: 17 additions & 22 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,36 @@ jobs:
strategy:
matrix:
include:
- ubuntu_version: 22.04
- ubuntu_version: 24.04
hyperscan_version: 5.4.2
pcre_version: 8.45
go_version: 1.20.3
build_flags: -tags hyperscan_v54,chimera
- ubuntu_version: 20.04
hyperscan_version: 5.2.1
pcre_version: 8.45
go_version: 1.19.8
build_flags: -tags hyperscan_v52,chimera
- ubuntu_version: 20.04
hyperscan_version: 5.1.1
pcre_version: 8.45
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.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
name: tests @ ubuntu ${{ matrix.ubuntu_version }} for hyperscan ${{ matrix.hyperscan_version }} w/ ${{ matrix.build_flags }}
env:
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: |
Expand Down
20 changes: 9 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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$
Expand Down Expand Up @@ -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
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# syntax=docker/dockerfile:1

ARG UBUNTU_VERSION=22.04
ARG UBUNTU_VERSION=24.04

FROM ubuntu:${UBUNTU_VERSION} as build

Check warning on line 5 in Dockerfile

View workflow job for this annotation

GitHub Actions / tests @ ubuntu 24.04 for hyperscan 5.4.2 w/ -tags hyperscan_v54

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

# Install dependencies

ENV DEBIAN_FRONTEND noninteractive

Check warning on line 9 in Dockerfile

View workflow job for this annotation

GitHub Actions / tests @ ubuntu 24.04 for hyperscan 5.4.2 w/ -tags hyperscan_v54

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

# hadolint ignore=DL3008
RUN <<EOT bash
Expand All @@ -20,7 +20,7 @@
libpcap-dev \
ninja-build \
pkg-config \
python2.7 \
python3 \
ragel \
wget \
zlib1g-dev
Expand All @@ -29,7 +29,7 @@

# Download Hyperscan

ARG HYPERSCAN_VERSION=5.4.1
ARG HYPERSCAN_VERSION=5.4.2

ENV HYPERSCAN_DIR=/hyperscan

Expand Down Expand Up @@ -65,6 +65,7 @@
-DBUILD_STATIC_LIBS=ON \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \
-DFAT_RUNTIME=off \
..
ninja
ninja install
Expand All @@ -75,7 +76,7 @@

# Install dependencies

ENV DEBIAN_FRONTEND noninteractive

Check warning on line 79 in Dockerfile

View workflow job for this annotation

GitHub Actions / tests @ ubuntu 24.04 for hyperscan 5.4.2 w/ -tags hyperscan_v54

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

# hadolint ignore=DL3008
RUN <<EOT bash
Expand All @@ -90,7 +91,7 @@

# Install golang

ARG GO_VERSION=1.20.3
ARG GO_VERSION=1.23.3

ADD https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz /

Expand All @@ -105,7 +106,7 @@

COPY --from=build ${INSTALL_DIR} ${INSTALL_DIR}

ENV PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${INSTALL_DIR}/lib/pkgconfig"

Check warning on line 109 in Dockerfile

View workflow job for this annotation

GitHub Actions / tests @ ubuntu 24.04 for hyperscan 5.4.2 w/ -tags hyperscan_v54

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$PKG_CONFIG_PATH' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

# Add gohs code

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ 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

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.

Expand Down
3 changes: 0 additions & 3 deletions bench/go/chimera_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build chimera
// +build chimera

package scan_test

import (
Expand Down
5 changes: 1 addition & 4 deletions chimera/api.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build chimera
// +build chimera

package chimera

import (
Expand Down Expand Up @@ -36,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
Expand Down
3 changes: 0 additions & 3 deletions chimera/api_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build chimera
// +build chimera

package chimera_test

import (
Expand Down
5 changes: 1 addition & 4 deletions chimera/block.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build chimera
// +build chimera

package chimera

import (
Expand Down Expand Up @@ -98,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 {
Expand Down
12 changes: 4 additions & 8 deletions chimera/common.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build chimera
// +build chimera

package chimera

import (
Expand Down Expand Up @@ -41,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+)$`)
Expand Down Expand Up @@ -80,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.
Expand All @@ -107,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)
Expand All @@ -118,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.
//
Expand Down
3 changes: 0 additions & 3 deletions chimera/common_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build chimera
// +build chimera

package chimera_test

import (
Expand Down
Loading
Loading