Skip to content

Commit

Permalink
Merge pull request #272 from ns1labs/release
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
Leonardo Parente authored Apr 22, 2022
2 parents ed0ba4f + 1ecddaa commit efbce2e
Show file tree
Hide file tree
Showing 171 changed files with 5,904 additions and 22,587 deletions.
23 changes: 23 additions & 0 deletions .github/actions/build-cpp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM debian:bullseye-slim

LABEL author="Everton Haise Taques <[email protected]>"
LABEL maintainer="NS1 Labs"
LABEL version="1.0.0"

ENV BUILD_DEPS "g++ cmake make git pkgconf jq python3-pip python3-setuptools ca-certificates libasan6 zip curl"

COPY ./entrypoint.sh /entrypoint.sh

RUN mkdir -p /pktvisor-src

WORKDIR /pktvisor-src

RUN apt-get update && \
apt-get upgrade --yes --force-yes && \
apt-get install --yes --force-yes --no-install-recommends ${BUILD_DEPS} && \
pip3 install conan

RUN chmod +x /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]

6 changes: 6 additions & 0 deletions .github/actions/build-cpp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Docker test action

Github Action to build, compact and publish pktvisor symbol to backtrace.io



24 changes: 24 additions & 0 deletions .github/actions/build-cpp/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'docker'
author: 'Everton Haise Taques <[email protected]>'
description: 'NS1 Labs'

inputs:
context:
description: "Docker build context"
required: true
default: "./"

symbol_url:
description: "symbol url"
required: true
default: ""

file:
description: "Dockerfile used to build the image"
required: true
default: "./Dockerfile"

runs:
using: 'docker'
image: 'Dockerfile'

49 changes: 49 additions & 0 deletions .github/actions/build-cpp/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
#
function validateParams() {
echo "========================= Checking parameters ========================="
[[ -z $INPUT_SYMBOL_URL ]] && echo "Backtrace symbol url is required" && exit 1 || echo "Backtrace symbol url present"
}

function build() {
echo "========================= Building pktvisor ========================="
cp -rf /github/workspace/.git/ /pktvisor-src/.git/
cp -rf /github/workspace/src/ /pktvisor-src/src/
cp -rf /github/workspace/cmd/ /pktvisor-src/cmd/
cp -rf /github/workspace/3rd/ /pktvisor-src/3rd/
cp -rf /github/workspace/docker/ /pktvisor-src/docker/
cp -rf /github/workspace/golang/ /pktvisor-src/golang/
cp -rf /github/workspace/integration_tests/ /pktvisor-src/integration_tests/
cp -rf /github/workspace/cmake/ /pktvisor-src/cmake/
cp -rf /github/workspace/CMakeLists.txt /pktvisor-src/
cp -rf /github/workspace/conanfile.txt /pktvisor-src/
mkdir /tmp/build
cd /tmp/build
conan profile new --detect default && \
conan profile update settings.compiler.libcxx=libstdc++11 default && \
conan config set general.revisions_enabled=1
PKG_CONFIG_PATH=/local/lib/pkgconfig cmake -DCMAKE_BUILD_TYPE=Debug -DASAN=ON /pktvisor-src && \
make all -j 4
}

function compact() {
echo "========================= Compacting binary and copying ========================="
cd /tmp/build
zip pktvisord.zip /tmp/build/bin/pktvisord
cp -rf /tmp/build/bin/pktvisord /github/workspace/
cp -rf /tmp/build/bin/crashpad_handler /github/workspace/
cp -rf /tmp/build/bin/pktvisor-reader /github/workspace/
#version for pktvisor-cli
cp -rf /pktvisor-src/golang/pkg/client/version.go /github/workspace/version.go
}

function publish() {
echo "========================= Publishing symbol to backtrace ========================="
cd /tmp/build
curl --data-binary @pktvisord.zip -H "Expect: gzip" "${INPUT_SYMBOL_URL}"
}

validateParams
build
compact
publish
12 changes: 12 additions & 0 deletions .github/actions/build-go/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM golang:latest

