-
Notifications
You must be signed in to change notification settings - Fork 2
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
github actions for building and testing - no commit history #8
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Build the library without tests | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
env: | ||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | ||
BUILD_TYPE: Release | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Configure CMake | ||
run: | | ||
cmake -B ${{github.workspace}}/build \ | ||
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DNF9_BUILD_TESTS=OFF | ||
|
||
- name: Build | ||
# Build your program with the given configuration | ||
run: | | ||
cmake --build ${{github.workspace}}/build \ | ||
--config ${{env.BUILD_TYPE}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Build tests using external libraries referencd by the project | ||
name: TestsOwnLibs | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
env: | ||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | ||
BUILD_TYPE: Debug | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install libpcap | ||
run: sudo apt-get install -y libpcap-dev | ||
|
||
- name: Initialize submodules | ||
run: git submodule init && git submodule update | ||
|
||
- name: Build libtins library | ||
run: | | ||
cd ${{github.workspace}}/external/libtins && mkdir build && \ | ||
cd build && cmake .. -DLIBTINS_ENABLE_CXX11=1 && cmake --build . | ||
|
||
- name: Configure CMake | ||
run: | | ||
cmake -B ${{github.workspace}}/build \ | ||
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DNF9_BUILD_TESTS=ON \ | ||
-DNF9_USE_OWN_LIBTINS=ON -DNF9_USE_OWN_GTEST=ON | ||
|
||
- name: Build Tests | ||
run: | | ||
cmake --build ${{github.workspace}}/build \ | ||
--config ${{env.BUILD_TYPE}} | ||
|
||
- name: Test | ||
working-directory: ${{github.workspace}}/build | ||
run: ./test/netflowtests | ||
# ctest -C ${{env.BUILD_TYPE}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Build tests using the libraries installed in system | ||
name: TestsSysLibs | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
env: | ||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | ||
BUILD_TYPE: Debug | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install libpcap | ||
run: sudo apt-get install -y libpcap-dev | ||
|
||
- name: Install googletest | ||
run: sudo apt-get install -y libgtest-dev | ||
|
||
- name: Install libtins | ||
run: sudo apt-get install -y libtins-dev | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably may install all dependencies in one step: |
||
|
||
- name: Configure CMake | ||
run: | | ||
cmake -B ${{github.workspace}}/build \ | ||
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DNF9_BUILD_TESTS=ON | ||
|
||
- name: Build Tests | ||
# Build your program with the given configuration | ||
run: | | ||
cmake --build ${{github.workspace}}/build \ | ||
--config ${{env.BUILD_TYPE}} | ||
|
||
- name: Test | ||
working-directory: ${{github.workspace}}/build | ||
run: ./test/netflowtests | ||
# ctest -C ${{env.BUILD_TYPE}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/clang_build/ | ||
__pycache__ | ||
ENV | ||
.vscode/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "external/libtins"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it really better than using a system library? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. System library is good, provided it is there. It happens to be the case on Ubuntu - github runner, so we can switch back to it there. On RedHat/CentOS/Fedora derivatives it may not be the case. I tried it on AWS Linux 2 (ID_LIKE="centos rhel fedora") and Oracle Linux (fedora) and needed to compile libtins myself, hence referencing it as a submodule. You may need to get used to using submodules, but they are based on healthy principles. You keep just a reference to the dependant repository, so there is no code duplication. Actually, libtins library itself is using googletest as a submodule https://github.com/mfontanini/libtins/blob/master/.gitmodules . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should still work in airgapped environment or via an internal cache (source of truth for this repository up to this PR was internal company Bitbucket. There's sometimes limited access to gh too. It's nice idea to have it build easily on RH-like distros, we'd just need to make certain it still works in current envs - and/or review policies. Also, probably this should reference a specific tag/commit which is known to work? |
||
path = external/libtins | ||
url = https://github.com/mfontanini/libtins.git |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,18 @@ information about the traffic. | |
|
||
libnetflow9 is written in C++17, and has a compatible C API. | ||
|
||
# Building # | ||
## Badges ## | ||
|
||
### Building ### | ||
|
||
![build workflow](https://github.com/doodeck/libnetflow9/actions/workflows/cmake.yml/badge.svg) | ||
|
||
### Testing ### | ||
|
||
![test workflow sys](https://github.com/doodeck/libnetflow9/actions/workflows/tests.yml/badge.svg) | ||
|
||
![test workflow own](https://github.com/doodeck/libnetflow9/actions/workflows/tests-own.yml/badge.svg) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't those links link to the exatel/libnetflow9 repo? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Excellent point! Ultimately - they should. As long as the changes exist only in a pull-request we will probably see an empty status. This is a chicken - egg problem, I guess, I should change it right now. |
||
|
||
|
||
## Dependencies ## | ||
|
||
|
@@ -33,6 +44,24 @@ cmake .. | |
make -j4 | ||
``` | ||
|
||
## Building on MacOS M1 | ||
|
||
``` | ||
mkdir build | ||
cd build | ||
cmake .. -DCMAKE_C_COMPILER=/opt/homebrew/bin/gcc-12 -DCMAKE_CXX_COMPILER=/opt/homebrew/bin/g++-12 | ||
cmake --build . | ||
``` | ||
|
||
Otherwise it defaults to Clang toolset, which as of version: | ||
|
||
`Apple clang version 14.0.0 (clang-1400.0.29.202)` | ||
|
||
is incapable of compiling the library. More details in the build log | ||
|
||
https://github.com/doodeck/libnetflow9/actions/runs/4681045806/jobs/8293144058 | ||
|
||
|
||
## Building and running tests ## | ||
|
||
```console | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# external libraries sources directory | ||
|
||
The external libraries are not used by default, instead it's expected they | ||
are installed system-wide. System libraries have advantages, e.g. you can | ||
rely on them in an airgapped environment. On the other hand, they are missing | ||
from some distributions. | ||
|
||
In order to activate the external libraries set to ON the correspoding cmake | ||
option[-s]: | ||
|
||
* `NF9_USE_OWN_LIBTINS` | ||
* `NF9_USE_OWN_GTEST` | ||
|
||
## libtins | ||
https://github.com/mfontanini/libtins.git | ||
|
||
Incorporated as a submodule as described here: | ||
|
||
https://git-scm.com/book/en/v2/Git-Tools-Submodules | ||
|
||
## googtest | ||
pulled directly from github release as recommended here: | ||
|
||
https://github.com/google/googletest/blob/main/googletest/README.md | ||
|
||
Overthere see the description below the last bullet point "Use CMake | ||
to download GoogleTest as part of the build's configure step. This approach | ||
doesn't have the limitations of the other methods." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking submodule to fixed commit would be nice IMHO. It might be a little more painful to switch any external library to newer version but won't cause pipeline failures when something go wrong in dependencies.
Anyway I don't get how own version of googletest is installed -
git submodule update
handles it? It's a bit implicit for me tbh.