Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions .github/workflows/project-creation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Copyright (c) 2023 Robert Bosch GmbH
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://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.
#
# SPDX-License-Identifier: Apache-2.0

name: Project creation

concurrency:
group: ${{ github.ref }}-project-creation
cancel-in-progress: true

on:
workflow_dispatch:
push:
# Run only on branches/commits and not tags
branches:
- main
pull_request:
branches:
- main

jobs:
check-project-creation:
name: Check project creation
runs-on: ubuntu-22.04
strategy:
matrix:
example: ["", "-e seat-adjuster"]
fail-fast: false

steps:
- uses: actions/setup-node@v3
with:
node-version: latest

- name: Checkout CLI
uses: actions/checkout@v4
with:
repository: eclipse-velocitas/cli
path: cli
ref: v0.6.1

- name: Checkout SDK repo
uses: actions/checkout@v4
with:
path: sdk

- name: Install CLI
shell: bash
run: |
cd cli
npm i && npm run build && npx oclif manifest && npm i -g .

- name: Create project
shell: bash
run: |
git config --global user.name "Git User"
git config --global user.email "gituser@email.com"

# overwrite SDK path in order to use scripts from this branch (rather than sdk/main)
export VELOCITAS_SDK_PATH_OVERRIDE=$(pwd)/sdk

mkdir app
cd app

# show available commands and version of CLI
velocitas

# copy "full" package-index.json from CLI repo
cp ../cli/testbench/test-create/vehicle-app-template/package-index.json ./package-index.json

velocitas create -n MyApp -l cpp ${{ matrix.example }}

- name: Install dependencies
shell: bash
run: |
pip install -r ./sdk/.project-creation/test/requirements.txt

- name: Run verification on generated project
shell: bash
run: |
export VELOCITAS_SDK_ROOT=./sdk
export VELOCITAS_APP_ROOT=./app

# debug print contents
ls -al $VELOCITAS_APP_ROOT

pytest --ignore-glob=**/.devcontainer/* --ignore-glob=**/.skeleton/* ./sdk/.project-creation

- name: Check if devContainer starts up properly and app is usable
uses: devcontainers/ci@v0.3
with:
subFolder: ./app
runCmd: |
git init && \
pre-commit run --all-files && \
pip3 install -r .devcontainer/tests/automated_tests/requirements.txt && \
pytest -sx .devcontainer/tests/automated_tests

- name: Upload logs
uses: actions/upload-artifact@v3
if: always()
with:
name: logs-${{ matrix.example }}
path: ./app/logs
retention-days: 1
19 changes: 19 additions & 0 deletions .project-creation/.skeleton/AppManifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"manifestVersion": "v3",
"name": "skeleton",
"interfaces": [
{
"type": "vehicle-signal-interface",
"config": {
"src": "https://github.com/COVESA/vehicle_signal_specification/releases/download/v3.0/vss_rel_3.0.json",
"datapoints": {
"required": []
}
}
},
{
"type": "pubsub",
"config": {}
}
]
}
26 changes: 26 additions & 0 deletions .project-creation/.skeleton/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (c) 2023 Contributors to the Eclipse Foundation
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://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.
#
# SPDX-License-Identifier: Apache-2.0

include_directories(
${CMAKE_BINARY_DIR}/gens
${CONAN_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/app/vehicle_model/include
)

link_directories(
${CONAN_LIB_DIRS}
)

add_subdirectory(src)
add_subdirectory(tests)
50 changes: 50 additions & 0 deletions .project-creation/.skeleton/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright (c) 2023 Contributors to the Eclipse Foundation
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://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.
#
# SPDX-License-Identifier: Apache-2.0

# syntax = docker/dockerfile:1.2

FROM ghcr.io/eclipse-velocitas/vehicle-app-cpp-sdk/app-builder:v0.4 as builder

RUN apk update && \
apk add jq && \
ln -s /usr/bin/python3 /usr/bin/python

COPY . /workspace

RUN --mount=type=cache,target=/root/.conan

# FIXME: For build tooling we only need "devenv-devcontainer-setup", we should be able to
# filter this without manual jq intervention...
RUN mv /workspace/.velocitas.json /workspace/.velocitas_org.json && \
cat /workspace/.velocitas_org.json | jq 'del(.packages[] | select(.name != "devenv-devcontainer-setup"))' > /workspace/.velocitas.json

WORKDIR /workspace

RUN velocitas init -f -v && \
./install_dependencies.sh -r && \
./build.sh -r -t app --static

RUN strip /workspace/build/bin/app

# Runner stage, to copy the executable
FROM scratch

COPY --from=builder /workspace/build/bin/app /dist/app

WORKDIR /tmp
WORKDIR /dist

ENV PATH="/dist:$PATH"

CMD ["/dist/app"]
3 changes: 3 additions & 0 deletions .project-creation/.skeleton/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# AppName Readme

A simple skeleton app for getting you up and running with Velocitas app development.
24 changes: 24 additions & 0 deletions .project-creation/.skeleton/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2023 Contributors to the Eclipse Foundation
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://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.
#
# SPDX-License-Identifier: Apache-2.0

set(TARGET_NAME "app")

add_executable(${TARGET_NAME}
SkeletonApp.cpp
Launcher.cpp
)

target_link_libraries(${TARGET_NAME}
${CONAN_LIBS}
)
39 changes: 39 additions & 0 deletions .project-creation/.skeleton/src/Launcher.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://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.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "SkeletonApp.h"
#include "sdk/Logger.h"

#include <csignal>

void signal_handler(int sig) {
velocitas::logger().error("App terminated due to: Signal {}", sig);
exit(-1);
}

int main(int argc, char** argv) {
signal(SIGINT, signal_handler);

example::SkeletonApp appName;
try {
appName.run();
} catch (const std::exception& e) {
velocitas::logger().error("App terminated due to: {}", e.what());
} catch (...) {
velocitas::logger().error("App terminated due to an unknown exeption.");
}
return 0;
}
38 changes: 38 additions & 0 deletions .project-creation/.skeleton/src/SkeletonApp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://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.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "SkeletonApp.h"
#include "sdk/IPubSubClient.h"
#include "sdk/Logger.h"
#include "sdk/vdb/IVehicleDataBrokerClient.h"

#include <utility>

namespace skeleton {

SkeletonApp::SkeletonApp()
: VehicleApp(velocitas::IVehicleDataBrokerClient::createInstance("vehicledatabroker"),
velocitas::IPubSubClient::createInstance("SkeletonApp")) {}

void SkeletonApp::onStart() {
velocitas::logger().info("App Started!");
}

void SkeletonApp::onError(const velocitas::Status& status) {
velocitas::logger().error("Error occurred during async invocation: {}", status.errorMessage());
}

} // namespace example
55 changes: 55 additions & 0 deletions .project-creation/.skeleton/src/SkeletonApp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://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.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef VEHICLE_APP_SDK_SKELETON_H
#define VEHICLE_APP_SDK_SKELETON_H

#include "sdk/Status.h"
#include "sdk/VehicleApp.h"
#include "vehicle/Vehicle.hpp"

#include <memory>
#include <string>

namespace skeleton {

/**
* @brief Skeleton vehicle app.
*/
class SkeletonApp : public velocitas::VehicleApp {
public:
SkeletonApp();

/**
* @brief Run when the vehicle app starts
*
*/
void onStart() override;

/**
* @brief Handle errors which occurred during async invocation.
*
* @param status The status which contains the error.
*/
void onError(const velocitas::Status& status);

private:
vehicle::Vehicle Vehicle;
};

} // namespace skeleton

#endif // VEHICLE_APP_SDK_SKELETON_H
Loading