Skip to content

Commit

Permalink
Add (#379): added new c++ compilert tests
Browse files Browse the repository at this point in the history
Added tests to the CI-pipeline to test different
C++ compiler and link the build-results within
the readme file.
  • Loading branch information
kitsudaiki committed Jul 24, 2024
1 parent 41b85a9 commit b851986
Show file tree
Hide file tree
Showing 10 changed files with 216 additions and 5 deletions.
26 changes: 26 additions & 0 deletions .github/actions/badge/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Regular badging sequence
description: Publishes a badge based on the job status
inputs:
category:
description: The subfolder where to group the badges
required: true
badges:
description: A json object of label => status for all badges
required: true
github_token:
description: The token to use to publish the changes
required: true
runs:
using: composite
steps:
- run: |
node ./.github/actions/badge/write-json-object.js ${{ inputs.category }} '${{ inputs.badges }}'
shell: bash
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ inputs.github_token }}
publish_branch: badges
publish_dir: ./badges
keep_files: true
user_name: "github-actions[bot]"
user_email: "github-actions[bot]@users.noreply.github.com"
18 changes: 18 additions & 0 deletions .github/actions/badge/write-json-object.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const fs = require('fs');
const category = process.argv[2];
const status = JSON.parse(process.argv[3]);

if (!fs.existsSync("./badges")) fs.mkdirSync("./badges");
if (!fs.existsSync("./badges/" + category)) fs.mkdirSync("./badges/" + category);
for (let e in status) {
const path = "./badges/" + category + "/" + e;
if (!fs.existsSync(path)) fs.mkdirSync(path);
const ok = status[e] == "success";
fs.writeFileSync(path + "/shields.json", JSON.stringify({
"schemaVersion": 1,
"label": e,
"message": ok ? "Passing" : "Failing",
"color": ok ? "brightgreen" : "red"
}));
}

125 changes: 124 additions & 1 deletion .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,129 @@ jobs:
retention-days: 1


