Skip to content

Commit efbce2e

Browse files
author
Leonardo Parente
authored
Merge pull request #272 from ns1labs/release
Release
2 parents ed0ba4f + 1ecddaa commit efbce2e

File tree

171 files changed

+5904
-22587
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+5904
-22587
lines changed

Diff for: .github/actions/build-cpp/Dockerfile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM debian:bullseye-slim
2+
3+
LABEL author="Everton Haise Taques <[email protected]>"
4+
LABEL maintainer="NS1 Labs"
5+
LABEL version="1.0.0"
6+
7+
ENV BUILD_DEPS "g++ cmake make git pkgconf jq python3-pip python3-setuptools ca-certificates libasan6 zip curl"
8+
9+
COPY ./entrypoint.sh /entrypoint.sh
10+
11+
RUN mkdir -p /pktvisor-src
12+
13+
WORKDIR /pktvisor-src
14+
15+
RUN apt-get update && \
16+
apt-get upgrade --yes --force-yes && \
17+
apt-get install --yes --force-yes --no-install-recommends ${BUILD_DEPS} && \
18+
pip3 install conan
19+
20+
RUN chmod +x /entrypoint.sh
21+
22+
ENTRYPOINT [ "/entrypoint.sh" ]
23+

Diff for: .github/actions/build-cpp/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Docker test action
2+
3+
Github Action to build, compact and publish pktvisor symbol to backtrace.io
4+
5+
6+

Diff for: .github/actions/build-cpp/action.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: 'docker'
2+
author: 'Everton Haise Taques <[email protected]>'
3+
description: 'NS1 Labs'
4+
5+
inputs:
6+
context:
7+
description: "Docker build context"
8+
required: true
9+
default: "./"
10+
11+
symbol_url:
12+
description: "symbol url"
13+
required: true
14+
default: ""
15+
16+
file:
17+
description: "Dockerfile used to build the image"
18+
required: true
19+
default: "./Dockerfile"
20+
21+
runs:
22+
using: 'docker'
23+
image: 'Dockerfile'
24+

Diff for: .github/actions/build-cpp/entrypoint.sh

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
#
3+
function validateParams() {
4+
echo "========================= Checking parameters ========================="
5+
[[ -z $INPUT_SYMBOL_URL ]] && echo "Backtrace symbol url is required" && exit 1 || echo "Backtrace symbol url present"
6+
}
7+
8+
function build() {
9+
echo "========================= Building pktvisor ========================="
10+
cp -rf /github/workspace/.git/ /pktvisor-src/.git/
11+
cp -rf /github/workspace/src/ /pktvisor-src/src/
12+
cp -rf /github/workspace/cmd/ /pktvisor-src/cmd/
13+
cp -rf /github/workspace/3rd/ /pktvisor-src/3rd/
14+
cp -rf /github/workspace/docker/ /pktvisor-src/docker/
15+
cp -rf /github/workspace/golang/ /pktvisor-src/golang/
16+
cp -rf /github/workspace/integration_tests/ /pktvisor-src/integration_tests/
17+
cp -rf /github/workspace/cmake/ /pktvisor-src/cmake/
18+
cp -rf /github/workspace/CMakeLists.txt /pktvisor-src/
19+
cp -rf /github/workspace/conanfile.txt /pktvisor-src/
20+
mkdir /tmp/build
21+
cd /tmp/build
22+
conan profile new --detect default && \
23+
conan profile update settings.compiler.libcxx=libstdc++11 default && \
24+
conan config set general.revisions_enabled=1
25+
PKG_CONFIG_PATH=/local/lib/pkgconfig cmake -DCMAKE_BUILD_TYPE=Debug -DASAN=ON /pktvisor-src && \
26+
make all -j 4
27+
}
28+
29+
function compact() {
30+
echo "========================= Compacting binary and copying ========================="
31+
cd /tmp/build
32+
zip pktvisord.zip /tmp/build/bin/pktvisord
33+
cp -rf /tmp/build/bin/pktvisord /github/workspace/
34+
cp -rf /tmp/build/bin/crashpad_handler /github/workspace/
35+
cp -rf /tmp/build/bin/pktvisor-reader /github/workspace/
36+
#version for pktvisor-cli
37+
cp -rf /pktvisor-src/golang/pkg/client/version.go /github/workspace/version.go
38+
}
39+
40+
function publish() {
41+
echo "========================= Publishing symbol to backtrace ========================="
42+
cd /tmp/build
43+
curl --data-binary @pktvisord.zip -H "Expect: gzip" "${INPUT_SYMBOL_URL}"
44+
}
45+
46+
validateParams
47+
build
48+
compact
49+
publish

