Skip to content

Commit 5515554

Browse files
authored
Merge pull request #17 from CESNET/devel
Merge devel into master
2 parents fefd6a1 + 5474f78 commit 5515554

File tree

101 files changed

+13937
-1096
lines changed

Some content is hidden

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

101 files changed

+13937
-1096
lines changed

.github/workflows/main.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build and tests
2+
3+
on:
4+
# Ignore changes in extra plugins (as they are not tested here)
5+
push:
6+
paths-ignore:
7+
- 'extra_plugins/**'
8+
pull_request:
9+
paths-ignore:
10+
- 'extra_plugins/**'
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
image: ['ubuntu:18.04', 'ubuntu:19.04', 'ubuntu:20.04', 'debian:stretch', 'debian:buster', 'debian:bullseye', 'centos:7', 'centos:8', 'fedora:29', 'fedora:30', 'fedora:31']
19+
20+
name: Build on ${{ matrix.image }}
21+
container: ${{ matrix.image }}
22+
steps:
23+
- uses: actions/checkout@v1
24+
25+
# Dependencies ---------------------------------------------------------------------------
26+
- name: Install dependencies for libfds and IPFIXcol2 (Ubuntu/Debian)
27+
if: startsWith(matrix.image, 'ubuntu') || startsWith(matrix.image, 'debian')
28+
run: |
29+
apt-get update
30+
apt-get -y install git gcc g++ cmake make libxml2-dev liblz4-dev libzstd-dev
31+
apt-get -y install python3-docutils zlib1g-dev pkg-config
32+
- name: Install dependencies for libfds and IPFIXcol2 (CentOS)
33+
if: startsWith(matrix.image, 'centos')
34+
run: |
35+
yum -y install epel-release
36+
yum -y install git gcc gcc-c++ cmake make libxml2-devel lz4-devel libzstd-devel
37+
yum -y install zlib-devel pkgconfig
38+
yum -y install python3-docutils || yum -y install python-docutils
39+
- name: Install depedencies for libfds and IPFIXcol2 (Fedora)
40+
if: startsWith(matrix.image, 'fedora')
41+
run: |
42+
dnf -y install git gcc gcc-c++ cmake make libxml2-devel lz4-devel libzstd-devel
43+
dnf -y install python3-docutils zlib-devel pkgconfig
44+
45+
# Build libfds library ------------------------------------------------------------------
46+
# Note: Master against master branch. Otherwise against debug branch.
47+
- name: Checkout libfds library - master branch
48+
if: github.ref == 'refs/heads/master'
49+
run: git clone --branch master https://github.com/CESNET/libfds.git libfds_build
50+
- name: Checkout libfds library - devel branch
51+
if: github.ref != 'refs/heads/master'
52+
run: git clone --branch devel https://github.com/CESNET/libfds.git libfds_build
53+
- name: Build and install libfds library
54+
working-directory: libfds_build
55+
run: |
56+
mkdir build && cd build
57+
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
58+
make && make install
59+
60+
# Build and test IPFIXcol2 ---------------------------------------------------------------
61+
- name: Build and install IPFIXcol2
62+
run: |
63+
mkdir build && cd build
64+
cmake .. -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTS=$TESTS
65+
make && make install
66+
env:
67+
TESTS: ${{ startsWith(matrix.image, 'centos:7') != true }}
68+
- name: Run tests
69+
if: startsWith(matrix.image, 'centos:7') != true
70+
run: cd build && make test
71+
- name: Try to run IPFIXcol2
72+
run: |
73+
ipfixcol2 -V
74+
ipfixcol2 -h
75+
ipfixcol2 -L -v