compiler_test:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
needs: [ cpp-check, clang-format-check, ansible-lint, flake8-check ]
strategy:
fail-fast: false
matrix:
compiler:
- { tag: "ubuntu-2204_clang-13", name: "Ubuntu 22.04 Clang 13", cxx: "/usr/bin/clang++-11", cc: "/usr/bin/clang-11", runs-on: "ubuntu-22.04" }
- { tag: "ubuntu-2204_clang-14", name: "Ubuntu 22.04 Clang 14", cxx: "/usr/bin/clang++-14", cc: "/usr/bin/clang-14", runs-on: "ubuntu-22.04" }
- { tag: "ubuntu-2204_clang-15", name: "Ubuntu 22.04 Clang 15", cxx: "/usr/bin/clang++-15", cc: "/usr/bin/clang-15", runs-on: "ubuntu-22.04" }
- { tag: "ubuntu-2404_clang-15", name: "Ubuntu 24.04 Clang 15", cxx: "/usr/bin/clang++-15", cc: "/usr/bin/clang-15", runs-on: "ubuntu-24.04" }
- { tag: "ubuntu-2404_clang-16", name: "Ubuntu 24.04 Clang 16", cxx: "/usr/bin/clang++-16", cc: "/usr/bin/clang-16", runs-on: "ubuntu-24.04" }
- { tag: "ubuntu-2404_clang-17", name: "Ubuntu 24.04 Clang 17", cxx: "/usr/bin/clang++-17", cc: "/usr/bin/clang-17", runs-on: "ubuntu-24.04" }
- { tag: "ubuntu-2404_clang-18", name: "Ubuntu 24.04 Clang 18", cxx: "/usr/bin/clang++-18", cc: "/usr/bin/clang-18", runs-on: "ubuntu-24.04" }
- { tag: "ubuntu-2204_gcc-10", name: "Ubuntu 22.04 G++ 10", cxx: "/usr/bin/g++-10", cc: "/usr/bin/gcc-10", runs-on: "ubuntu-22.04" }
- { tag: "ubuntu-2204_gcc-11", name: "Ubuntu 22.04 G++ 11", cxx: "/usr/bin/g++-11", cc: "/usr/bin/gcc-11", runs-on: "ubuntu-22.04" }
- { tag: "ubuntu-2204_gcc-12", name: "Ubuntu 22.04 G++ 12", cxx: "/usr/bin/g++-12", cc: "/usr/bin/gcc-12", runs-on: "ubuntu-22.04" }
- { tag: "ubuntu-2404_gcc-12", name: "Ubuntu 24.04 G++ 12", cxx: "/usr/bin/g++-12", cc: "/usr/bin/gcc-12", runs-on: "ubuntu-24.04" }
- { tag: "ubuntu-2404_gcc-13", name: "Ubuntu 24.04 G++ 13", cxx: "/usr/bin/g++-13", cc: "/usr/bin/gcc-13", runs-on: "ubuntu-24.04" }
- { tag: "ubuntu-2404_gcc-14", name: "Ubuntu 24.04 G++ 14", cxx: "/usr/bin/g++-14", cc: "/usr/bin/gcc-14", runs-on: "ubuntu-24.04" }
runs-on: ${{ matrix.compiler.runs-on }}
name: "${{ matrix.compiler.name }}"
env:
CXX: ${{ matrix.compiler.cxx }}
CC: ${{ matrix.compiler.cc }}
outputs:
ubuntu-2204_clang-13: ${{ steps.status.outputs.ubuntu-2204_clang-13 }}
ubuntu-2204_clang-14: ${{ steps.status.outputs.ubuntu-2204_clang-14 }}
ubuntu-2204_clang-15: ${{ steps.status.outputs.ubuntu-2204_clang-15 }}
ubuntu-2404_clang-15: ${{ steps.status.outputs.ubuntu-2404_clang-15 }}
ubuntu-2404_clang-16: ${{ steps.status.outputs.ubuntu-2404_clang-16 }}
ubuntu-2404_clang-17: ${{ steps.status.outputs.ubuntu-2404_clang-17 }}
ubuntu-2404_clang-18: ${{ steps.status.outputs.ubuntu-2404_clang-18 }}
ubuntu-2204_gcc-10: ${{ steps.status.outputs.ubuntu-2204_gcc-10 }}
ubuntu-2204_gcc-11: ${{ steps.status.outputs.ubuntu-2204_gcc-11 }}
ubuntu-2204_gcc-12: ${{ steps.status.outputs.ubuntu-2204_gcc-12 }}
ubuntu-2404_gcc-12: ${{ steps.status.outputs.ubuntu-2404_gcc-12 }}
ubuntu-2404_gcc-13: ${{ steps.status.outputs.ubuntu-2404_gcc-13 }}
ubuntu-2404_gcc-14: ${{ steps.status.outputs.ubuntu-2404_gcc-14 }}
steps:
-
name: Checkout repository
run: |
# use manually clone, because with the "actions/checkout@v3" action the name of the
# branch can not be read by the git commands, which is necessary for the build-script
git clone https://github.com/kitsudaiki/${GITHUB_REPOSITORY#*/}.git
cd ${GITHUB_REPOSITORY#*/}
git checkout ${GITHUB_REF#refs/heads/}
git submodule init
git submodule update --recursive
-
name: Install basic packages
run: |
sudo apt-get update && \
sudo apt-get install -y make \
cmake \
bison \
flex \
git \
ssh \
libssl-dev \
libcrypto++-dev \
libboost-dev \
nlohmann-json3-dev \
uuid-dev \
libsqlite3-dev \
protobuf-compiler
-
name: Install clang on Ubuntu 22.04
if: (matrix.compiler.tag == 'ubuntu-2204_clang-14') || (matrix.compiler.tag == 'ubuntu-2204_clang-15')
run: |
sudo apt-get install -y clang-15 clang-14 clang-13
-
name: Install clang on Ubuntu 24.04
if: (matrix.compiler.tag == 'ubuntu-2404_clang-15') || (matrix.compiler.tag == 'ubuntu-2404_clang-16') || (matrix.compiler.tag == 'ubuntu-2404_clang-17') || (matrix.compiler.tag == 'ubuntu-2404_clang-18')
run: |
sudo apt-get install -y clang-15 clang-16 clang-17 clang-18
-
name: Install gcc on Ubuntu 22.04
if: (matrix.compiler.tag == 'ubuntu-2204_gcc-10') || (matrix.compiler.tag == 'ubuntu-2204_gcc-11') || (matrix.compiler.tag == 'ubuntu-2204_gcc-12')
run: |
sudo apt-get install -y gcc-10 g++-10 gcc-11 g++-11 gcc-12 g++-12
-
name: Install gcc on Ubuntu 24.04
if: (matrix.compiler.tag == 'ubuntu-2404_gcc-12') || (matrix.compiler.tag == 'ubuntu-2404_gcc-13') || (matrix.compiler.tag == 'ubuntu-2404_gcc-14')
run: |
sudo apt-get install -y gcc-12 g++-12 gcc-13 g++-13 gcc-14 g++-14
-
name: Compile code
run: |
cd ${GITHUB_REPOSITORY#*/} && \
cmake -DCMAKE_BUILD_TYPE=Release -Drun_tests=ON -DCMAKE_CXX_COMPILER=${{ matrix.compiler.cxx }} -DCMAKE_C_COMPILER=${{ matrix.compiler.cc }} . && \
make -j4
-
name: Run basic test
run: |
cd ${GITHUB_REPOSITORY#*/}
./src/Hanami/Hanami_unittests
- name: Update Result
id: status
if: ${{ always() }}
run: echo "${{ matrix.compiler.tag }}=${{ job.status }}" >> $GITHUB_OUTPUT



compiler-badge-upload:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' && always() }}
needs: [ compiler_test ]
runs-on: ubuntu-22.04
name: Publish badges
steps:
-
name: Checkout repository
uses: actions/checkout@v3
-
name: Publish Badges
uses: ./.github/actions/badge
with:
category: compiler
badges: ${{ toJson(needs.compiler_test.outputs) }}
github_token: ${{ secrets.BADGES_PUSH_TOKEN }}



unit_tests:
name: "Unit-Tests"
Expand Down Expand Up @@ -1127,4 +1250,4 @@ jobs:
-
name: Upload pip-package
run: |
scp /tmp/hanami_python_build_result/hanami_sdk-$PYTHON_PACKAGE_VERSION-py2.py3-none-any.whl ${{ secrets.SHARE_SSH_ACCESS }}:~/hanami_file_share/$BRANCH_NAME/python-package/
scp /tmp/hanami_python_build_result/hanami_sdk-$PYTHON_PACKAGE_VERSION-py2.py3-none-any.whl ${{ secrets.SHARE_SSH_ACCESS }}:~/hanami_file_share/$BRANCH_NAME/python-package/
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Hanami

![Github workfloat status](https://img.shields.io/github/actions/workflow/status/kitsudaiki/Hanami/build_test.yml?branch=develop&style=flat-square&label=build%20and%20test)
![Github workflow status](https://img.shields.io/github/actions/workflow/status/kitsudaiki/Hanami/build_test.yml?branch=develop&style=flat-square&label=build%20and%20test)
![GitHub release](https://img.shields.io/github/v/release/kitsudaiki/Hanami?include_prereleases&label=version&style=flat-square)
![GitHub](https://img.shields.io/github/license/kitsudaiki/Hanami-AI?style=flat-square)
![Platform](https://img.shields.io/badge/Platform-Linux--x64|arm64-lightgrey?style=flat-square)
Expand All @@ -15,6 +15,43 @@

Hanami contains in its core a custom concept for neural networks, which are very flexible in their behavior and structure, which is packed in an as-a-Service backend. The backend is completely written from scratch in C++.

## Compiler

| C++ Compiler |
| --- |
| [![ubuntu-2204_clang-13][img_ubuntu-2204_clang-13]][Workflow] |
| [![ubuntu-2204_clang-14][img_ubuntu-2204_clang-14]][Workflow] |
| [![ubuntu-2204_clang-15][img_ubuntu-2204_clang-15]][Workflow] |
| [![ubuntu-2404_clang-15][img_ubuntu-2404_clang-15]][Workflow] |
| [![ubuntu-2404_clang-16][img_ubuntu-2404_clang-16]][Workflow] |
| [![ubuntu-2404_clang-17][img_ubuntu-2404_clang-17]][Workflow] |
| [![ubuntu-2404_clang-18][img_ubuntu-2404_clang-18]][Workflow] |
| [![ubuntu-2204_gcc-10][img_ubuntu-2204_gcc-10]][Workflow] |
| [![ubuntu-2204_gcc-11][img_ubuntu-2204_gcc-11]][Workflow] |
| [![ubuntu-2204_gcc-12][img_ubuntu-2204_gcc-12]][Workflow] |
| [![ubuntu-2404_gcc-12][img_ubuntu-2404_gcc-12]][Workflow] |
| [![ubuntu-2404_gcc-13][img_ubuntu-2404_gcc-13]][Workflow] |
| [![ubuntu-2404_gcc-14][img_ubuntu-2404_gcc-14]][Workflow] |


[img_ubuntu-2204_clang-13]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/kitsudaiki/Hanami/badges/compiler/ubuntu-2204_clang-13/shields.json&style=flat-square
[img_ubuntu-2204_clang-14]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/kitsudaiki/Hanami/badges/compiler/ubuntu-2204_clang-14/shields.json&style=flat-square
[img_ubuntu-2204_clang-15]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/kitsudaiki/Hanami/badges/compiler/ubuntu-2204_clang-15/shields.json&style=flat-square
[img_ubuntu-2404_clang-15]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/kitsudaiki/Hanami/badges/compiler/ubuntu-2404_clang-15/shields.json&style=flat-square
[img_ubuntu-2404_clang-16]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/kitsudaiki/Hanami/badges/compiler/ubuntu-2404_clang-16/shields.json&style=flat-square
[img_ubuntu-2404_clang-17]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/kitsudaiki/Hanami/badges/compiler/ubuntu-2404_clang-17/shields.json&style=flat-square
[img_ubuntu-2404_clang-18]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/kitsudaiki/Hanami/badges/compiler/ubuntu-2404_clang-18/shields.json&style=flat-square
[img_ubuntu-2204_gcc-10]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/kitsudaiki/Hanami/badges/compiler/ubuntu-2204_gcc-10/shields.json&style=flat-square
[img_ubuntu-2204_gcc-11]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/kitsudaiki/Hanami/badges/compiler/ubuntu-2204_gcc-11/shields.json&style=flat-square
[img_ubuntu-2204_gcc-12]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/kitsudaiki/Hanami/badges/compiler/ubuntu-2204_gcc-12/shields.json&style=flat-square
[img_ubuntu-2404_gcc-12]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/kitsudaiki/Hanami/badges/compiler/ubuntu-2404_gcc-12/shields.json&style=flat-square
[img_ubuntu-2404_gcc-13]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/kitsudaiki/Hanami/badges/compiler/ubuntu-2404_gcc-13/shields.json&style=flat-square
[img_ubuntu-2404_gcc-14]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/kitsudaiki/Hanami/badges/compiler/ubuntu-2404_gcc-14/shields.json&style=flat-square

[Workflow]: https://github.com/kitsudaiki/Hanami/actions/workflows/build_test.yml



## Initial goal

I started this project without a specific use-case in mind. The only goal was to create a neural network, which is much more dynamic, compared to other classical networks, in regard of learning behavior and structure. It should behave more like the human brain. So it was basically a private research project.
Expand Down
2 changes: 1 addition & 1 deletion src/Hanami/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Setting the compiler
set(CMAKE_CXX_COMPILER "clang++-15")
# set(CMAKE_CXX_COMPILER "clang++-15")

# Adding source files
set(SOURCES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ HttpProcessing::processRequest(http::request<http::string_body>& httpRequest,

// collect and prepare relevant data
const http::verb messageType = httpRequest.method();
std::string path = httpRequest.target().to_string();
std::string path = std::string(httpRequest.target());
std::string payload = "{}";

// Request path must be absolute and not contain "..".
Expand Down Expand Up @@ -80,7 +80,7 @@ HttpProcessing::processRequest(http::request<http::string_body>& httpRequest,
// get token from request-header
std::string token = "";
if (httpRequest.count("X-Auth-Token") > 0) {
token = httpRequest.at("X-Auth-Token").to_string();
token = std::string(httpRequest.at("X-Auth-Token"));
}

// handle control-messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#ifndef STRING_FUNCTIONS_H
#define STRING_FUNCTIONS_H

#include <stdint.h>

#include <algorithm>
#include <iostream>
#include <sstream>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#ifndef TABLE_ITEM_H
#define TABLE_ITEM_H

#include <stdint.h>

#include <iostream>
#include <nlohmann/json.hpp>
#include <vector>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#ifndef COMPARE_TEST_HELPER_H
#define COMPARE_TEST_HELPER_H

#include <stdint.h>

#include <iostream>
#include <string>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <condition_variable>
#include <deque>
#include <mutex>
#include <string>
#include <thread>
#include <vector>

Expand Down

0 comments on commit b851986

Please sign in to comment.