Diff for: .github/actions/build-go/Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM golang:latest
2+
3+
LABEL author="Everton Haise Taques <[email protected]>"
4+
LABEL maintainer="NS1 Labs"
5+
LABEL version="1.0.0"
6+
7+
COPY ./entrypoint.sh /entrypoint.sh
8+
9+
RUN chmod +x /entrypoint.sh
10+
11+
ENTRYPOINT [ "/entrypoint.sh" ]
12+

Diff for: .github/actions/build-go/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Docker test action
2+
3+
Github Action to build pktvisor-cli
4+
5+
6+

Diff for: .github/actions/build-go/action.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'docker'
2+
author: 'Everton Haise Taques <[email protected]>'
3+
description: 'NS1 Labs'
4+
5+
inputs:
6+
context:
7+
description: "Docker build context"
8+
required: true
9+
default: "./"
10+
11+
file:
12+
description: "Dockerfile used to build the image"
13+
required: true
14+
default: "./Dockerfile"
15+
16+
runs:
17+
using: 'docker'
18+
image: 'Dockerfile'
19+

Diff for: .github/actions/build-go/entrypoint.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
#
3+
function build() {
4+
echo "========================= Building pktvisor-cli ========================="
5+
cp -rf golang/ /src/
6+
# Copying this from previous build (cpp)
7+
cp -rf ./version.go /src/pkg/client/version.go
8+
cd /src
9+
go build -o pktvisor-cli cmd/pktvisor-cli/main.go
10+
}
11+
12+
function copy() {
13+
echo "========================= Copying binary ========================="
14+
cp -rf /src/pktvisor-cli /github/workspace/
15+
}
16+
17+
build
18+
copy

Diff for: .github/workflows/build.yml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ env:
1616
BUILD_TYPE: Release
1717
CTEST_OUTPUT_ON_FAILURE: 1
1818
CONAN_NON_INTERACTIVE: 1
19+
CONAN_REVISIONS_ENABLED: 1
1920

2021
jobs:
2122
build:

Diff for: .github/workflows/cross.yml

