-
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?
Conversation
.github/workflows/cmake.yml
Outdated
- uses: actions/checkout@v3 | ||
|
||
- name: Configure CMake | ||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. |
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.
Keep lines shorter, we try to keep a limit of 79 characters per line
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.
these comments were provided by github.com, when creating the action file. we can remove them.
CMakeLists.txt
Outdated
@@ -29,7 +29,12 @@ else () | |||
add_library(netflow9 STATIC ${CXX_SRC}) | |||
endif () | |||
|
|||
target_include_directories(netflow9 SYSTEM PUBLIC include) | |||
get_property(SRC_DIR DIRECTORY PROPERTY SOURCE_DIR) | |||
message(STATUS "tins include:" ${SRC_DIR}/external/libtins/include/) |
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.
Looks like you left this line for debugging. It's pretty useless information - it does not depend on anything external, and will always be the same once you download the repository, there is no way to change it.
README.md
Outdated
|
||
Apple clang version 14.0.0 (clang-1400.0.29.202) | ||
|
||
is incapable of compiling the library. |
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.
Can you provide more details about this?
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.
Are you able to see that build log:
https://github.com/doodeck/libnetflow9/actions/runs/4681045806/jobs/8293144058
?
CMake Error at CMakeLists.txt:75 (message):
Could not find required <memory_resource> or <experimental/memory_resource>
headers
I guess the library was designed and build on top of gcc toolset. What is causing problems here is probably CLang toolset. Actually they might have fixed it for the future releases:
test/CMakeLists.txt
Outdated
message(STATUS "googletest populate: " ${googletest_SOURCE_DIR} " " ${googletest_BINARY_DIR}) | ||
|
||
get_property(SRC_DIR DIRECTORY PROPERTY SOURCE_DIR) | ||
message(STATUS "tins libs: " ${SRC_DIR}/../external/libtins/build/lib/) |
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.
This is also pretty useless information, since the path never changes.
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.
Yes, it can be removed.
test/CMakeLists.txt
Outdated
|
||
find_library(LIBTINS_LIBRARIES tins) | ||
message(STATUS "googletest populate: " ${googletest_SOURCE_DIR} " " ${googletest_BINARY_DIR}) |
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.
This message could be more meaningful. What does it mean?
Also, if I just want to build the library, I don't need to see this - instead of a STATUS
message this could be DEBUG
.
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.
Debug message again, not needed anymore
.github/workflows/tests.yml
Outdated
|
||
env: | ||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | ||
BUILD_TYPE: Release |
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.
For tests we probably want to build in Debug mode with sanitizers etc. right?
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.
Sure, and I've just checked, that the tests still work afterwards with Debug.
test/CMakeLists.txt
Outdated
) | ||
# For Windows: Prevent overriding the parent project's compiler/linker settings | ||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
FetchContent_MakeAvailable(googletest) |
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.
That's cool but I think there should be an option to use system provided GTest still.
Sometimes, projects that deal with networking/security (such as this one) are built in airgapped environments.
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.
Sure, we can switch the behaviour on options. Actually, FetchContent_MakeAvailable is the approach recommended by Google (https://github.com/google/googletest/blob/main/googletest/README.md).
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.
"Specify the commit you depend on and update it regularly." might be fine for GTest, in general we prefer to depend on distro (Debian in most cases) libraries that get some security team support (and yet are stable in version). Not everywhere it's possible (npm, python packages), but it's a pain to "update commits regularly".
For gtest I would not care, but still, it would be best if it worked internally without calling gh - internal mirror on bitbucket in this case. So URL would have to be a variable (?). And then we have a mirror to update too. We try to care about the delivery chain.
@@ -0,0 +1,3 @@ | |||
[submodule "external/libtins"] |
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.
Is it really better than using a system library?
Also, is a submodule better than, e.g. a subtree? Personally I always found git-submodules difficult to use.
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.
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 comment
The 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?
Create cmake.yml Add MacOS builiding hints Add libtins as a submodule Add build hints for external libtins and gtest Create tests.yml Upgrade google test version 1.11.0 -> 1.13.0 Add build and tests badges to README Address the issues in the discussion of the PR: * use the system libraries, make alternatives optional, activated with switches * keep the lines up to 80 chars in length, unless technically not possible * set the level of redundant messages to DEBUG, mark them for removal with FIXME: * provide details of build problems using Apple/CLang in README * Use built type Debug for tests
c0ca159
to
e950390
Compare
Not needed in master, is not operational yet, used only to reproduce MacOS problems
I've addressed all the remarks in the discussion to PR. |
README.md
Outdated
|
||
![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 comment
The 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 comment
The 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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
We probably may install all dependencies in one step:
sudo apt-get install -y libpcap-dev libgtest-dev libtins-dev
- name: Build libtins library | ||
run: | | ||
cd ${{github.workspace}}/external/libtins && mkdir build && \ | ||
cd build && cmake .. -DLIBTINS_ENABLE_CXX11=1 && cmake --build . |
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.
…roject For the time being, in pull request's branch, the badges are expected to remain grey and show "no status"
Please review and consider for merging.