Skip to content

Commit

Permalink
Merge pull request #1 from tst-race/fix-ci
Browse files Browse the repository at this point in the history
Fix ci
  • Loading branch information
vines26 authored Feb 8, 2024
2 parents 8b818ff + ecc39c7 commit 863cc1b
Show file tree
Hide file tree
Showing 539 changed files with 49,890 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pluggable-transport/pt-client-image/client-mount/libxul.so filter=lfs diff=lfs merge=lfs -text
95 changes: 95 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Continuous Integration

on:
push:
pull_request:
branches:
- 'main'
workflow_dispatch:

permissions:
contents: write
packages: read

jobs:
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/tst-race/race-images/race-compile:main
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Build
run: ./build_it_all.sh

- name: Build-pt
run: ./pluggable-transport/build.sh -p=build/LINUX_x86_64/language-shims/source/include/src/core

- name: Create Build Artifact
# NOTE: _commsPluginBindings.so not in racesdk/package/
run: "tar cvf ${{ github.event.repository.name }}.tar.gz -C racesdk/package/ ."

- name: Upload Build Artifact
uses: actions/upload-artifact@v3
with:
name: "${{ github.event.repository.name }}-linux-x86_64.tar.gz"
path: "${{ github.event.repository.name }}-linux-x86_64.tar.gz"
retention-days: 10

# todo base these on the raceboat image
test-unit:
# needs: build
runs-on: ubuntu-latest
container:
image: ghcr.io/tst-race/race-images/race-compile:main
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: unit test
uses: actions/checkout@v3

- name: Build and Run Unit Tests
# shuffle the order of the tests to potentially uncover weirdness
# note that you can reproduce the test results by finding the seed in the log output and
# setting the environment variable GTEST_RANDOM_SEED to that value.
env:
GTEST_SHUFFLE: 1
run: |
./build_it_all.sh
cmake --build --preset=LINUX_x86_64 --target run_tests -j
test-coverage:
# needs: build
runs-on: ubuntu-latest
container:
image: ghcr.io/tst-race/race-images/race-compile:main
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Build and Run Unit Tests
# shuffle the order of the tests to potentially uncover weirdness
# note that you can reproduce the test results by finding the seed in the log output and
# setting the environment variable GTEST_RANDOM_SEED to that value.
env:
GTEST_SHUFFLE: 1
run: |
cmake --preset=coverage
cmake --build --preset=coverage --target coverage
test-format:
# needs: build
runs-on: ubuntu-latest
container:
image: ghcr.io/tst-race/race-images/race-compile:main
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Check Format
run: |
./build_it_all.sh
cmake --build --preset=LINUX_x86_64 --target check_format -j
73 changes: 73 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
##############################
## CMake
##############################
build/
cmake
racesdk/

##############################
## IntelliJ
##############################
out/
.idea/
.idea_modules/
*.iml
*.ipr
*.iws

##############################
## Eclipse
##############################
.settings/
bin/
tmp/
.metadata
.classpath
.project
*.tmp
*.bak
*.swp
*~.nib
local.properties
.loadpath
.factorypath

##############################
## NetBeans
##############################
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml

##############################
## Visual Studio Code
##############################
.vscode/

##############################
## OS X
##############################
.DS_Store

##############################
## Gitlab
##############################
.gitlab_artifacts
*~

##############################
## gcov
##############################
*.gcov

