Skip to content

Commit d7764ae

Browse files
authored
Add GitHub actions (#43)
* add this branch to check * change eigen url to fix ci, run ci on all branches push * apply patch to fix blas, from KISS-ICp * push patch * provide cmake version range * change macro name, conflicts with default cmake macro * add python api workflow * revert push branch check from all to main only
1 parent 45630f6 commit d7764ae

File tree

8 files changed

+187
-9
lines changed

8 files changed

+187
-9
lines changed

.github/workflows/cpp.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: C++ API
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
env:
10+
BUILD_TYPE: Release
11+
12+
jobs:
13+
cpp_api:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04]
18+
steps:
19+
- uses: actions/checkout@v3
20+
- name: Setup cmake
21+
uses: jwlawson/actions-setup-cmake@v1.13
22+
with:
23+
cmake-version: "3.25.x"
24+
- name: Configure CMake
25+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{github.workspace}}/cpp
26+
- name: Build
27+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
28+
29+
# As the previous job will always install the dependencies from cmake, and this is guaranteed to
30+
# work, we also want to support dev sandboxes where the main dependencies are already
31+
# pre-installed in the system. For now, we only support dev machines under a GNU/Linux
32+
# environmnets. If you are reading this and need the same functionallity in Windows/macOS please
33+
# open a ticket.
34+
cpp_api_dev:
35+
runs-on: ${{ matrix.os }}
36+
strategy:
37+
matrix:
38+
os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04]
39+
40+
steps:
41+
- uses: actions/checkout@v3
42+
- name: Cache dependencies
43+
uses: actions/cache@v2
44+
with:
45+
path: ~/.apt/cache
46+
key: ${{ runner.os }}-apt-${{ hashFiles('**/ubuntu_dependencies.yml') }}
47+
restore-keys: |
48+
${{ runner.os }}-apt-
49+
- name: Install dependencies
50+
run: |
51+
sudo apt-get update
52+
sudo apt-get install -y build-essential cmake git libeigen3-dev libtbb-dev libopencv-dev
53+
- name: Configure CMake
54+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{github.workspace}}/cpp
55+
- name: Build
56+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

.github/workflows/pre-commit.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Style Check
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
jobs:
10+
pre-commit:
11+
name: Pre-commit checks
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-python@v4
16+
with:
17+
python-version: "3.10"
18+
- uses: pre-commit/action@v3.0.0

.github/workflows/python.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Python API
2+
on:
3+
push:
4+
branches: ["main"]
5+
pull_request:
6+
branches: ["main"]
7+
8+
jobs:
9+
python_package:
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
matrix:
13+
os: [ubuntu-24.04, ubuntu-22.04, ubuntu-20.04]
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Set up Python3
18+
uses: actions/setup-python@v3
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
- name: Build pip package
23+
run: |
24+
python -m pip install --verbose ./python/
25+
- name: Test installation
26+
run: |
27+
map_closure_pipeline --version

cpp/3rdparty/eigen/eigen.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ set(EIGEN_BUILD_BLAS OFF CACHE BOOL "Don't build blas module")
2727
set(EIGEN_BUILD_LAPACK OFF CACHE BOOL "Don't build lapack module")
2828

2929
include(FetchContent)
30-
FetchContent_Declare(eigen URL https://github.com/nachovizzo/eigen/archive/refs/tags/3.4.90.tar.gz)
30+
FetchContent_Declare(
31+
eigen URL https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz
32+
PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_LIST_DIR}/eigen.patch UPDATE_DISCONNECTED 1)
3133
FetchContent_GetProperties(eigen)
3234
if(NOT eigen_POPULATED)
3335
FetchContent_Populate(eigen)