LABEL author="Everton Haise Taques <[email protected]>"
LABEL maintainer="NS1 Labs"
LABEL version="1.0.0"

COPY ./entrypoint.sh /entrypoint.sh

RUN chmod +x /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]

6 changes: 6 additions & 0 deletions .github/actions/build-go/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Docker test action

Github Action to build pktvisor-cli



19 changes: 19 additions & 0 deletions .github/actions/build-go/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'docker'
author: 'Everton Haise Taques <[email protected]>'
description: 'NS1 Labs'

inputs:
context:
description: "Docker build context"
required: true
default: "./"

file:
description: "Dockerfile used to build the image"
required: true
default: "./Dockerfile"

runs:
using: 'docker'
image: 'Dockerfile'

18 changes: 18 additions & 0 deletions .github/actions/build-go/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
#
function build() {
echo "========================= Building pktvisor-cli ========================="
cp -rf golang/ /src/
# Copying this from previous build (cpp)
cp -rf ./version.go /src/pkg/client/version.go
cd /src
go build -o pktvisor-cli cmd/pktvisor-cli/main.go
}

function copy() {
echo "========================= Copying binary ========================="
cp -rf /src/pktvisor-cli /github/workspace/
}

build
copy
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ env:
BUILD_TYPE: Release
CTEST_OUTPUT_ON_FAILURE: 1
CONAN_NON_INTERACTIVE: 1
CONAN_REVISIONS_ENABLED: 1

jobs:
build:
Expand Down
196 changes: 196 additions & 0 deletions .github/workflows/cross.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
---
name: Cross Compilation

on:
workflow_dispatch:
pull_request:
branches:
- develop
#- release
push:
branches:
- develop
#- release

