Skip to content

Commit

Permalink
UID2-2349 Add build pipeline for aws vsock proxy
Browse files Browse the repository at this point in the history
- first cut: basic build/test/package workflow
  • Loading branch information
atarassov-ttd committed Nov 21, 2023
1 parent b6e50ed commit fed7999
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 72 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build/Test/Package

on: [push]

jobs:
build:
runs-on: ubuntu-latest
container: amazonlinux:2
strategy:
matrix:
build_type: [debug, relwithdebinfo]
steps:
- name: Dev environment
run: |
yum groupinstall -y "Development Tools"
yum install -y cmake3 valgrind git
- uses: actions/checkout@v3

- name: Build and Test
run: |
cmake3 -S . -B build -DCMAKE_BUILD_TYPE=${{matrix.build_type}}
cd build
make package
make test
- uses: actions/upload-artifact@v3
if: matrix.build_type == 'release'
with:
name: vsock-bridge.tar.gz
path: build/*.tar.gz
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
.idea
16 changes: 14 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
cmake_minimum_required (VERSION 3.8)

project ("vsock-bridge")
if (DEFINED ENV{RELEASE_VERSION})
set (RELEASE_VERSION "$ENV{RELEASE_VERSION}")
else ()
set (RELEASE_VERSION "0.0.0")
endif ()

set(CMAKE_CXX_FLAGS_DEBUG "-ggdb")
project ("vsock-bridge" VERSION ${RELEASE_VERSION})

add_compile_options ("$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:-ggdb>")
set (CXX_STANDARD 17)
enable_testing ()

set (CPACK_GENERATOR "TGZ")
set (CPACK_PACKAGE_FILE_NAME "vsock-bridge-${RELEASE_VERSION}")
include (CPack)

add_subdirectory ("vsock-bridge")
43 changes: 0 additions & 43 deletions CMakeSettings.json

This file was deleted.

10 changes: 2 additions & 8 deletions vsock-bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# CMakeList.txt : CMake project for vsock-bridge, include source and define
# project specific logic here.
#
cmake_minimum_required (VERSION 3.8)

configure_file (include/version.h.in include/version.h)
add_subdirectory (src)

enable_testing ()
add_subdirectory (test)
add_subdirectory (test)
3 changes: 3 additions & 0 deletions vsock-bridge/include/version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

#define VSOCK_BRIDGE_VERSION "@PROJECT_VERSION@"
13 changes: 6 additions & 7 deletions vsock-bridge/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
cmake_minimum_required (VERSION 3.8)

add_library (vsock-io "socket.cpp" "logger.cpp" "epoll_poller.cpp")

add_executable (vsock-bridge "vsock-bridge.cpp" "config.cpp" "global.cpp")
target_link_libraries(vsock-bridge vsock-io pthread -static-libgcc -static-libstdc++)
target_link_libraries (vsock-bridge vsock-io pthread -static-libgcc -static-libstdc++)

target_include_directories(vsock-io PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include)
target_include_directories(vsock-bridge PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include)
target_include_directories (vsock-io PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include)
target_include_directories (vsock-bridge
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/../include)

set_property(TARGET vsock-io PROPERTY CXX_STANDARD 17)
set_property(TARGET vsock-bridge PROPERTY CXX_STANDARD 17)
install(TARGETS vsock-bridge DESTINATION bin)
16 changes: 14 additions & 2 deletions vsock-bridge/src/vsock-bridge.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <vsock-bridge.h>
#include "version.h"
#include "vsock-bridge.h"

using namespace vsockio;
using namespace vsockproxy;
Expand Down Expand Up @@ -114,6 +115,11 @@ void show_help()
<< std::flush;
}

void show_version()
{
std::cout << VSOCK_BRIDGE_VERSION << std::endl;
}

void quit_bad_args(const char* reason, bool showhelp)
{
std::cout << reason << std::endl;
Expand Down Expand Up @@ -147,7 +153,13 @@ int main(int argc, char* argv[])
exit(0);
}

else if (strcmp(argv[i], "-d") == 0 || strcmp(argv[i], "--daemon") == 0)
else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0)
{
show_version();
exit(0);
}

else if (strcmp(argv[i], "-d") == 0 || strcmp(argv[i], "--daemon") == 0)
{
daemonize = true;
}
Expand Down
14 changes: 4 additions & 10 deletions vsock-bridge/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
cmake_minimum_required (VERSION 3.8)
add_executable (vsock-bridge-tests testmain.cpp)
target_include_directories (vsock-bridge-tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include)
target_link_libraries (vsock-bridge-tests vsock-io pthread)

include_directories (tests
${CMAKE_CURRENT_SOURCE_DIR}/../include
)

add_executable (tests testmain.cpp)

target_link_libraries (tests vsock-io pthread)

add_test (NAME VSockTest COMMAND tests)
add_test (vsock-bridge-tests vsock-bridge-tests)

0 comments on commit fed7999

Please sign in to comment.