cpp/3rdparty/eigen/eigen.patch

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
commit cf82186416d04ea5df2a397d8fe09dc78d40ca65
2+
Author: Antonio Sánchez <cantonios@google.com>
3+
Date: Sat Mar 5 05:49:45 2022 +0000
4+
5+
Adds new CMake Options for controlling build components.
6+
7+
diff --git a/CMakeLists.txt b/CMakeLists.txt
8+
index de1c23e91..0af36a53a 100644
9+
--- a/CMakeLists.txt
10+
+++ b/CMakeLists.txt
11+
@@ -477,6 +477,9 @@ if(EIGEN_BUILD_TESTING)
12+
add_subdirectory(failtest)
13+
endif()
14+
15+
+include(CMakeDetermineFortranCompiler)
16+
+option(EIGEN_BUILD_BLAS "Toggles the building of the Eigen Blas library" ${CMAKE_Fortran_COMPILER})
17+
+option(EIGEN_BUILD_LAPACK "Toggles the building of the included Eigen LAPACK library" ${CMAKE_Fortran_COMPILER})
18+
if(EIGEN_LEAVE_TEST_IN_ALL_TARGET)
19+
add_subdirectory(blas)
20+
add_subdirectory(lapack)
21+
@@ -611,6 +614,8 @@ set_target_properties (eigen PROPERTIES EXPORT_NAME Eigen)
22+
23+
install (TARGETS eigen EXPORT Eigen3Targets)
24+
25+
+option(EIGEN_BUILD_CMAKE_PACKAGE "Enables the creation of EigenConfig.cmake and related files" ON)
26+
+if(EIGEN_BUILD_CMAKE_PACKAGE)
27+
configure_package_config_file (
28+
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Eigen3Config.cmake.in
29+
${CMAKE_CURRENT_BINARY_DIR}/Eigen3Config.cmake
30+
@@ -655,6 +660,7 @@ install (FILES ${CMAKE_CURRENT_BINARY_DIR}/Eigen3Config.cmake
31+
# Add uninstall target
32+
add_custom_target ( uninstall
33+
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/EigenUninstall.cmake)
34+
+endif()
35+
36+
if (EIGEN_SPLIT_TESTSUITE)
37+
ei_split_testsuite("${EIGEN_SPLIT_TESTSUITE}")
38+
diff --git a/blas/CMakeLists.txt b/blas/CMakeLists.txt
39+
index 8d3cb86dc..c530957fb 100644
40+
--- a/blas/CMakeLists.txt
41+
+++ b/blas/CMakeLists.txt
42+
@@ -1,6 +1,7 @@
43+
44+
project(EigenBlas CXX)
45+
46+
+if(EIGEN_BUILD_BLAS)
47+
include(CheckLanguage)
48+
check_language(Fortran)
49+
if(CMAKE_Fortran_COMPILER)
50+
@@ -59,4 +60,4 @@ if(EIGEN_BUILD_TESTING)
51+
endif()
52+
53+
endif()
54+
-
55+
+endif()
56+
diff --git a/lapack/CMakeLists.txt b/lapack/CMakeLists.txt
57+
index c8ca64001..8d6d75401 100644
58+
--- a/lapack/CMakeLists.txt
59+
+++ b/lapack/CMakeLists.txt
60+
@@ -1,5 +1,7 @@
61+
project(EigenLapack CXX)
62+
63+
+if(EIGEN_BUILD_LAPACK AND EIGEN_BUILD_BLAS)
64+
+
65+
include(CheckLanguage)
66+
check_language(Fortran)
67+
if(CMAKE_Fortran_COMPILER)
68+
@@ -457,3 +459,6 @@ if(EXISTS ${eigen_full_path_to_testing_lapack})
69+
70+
endif()
71+
72+
+elseif(EIGEN_BUILD_LAPACK AND NOT EIGEN_BUILD_BLAS)
73+
+ message(FATAL_ERROR "EIGEN_BUILD_LAPACK requires EIGEN_BUILD_BLAS")
74+
+endif() #EIGEN_BUILD_LAPACK

cpp/3rdparty/find_dependencies.cmake

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ endif()
2929
# will transfer the control from the calling scope to the function and the back to the calling scope once the function
3030
# as done whatever it has to do. This transfer will cause how black magic forwarded include dirs for the OpenCV targets to dont work anymore, as this will be confined to the local scope of the cmake function.
3131
# The easier solution for us was to just change function to macro, as the later will just copy paste the content adjusting the parameters (exactly like a C macro). This is horrible of course, but it is caused by the build system of OpenCV.
32-
macro(find_dependency PACKAGE_NAME TARGET_NAME INCLUDED_CMAKE_PATH)
32+
macro(find_external_dependency PACKAGE_NAME TARGET_NAME INCLUDED_CMAKE_PATH)
3333
string(TOUPPER ${PACKAGE_NAME} PACKAGE_NAME_UP)
3434
set(USE_FROM_SYSTEM_OPTION "USE_SYSTEM_${PACKAGE_NAME_UP}")
3535
if(${${USE_FROM_SYSTEM_OPTION}})
@@ -40,10 +40,11 @@ macro(find_dependency PACKAGE_NAME TARGET_NAME INCLUDED_CMAKE_PATH)
4040
endif()
4141
endmacro()
4242

43-
find_dependency("Eigen3" "Eigen3::Eigen" "${CMAKE_CURRENT_LIST_DIR}/eigen/eigen.cmake")
44-
find_dependency("TBB" "TBB::tbb" "${CMAKE_CURRENT_LIST_DIR}/tbb/tbb.cmake")
45-
find_dependency("OpenCV" "opencv_features2d" "${CMAKE_CURRENT_LIST_DIR}/opencv/opencv.cmake")
46-
find_dependency("tsl-robin-map" "tsl::robin_map"
47-
"${CMAKE_CURRENT_LIST_DIR}/tsl_robin/tsl_robin.cmake")
43+
find_external_dependency("Eigen3" "Eigen3::Eigen" "${CMAKE_CURRENT_LIST_DIR}/eigen/eigen.cmake")
44+
find_external_dependency("TBB" "TBB::tbb" "${CMAKE_CURRENT_LIST_DIR}/tbb/tbb.cmake")
45+
find_external_dependency("OpenCV" "opencv_features2d"
46+
"${CMAKE_CURRENT_LIST_DIR}/opencv/opencv.cmake")
47+
find_external_dependency("tsl-robin-map" "tsl::robin_map"
48+
"${CMAKE_CURRENT_LIST_DIR}/tsl_robin/tsl_robin.cmake")
4849

4950
include(${CMAKE_CURRENT_LIST_DIR}/hbst/hbst.cmake)

cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
# SOFTWARE.
2323

24-
cmake_minimum_required(VERSION 3.22)
24+
cmake_minimum_required(VERSION 3.16...3.26)
2525
project(map_closures_cpp VERSION 1.0.0 LANGUAGES CXX)
2626

2727
option(USE_SYSTEM_EIGEN3 "Use system pre-installed Eigen" ON)

python/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
# SOFTWARE.
23-
cmake_minimum_required(VERSION 3.22)
23+
cmake_minimum_required(VERSION 3.16...3.26)
2424
project(map_closure_pybind VERSION 1.0.0 LANGUAGES CXX)
2525

2626
# Set build type

0 commit comments

Comments
 (0)