Skip to content

Commit

Permalink
Add CI and Fix Windows Build Errors (#604)
Browse files Browse the repository at this point in the history
Add CI testing for each platform
Fix Windows include file and linker errors encountered
Fix a few tests on Windows
  • Loading branch information
matthew-lidar committed Aug 6, 2024
1 parent 7815f42 commit 27bc78f
Show file tree
Hide file tree
Showing 17 changed files with 206 additions and 19 deletions.
115 changes: 115 additions & 0 deletions .github/workflows/build_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Lint Build and Test

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: install deps
run: sudo apt install build-essential cmake libjsoncpp-dev libeigen3-dev libcurl4-openssl-dev libtins-dev libpcap-dev libglfw3-dev libglew-dev libspdlog-dev libflatbuffers-dev libgtest-dev clang-format
- name: cpp-lint
run: ./clang-linting.sh
- name: install python
run: sudo apt install python3 python3-pip
- name: install python-deps one
run: cd python && python3 setup.py egg_info && pip3 install `grep -v '^\[' src/*.egg-info/requires.txt`
- name: install python-deps
run: pip3 install mypy flake8
- name: python-lint
run: cd python && mypy ./src ./tests && flake8
linux-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: install deps
run: sudo apt install build-essential cmake libjsoncpp-dev libeigen3-dev libcurl4-openssl-dev libtins-dev libpcap-dev libglfw3-dev libglew-dev libspdlog-dev libflatbuffers-dev libgtest-dev clang-format
- name: cmake configure
run: cmake . -B build -DBUILD_TESTING=ON -DBUILD_EXAMPLES=ON
- name: cmake build
run: cmake --build build -j4
- name: run tests
run: cd build/ && ctest -j4 --output-on-failure
linux-python-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: install python
run: sudo apt install python3 python3-pip
- name: install deps
run: sudo apt install build-essential cmake libjsoncpp-dev libeigen3-dev libcurl4-openssl-dev libtins-dev libpcap-dev libglfw3-dev libglew-dev libspdlog-dev libflatbuffers-dev
- name: install python-deps
run: pip3 install pytest pytest-xdist
- name: build python
run: cd python && sudo python3 -m pip install -e .[test]
- name: run tests
run: cd python/tests && pytest -n4
windows-build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: vcpkg build
uses: johnwason/vcpkg-action@v6
id: vcpkg
with:
pkgs: jsoncpp eigen3 curl libtins glfw3 glew spdlog libpng flatbuffers gtest
triplet: x64-windows
revision: 2024.04.26
token: ${{ github.token }}
github-binarycache: true
- name: cmake configure
run: cmake . -B build -DBUILD_TESTING=ON -DBUILD_EXAMPLES=ON -DCMAKE_TOOLCHAIN_FILE=D:/a/ouster-sdk/ouster-sdk/vcpkg/scripts/buildsystems/vcpkg.cmake
- name: cmake build
run: cmake --build build -j4
- name: run tests
run: cd build/ && ctest -j4 -C Debug --output-on-failure
windows-python-build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- uses: seanmiddleditch/gha-setup-ninja@master
- uses: ilammy/msvc-dev-cmd@v1
- name: vcpkg build
uses: johnwason/vcpkg-action@v6
id: vcpkg
with:
pkgs: jsoncpp eigen3 curl libtins glfw3 glew spdlog libpng flatbuffers gtest
triplet: x64-windows
revision: 2024.04.26
token: ${{ github.token }}
github-binarycache: true
- name: install python-deps
run: pip3 install pytest pytest-xdist
- name: build python
run: cd python && python3 -m pip install -e .[test]
env:
OUSTER_SDK_CMAKE_ARGS: '-DCMAKE_TOOLCHAIN_FILE=D:/a/ouster-sdk/ouster-sdk/vcpkg/scripts/buildsystems/vcpkg.cmake'
- name: run tests
run: cd python/tests && pytest -n3
mac-build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: install deps
run: brew install cmake pkg-config jsoncpp eigen curl libtins glfw glew spdlog flatbuffers googletest
- name: cmake configure
run: cmake . -B build -DBUILD_TESTING=ON -DBUILD_EXAMPLES=ON
- name: cmake build
run: cmake --build build -j3
- name: run tests
run: cd build/ && ctest -j3 --output-on-failure
mac-python-build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: install deps
run: brew install cmake pkg-config jsoncpp eigen curl libtins glfw glew spdlog flatbuffers
- name: install python-deps
run: pip3 install pytest pytest-xdist --break-system-packages
- name: build python
run: cd python && python3 -m pip install -e .[test] --break-system-packages
- name: set netparams
run: sudo sysctl -w net.inet.udp.maxdgram=65535
- name: run tests
run: cd python/tests && pytest -n3
2 changes: 1 addition & 1 deletion ouster_client/include/ouster/lidar_scan.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class LidarScan {
template <typename Iterator>
LidarScan(size_t w, size_t h, Iterator begin, Iterator end,
size_t columns_per_packet = DEFAULT_COLUMNS_PER_PACKET)
: LidarScan(w, h, {begin, end}, columns_per_packet){};
: LidarScan(w, h, {begin, end}, columns_per_packet) {}

/**
* Initialize a lidar scan from another lidar scan.
Expand Down
4 changes: 4 additions & 0 deletions ouster_client/src/lidar_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include "ouster/strings.h"
#include "ouster/types.h"

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

using namespace ouster::strings;

namespace ouster {
Expand Down
1 change: 0 additions & 1 deletion ouster_osf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ target_link_libraries(ouster_osf
target_include_directories(ouster_osf PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
${EIGEN3_INCLUDE_DIR}
)
add_dependencies(ouster_osf cpp_gen)
add_library(OusterSDK::ouster_osf ALIAS ouster_osf)
Expand Down
1 change: 1 addition & 0 deletions ouster_osf/src/compat_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <direct.h>
#include <fcntl.h>
#include <io.h>
#include <share.h>
#include <shlwapi.h>
#include <tchar.h>
#include <windows.h>
Expand Down
6 changes: 6 additions & 0 deletions ouster_osf/tests/png_tools_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,15 @@ TEST_F(OsfPngToolsTest, InternalsTest) {
EXPECT_NE(error_loc, std::string::npos);
output_error = output_error.substr(error_loc);
EXPECT_TRUE(error_caught);
#ifdef _WIN32
EXPECT_EQ(output_error,
"[error] ERROR libpng osf: Also Checkout Porcupine Tree"
" - Arriving Somewhere But Not Here\r\n");
#else
EXPECT_EQ(output_error,
"[error] ERROR libpng osf: Also Checkout Porcupine Tree"
" - Arriving Somewhere But Not Here\n");
#endif
}

#ifndef OUSTER_OSF_NO_THREADING
Expand Down
4 changes: 4 additions & 0 deletions ouster_osf/tests/reader_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,11 @@ TEST_F(ReaderTest, MetadataFromBufferTest) {
EXPECT_NE(error_loc, std::string::npos);

output_error = output_error.substr(error_loc);
#ifdef _WIN32
EXPECT_EQ(output_error, "[error] UNKNOWN TYPE: NON EXISTENT\r\n");
#else
EXPECT_EQ(output_error, "[error] UNKNOWN TYPE: NON EXISTENT\n");
#endif
EXPECT_EQ(result, nullptr);

result = sensor->from_buffer(sensor->buffer(),
Expand Down
1 change: 0 additions & 1 deletion ouster_pcap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ target_include_directories(ouster_pcap PUBLIC
CodeCoverageFunctionality(ouster_pcap)

if(WIN32)
target_compile_options(ouster_pcap PRIVATE /wd4200)
target_link_libraries(ouster_pcap PUBLIC ws2_32)
endif()
target_link_libraries(ouster_pcap
Expand Down
52 changes: 50 additions & 2 deletions ouster_pcap/src/ip_reassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,29 @@

#include "ip_reassembler.h"

#include <tins/arp.h>
#include <tins/constants.h>
#include <tins/detail/pdu_helpers.h>
#include <tins/dot11/dot11_base.h>
#include <tins/dot1q.h>
#include <tins/eapol.h>
#include <tins/ethernetII.h>
#include <tins/icmp.h>
#include <tins/icmpv6.h>
#include <tins/ieee802_3.h>
#include <tins/ip.h>

#include <tins/ipsec.h>
#include <tins/ipv6.h>
#include <tins/loopback.h>
#include <tins/mpls.h>
#include <tins/pdu_allocator.h>
#include <tins/ppi.h>
#include <tins/pppoe.h>
#include <tins/radiotap.h>
#include <tins/rawpdu.h>
#include <tins/sll.h>
#include <tins/tcp.h>
#include <tins/udp.h>
using std::make_pair;

namespace Tins {
Expand Down Expand Up @@ -95,6 +114,35 @@ bool IPv4Stream2::is_complete() const {
return fragments_.begin()->offset() == 0;
}

static Tins::PDU* pdu_from_flag2(Constants::IP::e flag, const uint8_t* buffer,
uint32_t size,
bool rawpdu_on_no_match = true) {
switch (flag) {
case Constants::IP::PROTO_IPIP:
return new Tins::IP(buffer, size);
case Constants::IP::PROTO_TCP:
return new Tins::TCP(buffer, size);
case Constants::IP::PROTO_UDP:
return new Tins::UDP(buffer, size);
case Constants::IP::PROTO_ICMP:
return new Tins::ICMP(buffer, size);
case Constants::IP::PROTO_ICMPV6:
return new Tins::ICMPv6(buffer, size);
case Constants::IP::PROTO_IPV6:
return new Tins::IPv6(buffer, size);
case Constants::IP::PROTO_AH:
return new Tins::IPSecAH(buffer, size);
case Constants::IP::PROTO_ESP:
return new Tins::IPSecESP(buffer, size);
default:
break;
}
if (rawpdu_on_no_match) {
return new Tins::RawPDU(buffer, size);
}
return 0;
}

PDU* IPv4Stream2::allocate_pdu() const {
PDU::serialization_type buffer;
buffer.reserve(total_size_);
Expand All @@ -108,7 +156,7 @@ PDU* IPv4Stream2::allocate_pdu() const {
expected = it->offset() + it->payload().size();
buffer.insert(buffer.end(), it->payload().begin(), it->payload().end());
}
return Internals::pdu_from_flag(
return pdu_from_flag2(
static_cast<Constants::IP::e>(first_fragment_.protocol()),
buffer.empty() ? 0 : &buffer[0], static_cast<uint32_t>(buffer.size()));
}
Expand Down
4 changes: 2 additions & 2 deletions ouster_pcap/src/ip_reassembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class IPv4Fragment2 {
uint16_t offset_;
};

class TINS_API IPv4Stream2 {
class IPv4Stream2 {
public:
IPv4Stream2();

Expand Down Expand Up @@ -119,7 +119,7 @@ class TINS_API IPv4Stream2 {
* });
* \endcode
*/
class TINS_API IPv4Reassembler2 {
class IPv4Reassembler2 {
public:
/**
* The status of each processed packet.
Expand Down
4 changes: 4 additions & 0 deletions ouster_viz/src/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

#include "ouster/point_viz.h"

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

namespace ouster {
namespace viz {

Expand Down
4 changes: 4 additions & 0 deletions ouster_viz/src/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include "glfw.h"
#include "ouster/point_viz.h"

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

namespace ouster {
namespace viz {
namespace impl {
Expand Down
1 change: 1 addition & 0 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def install_requires():
install_requires.append(temp)
return install_requires


if __name__ == "__main__":
setup(
name='ouster-sdk',
Expand Down
16 changes: 8 additions & 8 deletions python/src/ouster/sdk/examples/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ def filter_3d_by_range_and_azimuth(hostname: str,
plt.figure()
ax = plt.axes(projection='3d')
r = 3
ax.set_xlim3d([-r, r])
ax.set_ylim3d([-r, r])
ax.set_zlim3d([-r, r])
ax.set_xlim3d([-r, r]) # type: ignore
ax.set_ylim3d([-r, r]) # type: ignore
ax.set_zlim3d([-r, r]) # type: ignore

plt.title("Filtered 3D Points from {}".format(hostname))

Expand All @@ -155,7 +155,7 @@ def filter_3d_by_range_and_azimuth(hostname: str,
# [doc-etag-filter-3d]

[x, y, z] = [c.flatten() for c in np.dsplit(xyz_filtered, 3)]
ax.scatter(x, y, z, c=z / max(z), s=0.2)
ax.scatter(x, y, z, c=z / max(z), s=0.2) # type: ignore
plt.show()


Expand Down Expand Up @@ -210,9 +210,9 @@ def plot_xyz_points(hostname: str, lidar_port: int = 7502) -> None:
plt.figure()
ax = plt.axes(projection='3d')
r = 3
ax.set_xlim3d([-r, r])
ax.set_ylim3d([-r, r])
ax.set_zlim3d([-r, r])
ax.set_xlim3d([-r, r]) # type: ignore
ax.set_ylim3d([-r, r]) # type: ignore
ax.set_zlim3d([-r, r]) # type: ignore

plt.title("3D Points from {}".format(hostname))

Expand All @@ -224,7 +224,7 @@ def plot_xyz_points(hostname: str, lidar_port: int = 7502) -> None:

# graph xyz
[x, y, z] = [c.flatten() for c in np.dsplit(xyz, 3)]
ax.scatter(x, y, z, c=z / max(z), s=0.2)
ax.scatter(x, y, z, c=z / max(z), s=0.2) # type: ignore
plt.show()


Expand Down
8 changes: 4 additions & 4 deletions python/src/ouster/sdk/examples/pcap.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ def pcap_display_xyz_points(source: client.PacketSource,
plt.figure()
ax = plt.axes(projection='3d')
r = 6
ax.set_xlim3d([-r, r])
ax.set_ylim3d([-r, r])
ax.set_zlim3d([-r, r])
ax.set_xlim3d([-r, r]) # type: ignore
ax.set_ylim3d([-r, r]) # type: ignore
ax.set_zlim3d([-r, r]) # type: ignore

plt.title("3D Points XYZ for scan")

Expand All @@ -107,7 +107,7 @@ def pcap_display_xyz_points(source: client.PacketSource,
key = scan.field(client.ChanField.REFLECTIVITY)

[x, y, z] = [c.flatten() for c in np.dsplit(xyz, 3)]
ax.scatter(x, y, z, c=normalize(key.flatten()), s=0.2)
ax.scatter(x, y, z, c=normalize(key.flatten()), s=0.2) # type: ignore
plt.show()
# [doc-etag-pcap-plot-xyz-points]

Expand Down
1 change: 1 addition & 0 deletions tests/cartesian_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <gtest/gtest.h>

#include <Eigen/Eigen>
#include <iomanip>
#include <numeric>
#include <random>

Expand Down
1 change: 1 addition & 0 deletions tests/parsing_benchmark_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <gtest/gtest.h>

#include <iomanip>
#include <numeric>
#include <random>

Expand Down

0 comments on commit 27bc78f

Please sign in to comment.