Skip to content

Commit

Permalink
feat: add c++ api (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddiakiteaneo authored Jun 30, 2023
2 parents 0e25bc9 + c09c978 commit cdd4d0e
Show file tree
Hide file tree
Showing 43 changed files with 3,781 additions and 1 deletion.
59 changes: 59 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Ignore everything


# Allow files and directories
# Example :
# !**/ArmoniK.Api.Common

# Ignore unnecessary files inside allowed directories
# This should go after the allowed directories
**/*~
**/*.log
**/*.obj
**/obj
**/bin
**/*.o
**/*.a
**/*.so
**/*.lib
**/build*
**/.build*
**/gen
**/install*
**/.git
**/.github
**/.vs
**/.vscode
**/Api
**/.docs
**/out
**/grpc
**/win64
**/tools/tools
**/.classpath
**/.dockerignore
**/Dockerfile
**/.env
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.idea
**/*.*proj.user
**/*.dbmdl
**/*.dump
**/*.jfm
**/azds.yaml
**/charts
**/docker-compose*
docker-compose
**/node_modules
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
**/publish
terraform
tmp


121 changes: 121 additions & 0 deletions .docs/content/1.guide/5.cpp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Compilation steps for cpp API

## Compilation of ArmoniK.Api.cpp Client and Server on Linux using Docker

In order to compile the client and server on Linux, we use a Docker image to set up the necessary environment and dependencies. This ensures a consistent and clean environment for compilation.

### Prerequisites Linux

1. Install Docker on your Linux system. Follow the instructions on the [official Docker documentation](https://docs.docker.com/engine/install/).
2. Clone the repository containing the source code and the necessary scripts.

### Compilation Steps for Linux

1. Open a terminal in the root directory of the cloned repository.
2. Run the `compile.sh` script:
This script compile the cpp project on linux systems.

```bash [bash]
cd packages/cpp/tools
./compile.sh
```

The `compile.sh` script does the following:

- Sets the image tag for the Docker image.
- Determines the absolute paths of the necessary directories (working, proto, build, and install directories).
- Checks if the Docker image exists. If not, it builds the Docker image using the Dockerfile.ubuntu file.
- Compiles the project source using the Docker image.
Once the compilation is complete, the compiled binaries will be located in the install directory.

Now you have successfully compiled the client and server on Linux using Docker.

### Compiling the Client and Server on Windows

This guide explains how to compile the Armonik API client and server on Windows

### Prerequisites Windows

Before getting started, make sure you have the following tools and packages installed on your machine:

- PowerShell
- Visual Studio 2022
- Git

Before getting started, you will need PowerShell and be inform that the script will install localy in the folder tools/win64 all prerequisites excepting Visual Studio 2022 and CMake plugins :

- Chocolatey package manager
- Grpc 1.54.0 built from source
- CMake
- NASM

### Compilation Steps for windows

Follow these steps to compile the Armonik API client and server:

From a PowerShell, go to the folder package/cpp/tools

```powershell [PowerShell]
cd packages\cpp\tools
```

This will install the required dependencies and compile the Armonik API client and server.

Wait for the script to complete. This may take some time, depending on the speed of your machine and the size of the project.

Once the script has completed, you should see the compiled output in the install directory. From the root folder of repository ArmoniK.API

```powershell [PowerShell]
cd packages\cpp\tools\win64
```

### Troubleshooting

If you encounter any issues during the compilation process, try the following troubleshooting steps:

- Make sure you have all the prerequisites installed correctly.
- Check that you are running PowerShell as an administrator.

### Conclusion

Compiling the Armonik API client and server on Windows can be a complex process.

By following the steps outlined in this guide, you should be able to compile the project successfully and start using the Armonik API on Windows.

## Compilation of the Worker ArmoniK.Api.cpp Image for Deployment in Armonik Infrastructure

The worker image is a Docker image that is built specifically to be deployed in the Armonik infrastructure. This image contains the necessary dependencies and configurations for the worker to function correctly.

### Prerequisites

1. Install Docker on your Linux system. Follow the instructions on the [official Docker documentation](https://docs.docker.com/engine/install/).
2. Clone the repository containing the source code and the necessary scripts.

### Compilation Steps

1. Open a terminal in the root directory of the cloned repository.
2. Run the `build-worker.sh` script:

```bash
cd packages/cpp/tools
./build-worker.sh
```

The build-worker.sh script does the following:

- Sets the image tag for the Docker image.
- Determines the absolute paths of the necessary directories (script, working, and root directories).
- Changes to the root directory where the Protos are located.
- Builds the worker Docker image using the Dockerfile.worker file.

Now you should have the final image

3. Once the worker image has been built, you can use the following command to list all the Docker images available on your system:

```bash
docker images | grep armonik-api-cpp
```

The worker image should be listed with the specified image tag (e.g., armonik-api-cpp:v0.1).

Now you have successfully compiled the worker image for deployment in the Armonik infrastructure.
61 changes: 60 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,50 @@ jobs:
exit 1
fi
format-cpp:
name: Format C++
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
fetch-depth: 0

- name: Run clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format
- name: Check Diff
id: check-diff
run: |
cd packages/cpp
git ls-files *.{c,h,hpp,cpp,cc} | xargs clang-format -style=file:.clang-format -i
DIFF="$(git diff --name-only)"
if [ -z "$DIFF" ]; then
echo "OK: Format is clean"
else
echo "Error: Format was not clean"
echo "List of files:"
echo "$DIFF"
git diff
exit 1
fi
- name: Generate patch
if: ${{ failure() && steps.check-diff.conclusion == 'failure' }}
run: |
git diff > patch-cpp.diff
- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.check-diff.conclusion == 'failure' }}
with:
name: patch-cpp
path: ./patch-cpp.diff

format-protobuf:
name: Format Protobuf
runs-on: ubuntu-latest
Expand Down Expand Up @@ -189,4 +233,19 @@ jobs:
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3
with:
name: code-coverage-report-xml
path: packages/python/coverage.xml
path: packages/python/coverage.xml

build-cpp-packages:
name: Build C++ Packages
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}

- name: Build the package
run: |
cd packages/cpp/tools/
./compile.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ dist

!packages/common
!packages/csharp
!packages/cpp
!packages/python
!packages/angular
!packages/web
Expand Down
Loading

0 comments on commit cdd4d0e

Please sign in to comment.