Skip to content

Commit

Permalink
Adding ci tooling for exchange
Browse files Browse the repository at this point in the history
Changed default working directory

Change to test ci

Formatting and spellcheck

Hoping clang format 17 works

Adapting ci from raccoon

update to llvm 17

Updated working directory for deps that need conan profile

Second revision to conan installation

fix include errors

Changing conan build type to release

Definitely wont work

Def wont work 2 electric boogaloo

Quick test

Test 2

Another lol

ANOTHER

Fixed working directories
  • Loading branch information
stevenewald committed Oct 23, 2023
1 parent 9a794ef commit 8ef7475
Show file tree
Hide file tree
Showing 19 changed files with 198 additions and 97 deletions.
File renamed without changes.
158 changes: 126 additions & 32 deletions exchange/.github/workflows/ci.yml.disabled → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,109 @@
name: Continuous Integration
name: Exchange Continuous Integration

on:
push:
branches:
- master
- main
- ci-test
# paths:
# - exchange

pull_request:
branches:
- master
- main
- ci-test
# paths:
# - exchange

workflow_dispatch:

# We only care about the latest revision of a PR, so cancel all previous instances.
concurrency:
group: ci-${{ github.event.pull_request.number || github.ref_name }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: exchange

steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'

- uses: actions/setup-python@v4
with: { python-version: "3.8" }
with: { python-version: "3.11" }

- name: Install LLVM 17
run: |
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main"
sudo apt update
sudo apt install llvm-17 llvm-17-dev llvm-17-tools clang-17 clang-tidy-17 clang-format-17 clang-tools-17 libclang-17-dev -y
- name: Install codespell
run: pip3 install codespell

- name: Lint
run: cmake -D FORMAT_COMMAND=clang-format-14 -P cmake/lint.cmake
run: cmake -D FORMAT_COMMAND=clang-format-17 -P cmake/lint.cmake

- name: Spell check
if: always()
run: cmake -P cmake/spell.cmake

coverage:
needs: [lint]

runs-on: ubuntu-22.04
defaults:
run:
working-directory: exchange


# To enable coverage, delete the last line from the conditional below and
# edit the "<name>" placeholder to your GitHub name.
# If you do not wish to use codecov, then simply delete this job from the
# workflow.
if: github.repository_owner == '<name>'
&& false
if: github.repository_owner == 'northwesternfintech'

env:
CC: gcc-13
CXX: g++-13

steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Install LCov
run: sudo apt-get update -q
&& sudo apt-get install lcov -q -y
run: sudo apt update -q
&& sudo apt install lcov -q -y

- name: Install Python
uses: actions/setup-python@v4
with: { python-version: "3.8" }
with: { python-version: "3.11" }

- name: Install GCC 13
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gcc-13 g++-13 -y
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 130
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 130
sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-13 130
- name: Install dependencies
run: |
pip3 install conan
bash < .github/scripts/conan-profile.sh
conan install . -b missing
sudo apt install libssl-dev -y
bash < ../.github/scripts/conan-profile.sh
conan install . -s build_type=Release -b missing
- name: Configure
run: cmake --preset=ci-coverage
Expand All @@ -65,7 +112,7 @@ jobs:
run: cmake --build build/coverage -j 2

- name: Test
working-directory: build/coverage
working-directory: exchange/build/coverage
run: ctest --output-on-failure --no-tests=error -j 2

- name: Process coverage info
Expand All @@ -80,21 +127,41 @@ jobs:
needs: [lint]

runs-on: ubuntu-22.04
defaults:
run:
working-directory: exchange


env: { CXX: clang++-14 }
env:
CC: clang-17
CXX: clang++-17
CLANG_DIR: '/usr/lib/llvm-17/lib/cmake/clang'
LLVM_DIR: '/usr/lib/llvm-17/lib/cmake/llvm'

steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Install Python
uses: actions/setup-python@v4
with: { python-version: "3.8" }
with: { python-version: "3.11" }

- name: Install LLVM 17
run: |
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main"
sudo apt update
sudo apt install llvm-17 llvm-17-dev llvm-17-tools clang-17 clang-tidy-17 clang-tools-17 libclang-17-dev -y
- name: Install dependencies
run: |
pip3 install conan
bash < .github/scripts/conan-profile.sh
conan install . -b missing
sudo apt install libssl-dev -y
bash < ../.github/scripts/conan-profile.sh
conan install . -s build_type=Release -b missing
- name: Configure
run: cmake --preset=ci-sanitize
Expand All @@ -103,7 +170,7 @@ jobs:
run: cmake --build build/sanitize -j 2

- name: Test
working-directory: build/sanitize
working-directory: exchange/build/sanitize
env:
ASAN_OPTIONS: "strict_string_checks=1:\
detect_stack_use_after_return=1:\
Expand All @@ -118,32 +185,54 @@ jobs:

strategy:
matrix:
os: [macos-12, ubuntu-22.04, windows-2022]
os: [ubuntu-22.04]

runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: exchange


env:
CC: clang-17
CXX: clang++-17
CLANG_DIR: '/usr/lib/llvm-17/lib/cmake/clang'
LLVM_DIR: '/usr/lib/llvm-17/lib/cmake/llvm'

steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Install LLVM 17
run: |
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main"
sudo apt update
sudo apt install llvm-17 llvm-17-dev llvm-17-tools clang-17 clang-tidy-17 clang-tools-17 libclang-17-dev -y
- name: Install static analyzers
if: matrix.os == 'ubuntu-22.04'
run: >-
sudo apt-get install clang-tidy-14 cppcheck -y -q
sudo apt install cppcheck -y -q
sudo update-alternatives --install
/usr/bin/clang-tidy clang-tidy
/usr/bin/clang-tidy-14 140
/usr/bin/clang-tidy-17 160
- name: Install Python
uses: actions/setup-python@v4
with: { python-version: "3.8" }
with: { python-version: "3.11" }

- name: Install dependencies
shell: bash
run: |
pip3 install conan
bash < .github/scripts/conan-profile.sh
conan install . -b missing
sudo apt install libssl-dev -y
bash < ../.github/scripts/conan-profile.sh
conan install . -s build_type=Release -b missing
- name: Setup MultiToolTask
if: matrix.os == 'windows-2022'
Expand All @@ -162,14 +251,18 @@ jobs:
run: cmake --install build --config Release --prefix prefix

- name: Test
working-directory: build
working-directory: exchange/build
run: ctest --output-on-failure --no-tests=error -C Release -j 2

docs:
# Deploy docs only when builds succeed
needs: [sanitize, test]

runs-on: ubuntu-22.04
defaults:
run:
working-directory: exchange


# To enable, first you have to create an orphaned gh-pages branch:
#
Expand All @@ -182,23 +275,24 @@ jobs:
# this comment and the last line in the conditional below.
# If you do not wish to use GitHub Pages for deploying documentation, then
# simply delete this job similarly to the coverage one.
if: github.ref == 'refs/heads/master'
if: github.ref == 'refs/heads/main'
&& github.event_name == 'push'
&& github.repository_owner == '<name>'
&& false
&& github.repository_owner == 'northwesternfintech'

steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'

- uses: actions/setup-python@v4
with: { python-version: "3.8" }
with: { python-version: "3.11" }

- name: Install m.css dependencies
run: pip3 install jinja2 Pygments

- name: Install Doxygen
run: sudo apt-get update -q
&& sudo apt-get install doxygen -q -y
run: sudo apt update -q
&& sudo apt install doxygen -q -y

- name: Build docs
run: cmake "-DPROJECT_SOURCE_DIR=$PWD" "-DPROJECT_BINARY_DIR=$PWD/build"
Expand Down
3 changes: 3 additions & 0 deletions exchange/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ target_link_libraries(NUTC24_exe PRIVATE NUTC24_lib)
# quill
target_link_libraries(NUTC24_exe PRIVATE quill::quill)

# fmt
target_link_libraries(NUTC24_exe PRIVATE fmt::fmt)

# rabbitmq
find_package(rabbitmq-c REQUIRED)
target_link_libraries(NUTC24_exe PRIVATE rabbitmq::rabbitmq-static)
Expand Down
7 changes: 7 additions & 0 deletions exchange/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,10 @@ tasks:
default:
cmds:
- task: run


lint:
cmds:
- cmake -D FIX=YES -P cmake/lint.cmake
- cmake -D FIX=YES -P cmake/spell.cmake

2 changes: 1 addition & 1 deletion exchange/src/matching/engine/engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include "client_manager/client_manager.hpp"
#include "logging.hpp"
#include "utils/messages.hpp"
#include "utils/logger/logger.hpp"
#include "utils/messages.hpp"

#include <chrono>

Expand Down
3 changes: 1 addition & 2 deletions exchange/src/matching/manager/engine_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ Manager::get_engine(const std::string& ticker)
void
Manager::add_initial_liquidity(const std::string& ticker, float quantity, float price)
{
MarketOrder to_add{"SIMULATED", messages::SIDE::SELL, ticker, quantity,
price};
MarketOrder to_add{"SIMULATED", messages::SIDE::SELL, ticker, quantity, price};
auto it = engines.find(ticker);
if (it != engines.end()) {
it->second.add_order_without_matching(to_add);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace nutc {
namespace rabbitmq {
//TODO: refactor to client_manager?
// TODO: refactor to client_manager?

class RabbitMQClientManager {
public:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include "client_manager/client_manager.hpp"
#include "matching/manager/engine_manager.hpp"
#include "logging.hpp"
#include "matching/manager/engine_manager.hpp"
#include "utils/messages.hpp"

#include <optional>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ RabbitMQOrderHandler::handleIncomingMarketOrder(

void
RabbitMQOrderHandler::addLiquidityToTicker(
manager::ClientManager& clients, engine_manager::Manager& engine_manager, const std::string& ticker, float quantity,
float price
manager::ClientManager& clients, engine_manager::Manager& engine_manager,
const std::string& ticker, float quantity, float price
)
{
engine_manager.add_initial_liquidity(ticker, quantity, price);
messages::ObUpdate update{ticker, messages::SIDE::SELL, price, quantity};
std::vector<messages::ObUpdate> vec{};
vec.push_back(update);
RabbitMQPublisher::broadcastObUpdates(clients, vec, "");
RabbitMQPublisher::broadcastObUpdates(clients, vec, "");
}

} // namespace rabbitmq
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "RabbitMQPublisher.hpp"
#include "networking/rabbitmq/connection_manager/RabbitMQConnectionManager.hpp"

#include "logging.hpp"
#include "networking/rabbitmq/connection_manager/RabbitMQConnectionManager.hpp"

namespace nutc {
namespace rabbitmq {
Expand All @@ -19,9 +19,7 @@ RabbitMQPublisher::publishMessage(
return true;
};

const auto& conn = RabbitMQConnectionManager::getInstance().get_connection_state();


const auto& conn = RabbitMQConnectionManager::getInstance().get_connection_state();

if (!checkReply(amqp_get_rpc_reply(conn), "Failed to declare queue.")) {
return false;
Expand Down
Loading

0 comments on commit 8ef7475

Please sign in to comment.