+196
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
---
2+
name: Cross Compilation
3+
4+
on:
5+
workflow_dispatch:
6+
pull_request:
7+
branches:
8+
- develop
9+
#- release
10+
push:
11+
branches:
12+
- develop
13+
#- release
14+
15+
jobs:
16+
pkvisor:
17+
name: pktvisor
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
include:
22+
- arch: x86_64
23+
conan_arch: x86_64
24+
toolchain: http://musl.cc/x86_64-linux-musl-cross.tgz
25+
cc: x86_64-linux-musl-gcc
26+
cxx: x86_64-linux-musl-g++
27+
ldflags: "-static"
28+
- arch: armv7lh # ARMv7 little-endian hard-float
29+
conan_arch: armv7hf
30+
toolchain: http://musl.cc/armv7l-linux-musleabihf-cross.tgz
31+
cc: armv7l-linux-musleabihf-gcc
32+
cxx: armv7l-linux-musleabihf-g++
33+
- arch: aarch64
34+
conan_arch: armv8
35+
toolchain: http://musl.cc/aarch64-linux-musl-cross.tgz
36+
cc: aarch64-linux-musl-gcc
37+
cxx: aarch64-linux-musl-g++
38+
env:
39+
CC: gcc-10
40+
CXX: g++-10
41+
CONAN_USER_HOME: "${{github.workspace}}"
42+
steps:
43+
- name: Install sccache from cache
44+
id: cache-sccache
45+
uses: actions/cache@v2
46+
with:
47+
path: bin/sccache
48+
key: sccache-v0.2.15
49+
- name: Install sccache
50+
if: steps.cache-sccache.outputs.cache-hit != 'true'
51+
run: |
52+
mkdir -p bin
53+
curl -L https://github.com/mozilla/sccache/releases/download/v0.2.15/sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz | \
54+
tar -C bin -xz --strip-components=1 sccache-v0.2.15-x86_64-unknown-linux-musl/sccache
55+
chmod +x bin/sccache
56+
57+
- name: Install compiler toolchain from cache
58+
id: cache-toolchain
59+
uses: actions/cache@v2
60+
with:
61+
path: toolchain
62+
key: toolchain-test-${{matrix.toolchain}}
63+
- name: Install compiler toolchain
64+
if: steps.cache-toolchain.outputs.cache-hit != 'true'
65+
run: |
66+
mkdir -p toolchain
67+
curl -L "${{matrix.toolchain}}" | tar -C toolchain -xz --strip-components=1
68+
69+
- name: Install Conan
70+
run: pip install --no-cache-dir conan
71+
- name: Create Conan configuration
72+
run: |
73+
# init config
74+
CONAN_V2_MODE=1 conan config init
75+
conan config set general.revisions_enabled=1
76+
conan remote add ns1labs https://ns1labs.jfrog.io/artifactory/api/conan/ns1labs-conan
77+
# add custom compiler settings for libc
78+
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"))'
79+
- name: Create Conan host profile
80+
run: |
81+
cat > "${{env.CONAN_USER_HOME}}/.conan/profiles/host" << "EOF"
82+
[settings]
83+
os=Linux
84+
os_build=Linux
85+
arch=${{matrix.conan_arch}}
86+
arch_build=x86_64
87+
compiler=gcc
88+
compiler.version=11
89+
compiler.libcxx=libstdc++11
90+
compiler.libc=musl
91+
build_type=Release
92+
[options]
93+
pcapplusplus:with_musl=True
94+
[build_requires]
95+
[env]
96+
CC=${{github.workspace}}/toolchain/bin/${{matrix.cc}}
97+
CXX=${{github.workspace}}/toolchain/bin/${{matrix.cxx}}
98+
LDFLAGS=${{matrix.ldflags}}
99+
EOF
100+
101+
- name: Restore sccache
102+
uses: actions/cache@v2
103+
with:
104+
path: ~/.cache/sccache
105+
key: sccache-${{matrix.arch}}-${{github.head_ref||github.event.ref}}-${{github.run_id}}
106+
restore-keys: |
107+
sccache-${{matrix.arch}}-${{github.head_ref||github.event.ref}}-
108+
sccache-${{matrix.arch}}-${{github.base_ref||github.event.repository.default_branch}}-
109+
110+
- name: Checkout sources
111+
uses: actions/checkout@v2
112+
with:
113+
path: src
114+
- name: Install dependencies
115+
run: |
116+
mkdir build
117+
cd build
118+
conan install -pr:b default -pr:h host -g virtualenv --build=missing "${{github.workspace}}/src"
119+
- name: Configure
120+
run: |
121+
cd build
122+
source environment.sh.env
123+
export CC CXX
124+
export LDFLAGS=-static
125+
cmake "${{github.workspace}}/src" \
126+
-DCMAKE_BUILD_TYPE=Release \
127+
-DCMAKE_C_COMPILER_LAUNCHER="${{github.workspace}}/bin/sccache" -DCMAKE_CXX_COMPILER_LAUNCHER="${{github.workspace}}/bin/sccache" \
128+
-DPKTVISOR_CONAN_INIT=OFF -DPKTVISOR_CONAN_BUILD="never" -DPKTVISOR_CONAN_BUILD_PROFILE="default" -DPKTVISOR_CONAN_HOST_PROFILE="host" \
129+
-DProtobuf_PROTOC_EXECUTABLE=$(command -v protoc) \
130+
-DCORRADE_RC_PROGRAM=$(command -v corrade-rc) \
131+
-DCMAKE_CXX_STANDARD_LIBRARIES=-latomic
132+
- name: Build
133+
run: |
134+
cd build
135+
make -j4 VERBOSE=1
136+
137+
- name: Print sccache stats
138+
run: |
139+
"${{github.workspace}}/bin/sccache" -s
140+
141+
- name: Upload pktvisord
142+
uses: actions/upload-artifact@v2
143+
with:
144+
name: pktvisord-linux-${{matrix.arch}}-static
145+
path: build/bin/pktvisord
146+
retention-days: 7
147+
148+
- name: Upload pktvisor-reader
149+
uses: actions/upload-artifact@v2
150+
with:
151+
name: pktvisor-reader-linux-${{matrix.arch}}-static
152+
path: build/bin/pktvisor-reader
153+
retention-days: 7
154+
155+
pkvisor-cli:
156+
name: pktvisor-cli
157+
runs-on: ubuntu-latest
158+
strategy:
159+
matrix:
160+
os: [linux, macos]
161+
arch: [x86_64, armv7lh, aarch64]
162+
exclude:
163+
- os: macos
164+
arch: armv7lh
165+
steps:
166+
- name: Setup Go
167+
uses: actions/setup-go@v2
168+
with:
169+
go-version: 1.17
170+
- name: Checkout sources
171+
uses: actions/checkout@v2
172+
with:
173+
path: src
174+
- name: Configure
175+
run: |
176+
VERSION_ONLY=1 cmake src
177+
- name: Build
178+
run: |
179+
if [ "${{matrix.os}}" = macos ]; then
180+
export GOOS=darwin
181+
fi
182+
183+
if [ "${{matrix.arch}}" = armv7lh ]; then
184+
export GOARCH=arm
185+
elif [ "${{matrix.arch}}" = aarch64 ]; then
186+
export GOARCH=arm64
187+
fi
188+
189+
cd src/golang
190+
go build -o ${{github.workspace}}/pktvisor-cli ./cmd/pktvisor-cli
191+
- name: Upload pktvisor-cli
192+
uses: actions/upload-artifact@v2
193+
with:
194+
name: pktvisor-cli-${{matrix.os}}-${{matrix.arch}}
195+
path: pktvisor-cli
196+
retention-days: 7

0 commit comments

Comments
 (0)