Merge pull request #2 from F-WuTS/feature/ci-packing
This commit is contained in:
commit
d5885d4d39
12 changed files with 207 additions and 48 deletions
2
.dockerignore
Normal file
2
.dockerignore
Normal file
|
@ -0,0 +1,2 @@
|
|||
.github
|
||||
ci/Dockerfile
|
38
.github/workflows/ci.yaml
vendored
38
.github/workflows/ci.yaml
vendored
|
@ -1,38 +0,0 @@
|
|||
name: Build and test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['master']
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-20.04, ubuntu-22.04]
|
||||
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt install build-essential cmake git libboost-system-dev libboost-thread-dev
|
||||
git clone https://github.com/google/googletest.git
|
||||
cd googletest
|
||||
cmake CMakeLists.txt
|
||||
make
|
||||
sudo make install
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_FLAGS="-Werror"
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
|
||||
- name: Test
|
||||
working-directory: ${{github.workspace}}/build
|
||||
run: ctest -C ${{env.BUILD_TYPE}}
|
41
.github/workflows/package.yaml
vendored
Normal file
41
.github/workflows/package.yaml
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
name: Package
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "*"
|
||||
|
||||
jobs:
|
||||
package:
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [linux/arm64/v8]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
platforms: linux/arm64
|
||||
|
||||
- name: Prepare container
|
||||
run: docker buildx build -f ci/Dockerfile . -t libcreate --platform ${{ matrix.platform }} --load
|
||||
- name: Build
|
||||
run: docker run --platform ${{ matrix.platform }} -v ./output:/libcreate/_packages libcreate
|
||||
- name: Push deb to compREP
|
||||
uses: cpina/github-action-push-to-another-repository@main
|
||||
env:
|
||||
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
|
||||
with:
|
||||
source-directory: "output/"
|
||||
target-directory: "debs/libcreate/"
|
||||
destination-github-username: "F-WuTS"
|
||||
destination-repository-name: "compREP"
|
||||
target-branch: master
|
30
.github/workflows/test.yaml
vendored
Normal file
30
.github/workflows/test.yaml
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
name: Build and test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["master"]
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt install build-essential cmake git libboost-system-dev libboost-thread-dev file libgtest-dev googletest
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
|
||||
- name: Test
|
||||
working-directory: ${{github.workspace}}/build
|
||||
run: ctest -C ${{env.BUILD_TYPE}}
|
|
@ -1,3 +1,17 @@
|
|||
#########
|
||||
# Setup #
|
||||
#########
|
||||
|
||||
cmake_minimum_required(VERSION 3.25)
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
include(Versioning)
|
||||
|
||||
########
|
||||
# Main #
|
||||
########
|
||||
|
||||
# After installation this project can be found by 'find_package' command:
|
||||
#
|
||||
# find_package(libcreate REQUIRED)
|
||||
|
@ -5,12 +19,14 @@
|
|||
# target_link_libraries(... ${libcreate_LIBRARIES})
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
project(libcreate)
|
||||
project(
|
||||
libcreate
|
||||
VERSION ${TAG_VERSION_MAJOR}.${TAG_VERSION_MINOR}.${TAG_VERSION_PATCH}
|
||||
)
|
||||
|
||||
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||
add_compile_options(-Wall -Wextra -Wpedantic -Werror)
|
||||
|
||||
set(PACKAGE_VERSION 3.0.0)
|
||||
set(PACKAGE_VERSION ${TAG_VERSION_MAJOR}.${TAG_VERSION_MINOR}.${TAG_VERSION_PATCH})
|
||||
|
||||
option(LIBCREATE_BUILD_TESTS "Enable the build of tests." ON)
|
||||
|
||||
|
@ -203,3 +219,9 @@ if(LIBCREATE_BUILD_TESTS AND ${GTEST_FOUND})
|
|||
else()
|
||||
message("No GTest installation found. Skipping tests.")
|
||||
endif()
|
||||
|
||||
#############
|
||||
# Packaging #
|
||||
#############
|
||||
|
||||
include(Packing)
|
14
ci/Dockerfile
Normal file
14
ci/Dockerfile
Normal file
|
@ -0,0 +1,14 @@
|
|||
FROM debian:bookworm
|
||||
|
||||
RUN apt update && \
|
||||
apt install -y \
|
||||
build-essential cmake git file tree \
|
||||
libboost-system-dev libboost-thread-dev \
|
||||
libgtest-dev googletest && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /libcreate
|
||||
COPY . .
|
||||
|
||||
WORKDIR /libcreate/build
|
||||
ENTRYPOINT ["/bin/bash", "/libcreate/ci/entrypoint.sh"]
|
15
ci/entrypoint.sh
Executable file
15
ci/entrypoint.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
cmake -B /libcreate/build -S /libcreate -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build /libcreate/build --config Release
|
||||
ctest -C Release --output-on-failure
|
||||
cpack --build /libcreate/build -G DEB
|
||||
|
||||
debs=(/libcreate/_packages/*.deb)
|
||||
cp "${debs[0]}" /tmp/libcreate.deb
|
||||
dpkg-deb -R /tmp/libcreate.deb /tmp/libcreate
|
||||
tree /tmp/libcreate
|
41
cmake/Packing.cmake
Normal file
41
cmake/Packing.cmake
Normal file
|
@ -0,0 +1,41 @@
|
|||
# these are cache variables, so they could be overwritten with -D,
|
||||
set(CPACK_PACKAGE_NAME ${PROJECT_NAME}
|
||||
CACHE STRING "The resulting package name"
|
||||
)
|
||||
# which is useful in case of packing only selected components instead of the whole thing
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "C++ library for interfacing with iRobot's Create 1 and 2"
|
||||
CACHE STRING "Package description for the package metadata"
|
||||
)
|
||||
set(CPACK_PACKAGE_VENDOR "Verein zur Förderung von Jugendlichen durch Robotikwettbewerbe")
|
||||
|
||||
set(CPACK_VERBATIM_VARIABLES YES)
|
||||
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
|
||||
SET(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_SOURCE_DIR}/_packages")
|
||||
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
|
||||
|
||||
set(CPACK_PACKAGE_CONTACT "kontakt@comp-air.at")
|
||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "comp-air dev team")
|
||||
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
|
||||
|
||||
# Discover and set dependencies correcly
|
||||
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS YES)
|
||||
|
||||
# The installation path directory should have 0755 permissions
|
||||
set(
|
||||
CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
|
||||
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
||||
GROUP_READ GROUP_EXECUTE
|
||||
WORLD_READ WORLD_EXECUTE
|
||||
)
|
||||
|
||||
# package name for deb. If set, then instead of some-application-0.9.2-Linux.deb
|
||||
# you'll get some-application_0.9.2_amd64.deb (note the underscores too)
|
||||
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
|
||||
|
||||
include(CPack)
|
31
cmake/Versioning.cmake
Normal file
31
cmake/Versioning.cmake
Normal file
|
@ -0,0 +1,31 @@
|
|||
find_package(Git)
|
||||
|
||||
if(GIT_EXECUTABLE)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} describe --tags
|
||||
OUTPUT_VARIABLE TAG_VERSION
|
||||
RESULT_VARIABLE ERROR_CODE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
if(DEFINED ENV{GITHUB_REF} AND ENV{GITHUB_REF_TYPE} EQUAL "tag")
|
||||
set(TAG_VERSION $ENV{GITHUB_REF})
|
||||
message(STATUS "Extracted version from GITHUB_REF")
|
||||
endif()
|
||||
|
||||
if(TAG_VERSION STREQUAL "")
|
||||
set(TAG_VERSION 0.0.0)
|
||||
message(WARNING "Failed to determine version from Git tags. Using default version \"${TAG_VERSION}\".")
|
||||
endif()
|
||||
|
||||
message(STATUS "Project version: ${TAG_VERSION}")
|
||||
|
||||
# Split into major, minor, patch
|
||||
string(
|
||||
REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)"
|
||||
TAG_VERSION_MATCH ${TAG_VERSION}
|
||||
)
|
||||
set(TAG_VERSION_MAJOR ${CMAKE_MATCH_1})
|
||||
set(TAG_VERSION_MINOR ${CMAKE_MATCH_2})
|
||||
set(TAG_VERSION_PATCH ${CMAKE_MATCH_3})
|
||||
endif()
|
|
@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define CREATE_PACKET_H
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
namespace create {
|
||||
class Packet {
|
||||
|
|
0
package.sh
Executable file
0
package.sh
Executable file
|
@ -65,11 +65,11 @@ TEST(DataTest, GetNumPackets)
|
|||
|
||||
create::Data data_v_3(create::V_3);
|
||||
// Number exclusive to V_3 = 13
|
||||
// 17 + 13 = 30
|
||||
EXPECT_EQ(static_cast<int>(data_v_3.getNumPackets()), 30);
|
||||
// 17 + 17 = 34
|
||||
EXPECT_EQ(static_cast<int>(data_v_3.getNumPackets()), 34);
|
||||
|
||||
create::Data data_v_all(create::V_ALL);
|
||||
EXPECT_EQ(static_cast<int>(data_v_all.getNumPackets()), 33);
|
||||
EXPECT_EQ(static_cast<int>(data_v_all.getNumPackets()), 37);
|
||||
}
|
||||
|
||||
TEST(DataTest, GetPacket)
|
||||
|
@ -108,7 +108,7 @@ TEST(DataTest, GetPacketIDs)
|
|||
create::Data data_v_3(create::V_3);
|
||||
const std::vector<uint8_t> packet_ids = data_v_3.getPacketIDs();
|
||||
// Vector should have same length as reported by getNumPackets()
|
||||
ASSERT_EQ(static_cast<int>(packet_ids.size()), 30);
|
||||
ASSERT_EQ(static_cast<int>(packet_ids.size()), 34);
|
||||
|
||||
// Vector should contain ID_LEFT_ENC
|
||||
bool found = false;
|
||||
|
@ -133,9 +133,9 @@ TEST(DataTest, GetTotalDataBytes)
|
|||
create::Data data_v_2(create::V_2);
|
||||
EXPECT_EQ(static_cast<int>(data_v_2.getTotalDataBytes()), 26);
|
||||
|
||||
// V_3 has an additional 21 bytes
|
||||
// V_3 has an additional 29 bytes
|
||||
create::Data data_v_3(create::V_3);
|
||||
EXPECT_EQ(static_cast<int>(data_v_3.getTotalDataBytes()), 42);
|
||||
EXPECT_EQ(static_cast<int>(data_v_3.getTotalDataBytes()), 50);
|
||||
}
|
||||
|
||||
TEST(DataTest, IsValidPacketID)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue