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 28, 2023
1 parent c2a56a3 commit 25b3ea3
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 72 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build and test Package

on:
push:
schedule:
- cron: '30 5 * * *'
workflow_dispatch:
inputs:
ref:
description: "Commit hash"
default: ""

jobs:
codeql:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{inputs.ref}}

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: c-cpp

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: c-cpp

build:
needs: [codeql]
runs-on: ubuntu-latest
container: amazonlinux:2
strategy:
matrix:
build_type: [debug, relwithdebinfo]
steps:
- name: Set up Dev Environment
run: |
yum groupinstall -y "Development Tools"
yum install -y cmake3 valgrind git
- uses: actions/checkout@v3
with:
ref: ${{inputs.ref}}

- name: Build and Test
run: |
cmake3 -S . -B build -DCMAKE_BUILD_TYPE=${{matrix.build_type}}
cd build
make package
make test
37 changes: 37 additions & 0 deletions .github/workflows/publish-pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish pre-release Package

on:
workflow_dispatch:
inputs:
ref:
description: "Commit hash"
default: ""

jobs:
build:
runs-on: ubuntu-latest
container: amazonlinux:2
strategy:
matrix:
build_type: [relwithdebinfo]
steps:
- name: Set up Dev Environment
run: |
yum groupinstall -y "Development Tools"
yum install -y cmake3 valgrind git
- uses: actions/checkout@v3
with:
ref: ${{inputs.ref}}

- 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
with:
name: Pre-release
path: build/*.tar.gz
56 changes: 56 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Publish release Package

on:
workflow_dispatch:
inputs:
version:
description: "Release version (major.minor.patch)"
required: true
ref:
description: "Commit hash"
default: ""

jobs:
build:
runs-on: ubuntu-latest
container: amazonlinux:2
strategy:
matrix:
build_type: [relwithdebinfo]
steps:
- name: Set up Dev Environment
run: |
yum groupinstall -y "Development Tools"
yum install -y cmake3 valgrind git
- uses: actions/checkout@v3
with:
ref: ${{inputs.ref}}

- name: Build and Test
run: |
cmake3 -S . -B build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DRELEASE_VERSION=${{inputs.version}}
cd build
make package
make test
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: v${{ inputs.version }}
release_name: v${{ inputs.version }}
draft: true
prerelease: false

- name: upload linux artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/vsock-bridge-${{inputs.version}}.tar.gz
asset_name: vsock-bridge-${{inputs.version}}.tar.gz
asset_content_type: application/tar+gzip
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
.idea
14 changes: 12 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
cmake_minimum_required (VERSION 3.8)

project ("vsock-bridge")
if (NOT DEFINED RELEASE_VERSION)
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 25b3ea3

Please sign in to comment.