##############################
## unit test output
##############################
*.output
some-file-in-tar-gz.txt
**/__pycache__
test/input-files/usr/*
66 changes: 66 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

# Copyright 2023 Two Six Technologies
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

cmake_minimum_required(VERSION 3.13)
project(raceboat LANGUAGES CXX)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -v")

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/race-cmake-modules)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_BUILD_TYPE Debug)

set(BUILD_VERSION "" CACHE STRING "Version of the SDK being built")
if("${BUILD_VERSION}" STREQUAL "")
message(FATAL_ERROR "Missing or empty BUILD_VERSION argument")
endif()

include(race/clang-format)
include(race/coverage)
include(race/java-format)
include(race/lint)
include(race/test-targets)
include(race/valgrind)
include(race/warnings)

setup_project_test_targets(raceboat UNIT INTEGRATION)
setup_project_format_targets(raceboat)

add_subdirectory(language-shims)
add_subdirectory(source)
if(NOT ANDROID)
add_subdirectory(app/race-cli)
add_subdirectory(test/common/UnifiedTestStub EXCLUDE_FROM_ALL)
add_subdirectory(test/common/DecomposedTestStub EXCLUDE_FROM_ALL)
add_subdirectory(test/common/plugins/myOS/myArch/DecomposedTestImplementation EXCLUDE_FROM_ALL)
add_subdirectory(test/source EXCLUDE_FROM_ALL)
endif()

# Create this after all subdirectories have been added
setup_project_coverage_target()

install(
TARGETS
raceboat
EXPORT raceboat
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include
)

install(
EXPORT raceboat
DESTINATION lib/cmake
)
9 changes: 9 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"version": 4,
"include": [
"./race-cmake-modules/presets/linux_x86_64.json",
"./race-cmake-modules/presets/linux_arm64-v8a.json",
"./race-cmake-modules/presets/android_x86_64.json",
"./race-cmake-modules/presets/android_arm64-v8a.json"
]
}
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# RACE communications libraries
This repository contains a library that can be used to communicate with another user of the library over RACE Comms channels.

## Creating `raceboat` docker image
Build, create package, and build the docker image. Use a `race-compile` container to build and create the package. The following demonstrates building for an aarch64 target platform. The flags will need to change for other target platforms, and is documented in the scripts.

```bash
cd raceboat
docker run -it --rm -v $(pwd):/code/ -w /code race-compile:main bash
./build_it_all.sh
./create-package.sh --linux<-arm64>
exit
./docker-image/build_image.sh --platform-arm64
```

Building results in several libraries. Two of which are suitable for real-world use. The others support tests.
`./racesdk/package/LINUX*/lib/libraceboat.so`
- mandatory core functionality with C++ APIs
- could be copied to /usr/local/lib/ or somewhere in `$PATH`
`./build/LINUX*/language-shims/source/_commsPluginBindings.so`
- optional library with python bindings
- should go into shims path (see `FileSystem::makeShimsPath()`)
- see [Using Plugin Bindings](./language-shims/README.md#using-python-bindings)

As with any C++ API, the header files are necessary for use.
`./racesdk/package/LINUX*/include/*.h`
- C++ API headers
- could copied to /usr/local/include/ or somewhere in `$PATH`

`./racesdk/package/LINUX*/` will be `./racesdk/package/ANDROID*/` when building for Android.


## Testing using race-cli
See race-email channel README.md for examples

The following demonstrates how to use race-cli client-connect and server-connect functions with direct twosix cpp exemplar channel in a race-sdk docker container. Some of these paths will change slightly when not building on aarch64 host.

NOTE: see `FileSystem::makePluginInstallBasePath()` for path requirements of where to copy the plugins to. `find /code/private-race-core -name libraceboat.so` for raceboat.

NOTE: `--param hostname=localhost` does not work in this test. You can use the ip addresses reported from ifconfig on both nodes.
### server
```bash
docker run -it -v $(pwd):/code/ -v /tmp/:/tmp/ race-sdk:latest bash
cp -r /code/private-race-core/plugin-comms-twosix-cpp/kit/artifacts/linux-arm64-v8a-server/PluginCommsTwoSixStub/* /tmp/race/plugins/unix/arm64-v8a/PluginCommsTwoSixStub
ln -s /code/private-raceboat/build/LINUX_arm64-v8a/source/libraceboat.so /usr/local/lib/raceSdkCommon.so
cd /code/private-raceboat/build/LINUX_arm64-v8a/app/race-cli/
./race-cli --debug --dir /tmp/race -m --server-connect --send-channel twoSixDirectCpp --recv-channel twoSixDirectCpp --param hostname="172.17.0.4" --param PluginCommsTwoSixStub.startPort=26262 --param PluginCommsTwoSixStub.endPort=26264
```

### client
```bash
docker run -it -v $(pwd):/code/ -v /tmp/:/tmp/ race-sdk:latest bash
cp -r /code/private-race-core/plugin-comms-twosix-cpp/kit/artifacts/linux-arm64-v8a-client/PluginCommsTwoSixStub/* /tmp/race/plugins/unix/arm64-v8a/PluginCommsTwoSixStub
ln -s /code/private-raceboat/build/LINUX_arm64-v8a/source/libraceboat.so /usr/local/lib/raceSdkCommon.so
cd /code/private-raceboat/build/LINUX_arm64-v8a/app/race-cli/
./race-cli --debug --dir /tmp/race -m --client-connect --send-channel twoSixDirectCpp --recv-channel twoSixDirectCpp --param hostname="172.17.0.5" --param PluginCommsTwoSixStub.startPort=26262 --param PluginCommsTwoSixStub.endPort=26264 --send-address="{\"hostname\":\"172.17.0.4\",\"port\":26262}"
```


## Build and Run Unit Tests

Make sure the main project has already been built using the above commands

```bash
cd build/LINUX*/test/source/
make
./testStandaloneLibrary
```

## Formatting
```bash
cmake --build --preset=LINUX_x86_64 --target check_format -j
```

## APIs
See CommPluginDeveloperGuide.md in the `race-docs` repository for information about working with Comms plugins.
44 changes: 44 additions & 0 deletions app/race-cli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

# Copyright 2023 Two Six Technologies
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#


add_executable(race-cli main.cpp)

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

target_include_directories(race-cli PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)


target_link_libraries(race-cli
raceboat
stdc++fs
Threads::Threads
${CMAKE_DL_LIBS} # Contains dlopen and dlcose for dynamically loading plugins.
)

# TODO enable performance-* and readability-* checks (needs fixes)
setup_clang_tidy_for_target(TARGET race-cli)
# setup_cppcheck_for_target(
# TARGET race-cli
# CHECKS all
# SUPPRESS unmatchedSuppression unusedFunction missingIncludeSystem useStlAlgorithm
# )
setup_clang_format_for_target(race-cli PARENT raceboat)
Loading

0 comments on commit 863cc1b

Please sign in to comment.