.github/workflows/packages.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: Build RPM/DEB packages
2+
3+
on:
4+
# Ignore changes in extra plugins (as they are not tested here)
5+
push:
6+
paths-ignore:
7+
- 'extra_plugins/**'
8+
pull_request:
9+
paths-ignore:
10+
- 'extra_plugins/**'
11+
12+
jobs:
13+
deb:
14+
# Try to build DEB packages
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
image: ['ubuntu:18.04', 'ubuntu:19.04', 'ubuntu:20.04', 'debian:stretch', 'debian:buster', 'debian:bullseye']
20+
21+
name: Build DEBs on ${{ matrix.image }}
22+
container: ${{ matrix.image }}
23+
24+
steps:
25+
- uses: actions/checkout@v1
26+
- name: Define global variables
27+
run: echo "::set-output name=zip_file::libfds-${IMAGE//:/}-$GITHUB_SHA.zip"
28+
shell: bash
29+
env:
30+
IMAGE: ${{ matrix.image }}
31+
id: vars
32+
33+
# Dependencies ---------------------------------------------------------------------------
34+
- name: Install dependencies for libfds and IPFIXcol2 (Ubuntu/Debian)
35+
run: |
36+
apt-get update
37+
apt-get -y install git gcc g++ cmake make libxml2-dev liblz4-dev libzstd-dev
38+
apt-get -y install python3-docutils zlib1g-dev pkg-config
39+
apt-get -y install debhelper devscripts build-essential fakeroot zip
40+
41+
# Build LIBFDS DEB package ---------------------------------------------------------------
42+
- name: Checkout libfds library - master branch
43+
if: github.ref == 'refs/heads/master'
44+
run: git clone --branch master https://github.com/CESNET/libfds.git build/libfds_repo
45+
- name: Checkout libfds library - devel branch
46+
if: github.ref != 'refs/heads/master'
47+
run: git clone --branch devel https://github.com/CESNET/libfds.git build/libfds_repo
48+
- name: Build DEBs of libfds library and install them
49+
working-directory: 'build/libfds_repo'
50+
run: |
51+
mkdir build && cd build
52+
cmake .. -DPACKAGE_BUILDER_DEB=On -DCPACK_PACKAGE_CONTACT="GitHub actions <[email protected]>"
53+
make deb
54+
apt -y install ./pkg/deb/debbuild/libfds*.deb
55+
56+
# Build IPFIXcol2 DEB package ------------------------------------------------------------
57+
- name: Build IPFIXcol2 DEBs and install them
58+
run: |
59+
cd build
60+
cmake .. -DPACKAGE_BUILDER_DEB=On -DCPACK_PACKAGE_CONTACT="GitHub actions <[email protected]>"
61+
make deb
62+
apt -y install ./pkg/deb/debbuild/*.deb
63+
- name: Try to run IPFIXcol2
64+
run: |
65+
ipfixcol2 -V
66+
ipfixcol2 -h
67+
ipfixcol2 -L
68+
- name: Pack IPFIXcol2 DEB packages
69+
working-directory: 'build/pkg/deb/debbuild/'
70+
run: zip "$GITHUB_WORKSPACE/$ZIP_FILE" *.deb *.ddeb *.tar.gz *.dsc
71+
env:
72+
ZIP_FILE: ${{ steps.vars.outputs.zip_file }}
73+
- name: Archive DEB packages
74+
if: github.event_name == 'push'
75+
uses: actions/upload-artifact@v1
76+
with:
77+
name: ${{ steps.vars.outputs.zip_file }}
78+
path: ${{ steps.vars.outputs.zip_file }}
79+
80+
rpm:
81+
# Try to build RPM packages
82+
runs-on: ubuntu-latest
83+
strategy:
84+
fail-fast: false
85+
matrix:
86+
image: ['centos:7', 'centos:8', 'fedora:29', 'fedora:30', 'fedora:31']
87+
88+
name: Build RPMs on ${{ matrix.image }}
89+
container: ${{ matrix.image }}
90+
91+
steps:
92+
- uses: actions/checkout@v1
93+
- name: Prepare environment and variables
94+
run: |
95+
echo "::set-output name=zip_file::libfds-${IMAGE//:/}-$GITHUB_SHA.zip"
96+
mkdir -p build/libfds_repo
97+
env:
98+
IMAGE: ${{ matrix.image }}
99+
id: vars
100+
101+
# Dependencies ---------------------------------------------------------------------------
102+
- name: Install dependencies for libfds and IPFIXcol2 (CentOS)
103+
if: startsWith(matrix.image, 'centos')
104+
run: |
105+
yum -y install epel-release
106+
yum -y install git gcc gcc-c++ cmake make libxml2-devel lz4-devel libzstd-devel
107+
yum -y install zlib-devel pkgconfig rpm-build
108+
yum -y install python3-docutils || yum -y install python-docutils
109+
- name: Install depedencies for libfds and IPFIXcol2 (Fedora)
110+
if: startsWith(matrix.image, 'fedora')
111+
run: |
112+
dnf -y install git gcc gcc-c++ cmake make libxml2-devel lz4-devel libzstd-devel
113+
dnf -y install python3-docutils zlib-devel pkgconfig rpm-build
114+
115+
# Build LIBFDS RPM package ---------------------------------------------------------------
116+
- name: Checkout libfds library - master branch
117+
if: github.ref == 'refs/heads/master'
118+
run: git clone --branch master https://github.com/CESNET/libfds.git build/libfds_repo
119+
- name: Checkout libfds library - devel branch
120+
if: github.ref != 'refs/heads/master'
121+
run: git clone --branch devel https://github.com/CESNET/libfds.git build/libfds_repo
122+
- name: Build RPMs of libfds library and install it
123+
working-directory: 'build/libfds_repo'
124+
run: |
125+
mkdir build && cd build
126+
cmake .. -DPACKAGE_BUILDER_RPM=On -DCPACK_PACKAGE_CONTACT="GitHub actions <[email protected]>"
127+
make rpm
128+
yum -y install pkg/rpm/rpmbuild/RPMS/*/libfds-*.rpm
129+
130+
# Build IPFIXcol2 RPM package ------------------------------------------------------------
131+
- name: Build IPFIXcol2 RPMs and install them
132+
run: |
133+
cd build
134+
cmake .. -DPACKAGE_BUILDER_RPM=On -DCPACK_PACKAGE_CONTACT="GitHub actions <[email protected]>"
135+
make rpm
136+
yum -y install pkg/rpm/rpmbuild/RPMS/*/ipfixcol2-*.rpm
137+
- name: Try to run IPFIXcol2
138+
run: |
139+
ipfixcol2 -V
140+
ipfixcol2 -h
141+
ipfixcol2 -L -v
142+
- name: Pack IPFIXcol2 RPM packages
143+
working-directory: 'build/pkg/rpm/rpmbuild'
144+
run: zip -r "$GITHUB_WORKSPACE/$ZIP_FILE" RPMS SRPMS
145+
env:
146+
ZIP_FILE: ${{ steps.vars.outputs.zip_file }}
147+
- name: Archive RPM packages
148+
if: github.event_name == 'push'
149+
uses: actions/upload-artifact@v1
150+
with:
151+
name: ${{ steps.vars.outputs.zip_file }}
152+
path: ${{ steps.vars.outputs.zip_file }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ cmake-build-debug/
44
cmake-build-debugwithtests/
55
cmake-build-release/
66

7+
# Visual Studio
8+
.vscode/
9+
710
# JetBrains files
811
.idea/
912

CMakeLists.txt

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ endif()
1414

1515
# Versions and other informations
1616
set(IPFIXCOL_VERSION_MAJOR 2)
17-
set(IPFIXCOL_VERSION_MINOR 0)
17+
set(IPFIXCOL_VERSION_MINOR 1)
1818
set(IPFIXCOL_VERSION_PATCH 0)
1919
set(IPFIXCOL_VERSION
2020
${IPFIXCOL_VERSION_MAJOR}.${IPFIXCOL_VERSION_MINOR}.${IPFIXCOL_VERSION_PATCH})
@@ -39,25 +39,23 @@ if (NOT COMPILER_SUPPORT_GNUXX11)
3939
endif()
4040

4141
# ------------------------------------------------------------------------------
42-
# Build options
43-
set(TESTS_DEFAULT OFF)
44-
4542
# Set default build type if not specified by user
46-
if (NOT CMAKE_BUILD_TYPE)
47-
set (CMAKE_BUILD_TYPE Release
48-
CACHE STRING "Choose type of build (Release/Debug/Coverage)." FORCE)
49-
endif()
50-
51-
string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE_UPPER)
52-
# Enable unit tests, by default, for coverage builds
53-
if (${BUILD_TYPE_UPPER} STREQUAL "COVERAGE")
54-
set(TESTS_DEFAULT ON)
43+
set(DEFAULT_BUILD_TYPE "Release")
44+
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
45+
# Use the default build type if not specified
46+
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
47+
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE
48+
STRING "Choose the type of build." FORCE)
49+
# Set the possible values of build type for cmake-gui
50+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
51+
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
5552
endif()
5653

5754
option(ENABLE_DOC_MANPAGE "Enable manual page building" ON)
5855
option(ENABLE_DOC_DOXYGEN "Enable code documentation building" OFF)
59-
option(ENABLE_TESTS "Build Unit tests (make test)" ${TESTS_DEFAULT})
56+
option(ENABLE_TESTS "Build Unit tests (make test)" OFF)
6057
option(ENABLE_TESTS_VALGRIND "Build Unit tests with Valgrind Memcheck" OFF)
58+
option(ENABLE_TESTS_COVERAGE "Enable support for code coverage" OFF)
6159
option(PACKAGE_BUILDER_RPM "Enable RPM package builder (make rpm)" OFF)
6260
option(PACKAGE_BUILDER_DEB "Enable DEB package builder (make deb)" OFF)
6361

@@ -68,11 +66,15 @@ option(PACKAGE_BUILDER_DEB "Enable DEB package builder (make deb)" OFF)
6866
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -std=gnu11")
6967
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
7068
set(CMAKE_C_FLAGS_DEBUG "-g -O0 -Wall -Wextra -pedantic")
71-
set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_DEBUG} --coverage -fprofile-arcs -ftest-coverage")
7269
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -std=gnu++11")
7370
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
7471
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wextra -pedantic")
75-
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_DEBUG} --coverage -fprofile-arcs -ftest-coverage")
72+
73+
if (ENABLE_TESTS AND ENABLE_TESTS_COVERAGE)
74+
# Additional flags for code coverage
75+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
76+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
77+
endif()
7678

7779
# ------------------------------------------------------------------------------
7880
# Project components
@@ -88,6 +90,7 @@ endif()
8890

8991
# ------------------------------------------------------------------------------
9092
# Status messages
93+
string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE_UPPER)
9194
MESSAGE(STATUS
9295
"\n\n"
9396
"IPFIXcol version.: ${IPFIXCOL_VERSION}\n"

0 commit comments

Comments
 (0)