jobs:
pkvisor:
name: pktvisor
runs-on: ubuntu-latest
strategy:
matrix:
include:
- arch: x86_64
conan_arch: x86_64
toolchain: http://musl.cc/x86_64-linux-musl-cross.tgz
cc: x86_64-linux-musl-gcc
cxx: x86_64-linux-musl-g++
ldflags: "-static"
- arch: armv7lh # ARMv7 little-endian hard-float
conan_arch: armv7hf
toolchain: http://musl.cc/armv7l-linux-musleabihf-cross.tgz
cc: armv7l-linux-musleabihf-gcc
cxx: armv7l-linux-musleabihf-g++
- arch: aarch64
conan_arch: armv8
toolchain: http://musl.cc/aarch64-linux-musl-cross.tgz
cc: aarch64-linux-musl-gcc
cxx: aarch64-linux-musl-g++
env:
CC: gcc-10
CXX: g++-10
CONAN_USER_HOME: "${{github.workspace}}"
steps:
- name: Install sccache from cache
id: cache-sccache
uses: actions/cache@v2
with:
path: bin/sccache
key: sccache-v0.2.15
- name: Install sccache
if: steps.cache-sccache.outputs.cache-hit != 'true'
run: |
mkdir -p bin
curl -L https://github.com/mozilla/sccache/releases/download/v0.2.15/sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz | \
tar -C bin -xz --strip-components=1 sccache-v0.2.15-x86_64-unknown-linux-musl/sccache
chmod +x bin/sccache
- name: Install compiler toolchain from cache
id: cache-toolchain
uses: actions/cache@v2
with:
path: toolchain
key: toolchain-test-${{matrix.toolchain}}
- name: Install compiler toolchain
if: steps.cache-toolchain.outputs.cache-hit != 'true'
run: |
mkdir -p toolchain
curl -L "${{matrix.toolchain}}" | tar -C toolchain -xz --strip-components=1
- name: Install Conan
run: pip install --no-cache-dir conan
- name: Create Conan configuration
run: |
# init config
CONAN_V2_MODE=1 conan config init
conan config set general.revisions_enabled=1
conan remote add ns1labs https://ns1labs.jfrog.io/artifactory/api/conan/ns1labs-conan
# add custom compiler settings for libc
python3 -c 'import yaml; p = "${{env.CONAN_USER_HOME}}/.conan/settings.yml"; d = yaml.safe_load(open(p)); d["compiler"]["gcc"]["libc"] = ["None", "glibc", "musl"]; yaml.safe_dump(d, open(p, "w"))'
- name: Create Conan host profile
run: |
cat > "${{env.CONAN_USER_HOME}}/.conan/profiles/host" << "EOF"
[settings]
os=Linux
os_build=Linux
arch=${{matrix.conan_arch}}
arch_build=x86_64
compiler=gcc
compiler.version=11
compiler.libcxx=libstdc++11
compiler.libc=musl
build_type=Release
[options]
pcapplusplus:with_musl=True
[build_requires]
[env]
CC=${{github.workspace}}/toolchain/bin/${{matrix.cc}}
CXX=${{github.workspace}}/toolchain/bin/${{matrix.cxx}}
LDFLAGS=${{matrix.ldflags}}
EOF
- name: Restore sccache
uses: actions/cache@v2
with:
path: ~/.cache/sccache
key: sccache-${{matrix.arch}}-${{github.head_ref||github.event.ref}}-${{github.run_id}}
restore-keys: |
sccache-${{matrix.arch}}-${{github.head_ref||github.event.ref}}-
sccache-${{matrix.arch}}-${{github.base_ref||github.event.repository.default_branch}}-
- name: Checkout sources
uses: actions/checkout@v2
with:
path: src
- name: Install dependencies
run: |
mkdir build
cd build
conan install -pr:b default -pr:h host -g virtualenv --build=missing "${{github.workspace}}/src"
- name: Configure
run: |
cd build
source environment.sh.env
export CC CXX
export LDFLAGS=-static
cmake "${{github.workspace}}/src" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_LAUNCHER="${{github.workspace}}/bin/sccache" -DCMAKE_CXX_COMPILER_LAUNCHER="${{github.workspace}}/bin/sccache" \
-DPKTVISOR_CONAN_INIT=OFF -DPKTVISOR_CONAN_BUILD="never" -DPKTVISOR_CONAN_BUILD_PROFILE="default" -DPKTVISOR_CONAN_HOST_PROFILE="host" \
-DProtobuf_PROTOC_EXECUTABLE=$(command -v protoc) \
-DCORRADE_RC_PROGRAM=$(command -v corrade-rc) \
-DCMAKE_CXX_STANDARD_LIBRARIES=-latomic
- name: Build
run: |
cd build
make -j4 VERBOSE=1
- name: Print sccache stats
run: |
"${{github.workspace}}/bin/sccache" -s
- name: Upload pktvisord
uses: actions/upload-artifact@v2
with:
name: pktvisord-linux-${{matrix.arch}}-static
path: build/bin/pktvisord
retention-days: 7

- name: Upload pktvisor-reader
uses: actions/upload-artifact@v2
with:
name: pktvisor-reader-linux-${{matrix.arch}}-static
path: build/bin/pktvisor-reader
retention-days: 7

pkvisor-cli:
name: pktvisor-cli
runs-on: ubuntu-latest
strategy:
matrix:
os: [linux, macos]
arch: [x86_64, armv7lh, aarch64]
exclude:
- os: macos
arch: armv7lh
steps:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Checkout sources
uses: actions/checkout@v2
with:
path: src
- name: Configure
run: |
VERSION_ONLY=1 cmake src
- name: Build
run: |
if [ "${{matrix.os}}" = macos ]; then
export GOOS=darwin
fi
if [ "${{matrix.arch}}" = armv7lh ]; then
export GOARCH=arm
elif [ "${{matrix.arch}}" = aarch64 ]; then
export GOARCH=arm64
fi
cd src/golang
go build -o ${{github.workspace}}/pktvisor-cli ./cmd/pktvisor-cli
- name: Upload pktvisor-cli
uses: actions/upload-artifact@v2
with:
name: pktvisor-cli-${{matrix.os}}-${{matrix.arch}}
path: pktvisor-cli
retention-days: 7
Loading

0 comments on commit efbce2e

Please sign in to comment.