Skip to content
Prev Previous commit
Next Next commit
run test in docker-compose
  • Loading branch information
flier committed Apr 18, 2023
commit d44fc0bc7f43b7948b4963de35eef87f838cb1ad
15 changes: 2 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ jobs:
pcre_version: 8.45
build_flags: -tags hyperscan_v54,chimera
chimera: true
- os: macos-latest
- os: macos-12
go: stable
hyperscan_version: 5.2.1
pcre_version: 8.45
build_flags: -tags hyperscan_v52,chimera
chimera: true
- os: macos-latest
- os: macos-11
go: stable
hyperscan_version: 5.1.1
pcre_version: 8.45
Expand All @@ -87,17 +87,6 @@ jobs:
pcre_version: 8.45
build_flags: -tags hyperscan_v52,chimera
chimera: true
- os: ubuntu-20.04
go: stable
hyperscan_version: 5.1.1
pcre_version: 8.45
build_flags: -tags chimera
chimera: true
- os: ubuntu-20.04
go: stable
hyperscan_version: 4.7.0
pcre_version: 8.41
build_flags: -tags hyperscan_v4
name: Go ${{ matrix.go }} tests @ ${{ matrix.os }} for hyperscan ${{ matrix.hyperscan_version }}
runs-on: ${{ matrix.os }}
env:
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,15 @@ jobs:
- name: Test
run: |
docker run --rm ${{ env.LATEST_TAG }}

docker-test:
runs-on: ubuntu-latest
strategy:
matrix:
version: [hyperscan-5.4, hyperscan-5.2, hyperscan-4.7]
steps:
- uses: actions/checkout@v3
- uses: isbang/[email protected]
with:
compose-file: "./docker-compose.yml"
services: ${{ matrix.version }}
54 changes: 33 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ ARG PCRE_VERSION=8.45
# Install dependencies

ENV DEBIAN_FRONTEND noninteractive

# hadolint ignore=DL3008
RUN <<EOT bash
apt-get update
apt-get update
apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
Expand All @@ -23,57 +25,67 @@ RUN <<EOT bash
python2.7 \
ragel \
wget \
zlib1g-dev
zlib1g-dev
rm -rf /var/lib/apt/lists/*
EOT

# Install golang

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

RUN <<EOT bash
rm -rf /usr/local/go
tar -C /usr/local -xzf /go${GO_VERSION}.tar.gz
rm /go${GO_VERSION}.tar.gz
rm -rf /usr/local/go
tar -C /usr/local -xzf /go${GO_VERSION}.linux-amd64.tar.gz
rm /go${GO_VERSION}.linux-amd64.tar.gz
EOT

ENV PATH=/usr/local/go/bin:${PATH}
ENV PATH="/usr/local/go/bin:${PATH}"

# Download Hyperscan

ENV HYPERSCAN_DIR=/hyperscan

WORKDIR ${HYPERSCAN_DIR}

ADD https://github.com/intel/hyperscan/archive/refs/tags/v${HYPERSCAN_VERSION}.tar.gz /hyperscan-v${HYPERSCAN_VERSION}.tar.gz
RUN <<EOT bash
mkdir ${HYPERSCAN_DIR}
RUN <<EOT bash
tar xf /hyperscan-v${HYPERSCAN_VERSION}.tar.gz -C ${HYPERSCAN_DIR} --strip-components=1
rm /hyperscan-v${HYPERSCAN_VERSION}.tar.gz
EOT

ADD https://sourceforge.net/projects/pcre/files/pcre/${PCRE_VERSION}/pcre-${PCRE_VERSION}.tar.gz/download /pcre-${PCRE_VERSION}.tar.gz
RUN <<EOT bash
mkdir ${HYPERSCAN_DIR}/pcre
tar xf /pcre-${PCRE_VERSION}.tar.gz -C ${HYPERSCAN_DIR}/pcre --strip-components=1

WORKDIR ${HYPERSCAN_DIR}/pcre

RUN <<EOT bash
tar xf /pcre-${PCRE_VERSION}.tar.gz -C ${HYPERSCAN_DIR}/pcre --strip-components=1
rm /pcre-${PCRE_VERSION}.tar.gz
EOT

# Install Hyperscan

ENV INSTALL_DIR=/usr/local

RUN <<EOT bash
mkdir ${HYPERSCAN_DIR}/build
cd ${HYPERSCAN_DIR}/build
cmake -G Ninja -DBUILD_STATIC_LIBS=on -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} ${HYPERSCAN_DIR}
ninja
ninja install
mv ${HYPERSCAN_DIR}/build/lib/lib*.a ${INSTALL_DIR}/lib/
WORKDIR ${HYPERSCAN_DIR}/build

ARG CMAKE_BUILD_TYPE=RelWithDebInfo

RUN <<EOT bash
cmake -G Ninja \
-DBUILD_STATIC_LIBS=ON \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \
..
ninja
ninja install
mv ${HYPERSCAN_DIR}/build/lib/lib*.a ${INSTALL_DIR}/lib/
EOT

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

# Add gohs code

ADD . /gohs/
COPY . /gohs/

WORKDIR /gohs
ENTRYPOINT ["/usr/local/go/bin/go"]
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
labels:
hyperscan: 5.4
args:
HYPERSCAN_VERSION: 5.4.0
HYPERSCAN_VERSION: 5.4.1
command: test -tags hyperscan_v54 ./...
hyperscan-5.2:
build:
Expand Down