Skip to content

Commit

Permalink
Updates to build and CI to support non-bundled vsomeip shared library
Browse files Browse the repository at this point in the history
* Update to up-transport-vsomeip in up-transport-vsomeip-rust main
* Plumb through the ability to use bundled vsomeip or bring your own library
* Test both bundled and unbundled vsomeip builds
* Remove build.yaml in favor of clear configurations for bundled and unbundled
  • Loading branch information
PLeVasseur authored and matthewd0123 committed Aug 6, 2024
1 parent 919c2a0 commit bd19272
Show file tree
Hide file tree
Showing 5 changed files with 312 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************/

name: Lint and Test
name: Lint and Test - Bundled

env:
VSOMEIP_INSTALL_PATH: vsomeip-install
Expand All @@ -29,8 +29,8 @@ on:
workflow_dispatch:

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

jobs:

Expand Down Expand Up @@ -167,3 +167,4 @@ jobs:
- name: Create Documentation for up-linux-streamer
working-directory: ${{github.workspace}}
run: RUSTDOCFLAGS=-Dwarnings cargo doc -p up-linux-streamer --no-deps

296 changes: 296 additions & 0 deletions .github/workflows/unbundled-lint-and-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
# ********************************************************************************
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# 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
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************/

name: Lint and Test - Unbundled

env:
VSOMEIP_RELEASE_URL: https://github.com/COVESA/vsomeip/archive/refs/tags/
VSOMEIP_RELEASE_TAG: 3.4.10.tar.gz
VSOMEIP_SOURCE_PATH: vsomeip-src
VSOMEIP_INSTALL_PATH: vsomeip-install

GENERIC_CPP_STDLIB_PATH: /usr/include/c++/11
ARCH_SPECIFIC_CPP_STDLIB_PATH: /usr/include/x86_64-linux-gnu/c++/11

on:
push:
branches: [ main ]
pull_request:
paths:
- "src/**"
- "Cargo.*"
workflow_call:
workflow_dispatch:

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

jobs:
obtain_and_build_vsomeip:
runs-on: ubuntu-latest
outputs:
cache_key: ${{ steps.generate_cache_key.outputs.CACHE_KEY }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set environment variables
run: |
echo "VSOMEIP_SOURCE_TARBALL=${{ env.VSOMEIP_RELEASE_URL }}${{ env.VSOMEIP_RELEASE_TAG }}" >> $GITHUB_ENV
echo "VSOMEIP_SOURCE_PATH=${{ github.workspace }}/${{ env.VSOMEIP_SOURCE_PATH }}" >> $GITHUB_ENV
echo "VSOMEIP_INSTALL_PATH=${{ github.workspace }}/${{ env.VSOMEIP_INSTALL_PATH }}" >> $GITHUB_ENV
echo "VSOMEIP_SOURCE_PATH_WITH_WILDCARD=${{ github.workspace }}/${{ env.VSOMEIP_SOURCE_PATH }}/*" >> $GITHUB_ENV
- name: Print environment variables for debugging
run: |
echo "VSOMEIP_SOURCE_TARBALL: ${{ env.VSOMEIP_SOURCE_TARBALL }}"
echo "VSOMEIP_SOURCE_PATH: ${{ env.VSOMEIP_SOURCE_PATH }}"
echo "VSOMEIP_INSTALL_PATH: ${{ env.VSOMEIP_INSTALL_PATH }}"
echo "VSOMEIP_SOURCE_PATH_WITH_WILDCARD: ${{ env.VSOMEIP_SOURCE_PATH_WITH_WILDCARD }}"
- name: Download tarball
run: |
wget -O vsomeip-source.tar.gz $VSOMEIP_SOURCE_TARBALL
ls -l
- name: Create destination directory
run: |
mkdir -p $VSOMEIP_SOURCE_PATH
ls -l
- name: Decompress tarball
run: |
tar --strip-components=1 -xzf vsomeip-source.tar.gz -C $VSOMEIP_SOURCE_PATH
ls -l
- name: Confirm decompressed
run: |
echo "Current working directory: $(pwd)"
echo "Contents of repository root:"
ls -l
echo "Contents of decompressed folder ($VSOMEIP_SOURCE_PATH):"
ls -l $VSOMEIP_SOURCE_PATH
- name: Generate cache key
run: echo "CACHE_KEY=${{ runner.os }}-vsomeip-${{ hashFiles(env.VSOMEIP_SOURCE_PATH_WITH_WILDCARD) }}" >> $GITHUB_ENV

- name: Set cache key output
id: generate_cache_key
run: echo "CACHE_KEY=${{ env.CACHE_KEY }}" >> $GITHUB_OUTPUT

- name: Cache vsomeip build
id: cache-vsomeip
uses: actions/cache@v3
with:
path: ${{ env.VSOMEIP_INSTALL_PATH }}
key: ${{ runner.os }}-vsomeip-${{ hashFiles(env.VSOMEIP_SOURCE_PATH_WITH_WILDCARD) }}
restore-keys: |
${{ runner.os }}-vsomeip-
- name: Install dependencies
if: steps.cache-vsomeip.outputs.cache-hit != 'true'
run: sudo apt-get install -y build-essential cmake libboost-all-dev

- name: Build vsomeip
if: steps.cache-vsomeip.outputs.cache-hit != 'true'
run: |
cd $VSOMEIP_SOURCE_PATH
cmake -Bbuild -DCMAKE_INSTALL_PREFIX=$VSOMEIP_INSTALL_PATH -DENABLE_SIGNAL_HANDLING=1 .
cmake --build build --target install
- name: Save vsomeip build to cache
if: steps.cache-vsomeip.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
path: ${{ env.VSOMEIP_INSTALL_PATH }}
key: ${{ runner.os }}-vsomeip-${{ hashFiles(env.VSOMEIP_SOURCE_PATH_WITH_WILDCARD) }}

lint:
name: Lint
needs: obtain_and_build_vsomeip
runs-on: ubuntu-latest
env:
CACHE_KEY: ${{ needs.obtain_and_build_vsomeip.outputs.cache_key }}

steps:
- uses: actions/checkout@v4

- name: Install C++ dependencies
run: sudo apt-get install -y build-essential cmake libboost-all-dev

- name: Set environment variables
run: |
echo "VSOMEIP_INSTALL_PATH=${{ github.workspace }}/${{ env.VSOMEIP_INSTALL_PATH }}" >> $GITHUB_ENV
- name: Print environment variables for debugging
run: |
echo "VSOMEIP_INSTALL_PATH: ${{ env.VSOMEIP_INSTALL_PATH }}"
- name: Ensure vsomeip install path exists
run: |
mkdir -p ${{ env.VSOMEIP_INSTALL_PATH }}
ls -l
- name: Print cache_key
run: |
echo "cache_key: ${{ env.CACHE_KEY }}"
- name: Restore vsomeip build cache
uses: actions/cache@v3
with:
path: ${{ env.VSOMEIP_INSTALL_PATH }}
key: ${{ env.CACHE_KEY }}
restore-keys: |
${{ runner.os }}-vsomeip-
- name: Install stable toolchain
run: |
rustup show
rustup component add rustfmt clippy
- name: Build the project
working-directory: ${{github.workspace}}
run: cargo build --no-default-features
- name: cargo fmt
working-directory: ${{github.workspace}}
run: cargo fmt -- --check
- name: cargo clippy
working-directory: ${{github.workspace}}
run: cargo clippy --no-default-features --all-targets -- -W warnings -D warnings

test:
name: Test
needs: obtain_and_build_vsomeip
runs-on: ubuntu-latest
env:
CACHE_KEY: ${{ needs.obtain_and_build_vsomeip.outputs.cache_key }}

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable

- name: Install C++ dependencies
if: steps.cache-vsomeip.outputs.cache-hit != 'true'
run: sudo apt-get install -y build-essential cmake libboost-all-dev

- name: Set environment variables
run: |
echo "VSOMEIP_INSTALL_PATH=${{ github.workspace }}/${{ env.VSOMEIP_INSTALL_PATH }}" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ github.workspace }}/${{ env.VSOMEIP_INSTALL_PATH }}/lib" >> $GITHUB_ENV
- name: Print environment variables for debugging
run: |
echo "VSOMEIP_INSTALL_PATH: ${{ env.VSOMEIP_INSTALL_PATH }}"
echo "LD_LIBRARY_PATH: ${{ env.LD_LIBRARY_PATH }}"
- name: Ensure vsomeip install path exists
run: |
mkdir -p ${{ env.VSOMEIP_INSTALL_PATH }}
ls -l
- name: Print cache_key
run: |
echo "cache_key: ${{ env.CACHE_KEY }}"
- name: Restore vsomeip build cache
uses: actions/cache@v3
with:
path: ${{ env.VSOMEIP_INSTALL_PATH }}
key: ${{ env.CACHE_KEY }}
restore-keys: |
${{ runner.os }}-vsomeip-
- name: Install dependencies
run: |
cargo install cargo-tarpaulin
- name: Show toolchain information
working-directory: ${{github.workspace}}
run: |
rustup toolchain list
cargo --version
- name: Run tests and report code coverage
run: |
# enable nightly features so that we can also include Doctests
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${VSOMEIP_INSTALL_PATH}/lib RUSTC_BOOTSTRAP=1 cargo tarpaulin --no-default-features -o xml -o lcov -o html --doc --tests -- --test-threads 1
- name: Upload coverage report (xml)
uses: actions/upload-artifact@v4
with:
name: Test Coverage Results (xml)
path: cobertura.xml

- name: Upload coverage report (lcov)
uses: actions/upload-artifact@v4
with:
name: Test Coverage Results (lcov)
path: lcov.info

- name: Upload coverage report (html)
uses: actions/upload-artifact@v4
with:
name: Test Coverage Results (html)
path: tarpaulin-report.html

# - name: Upload coverage report
# uses: actions/upload-artifact@v4
# with:
# name: Code coverage report
# path: cobertura.xml

build-docs:
name: Build documentation
needs: obtain_and_build_vsomeip
runs-on: ubuntu-latest
env:
CACHE_KEY: ${{ needs.obtain_and_build_vsomeip.outputs.cache_key }}

steps:
- uses: actions/checkout@v4

- name: Install C++ dependencies
run: sudo apt-get install -y build-essential cmake libboost-all-dev

- name: Set environment variables
run: |
echo "VSOMEIP_INSTALL_PATH=${{ github.workspace }}/${{ env.VSOMEIP_INSTALL_PATH }}" >> $GITHUB_ENV
- name: Print environment variables for debugging
run: |
echo "VSOMEIP_INSTALL_PATH: ${{ env.VSOMEIP_INSTALL_PATH }}"
- name: Ensure vsomeip install path exists
run: |
mkdir -p ${{ env.VSOMEIP_INSTALL_PATH }}
ls -l
- name: Print cache_key
run: |
echo "cache_key: ${{ env.CACHE_KEY }}"
- name: Restore vsomeip build cache
uses: actions/cache@v3
with:
path: ${{ env.VSOMEIP_INSTALL_PATH }}
key: ${{ env.CACHE_KEY }}
restore-keys: |
${{ runner.os }}-vsomeip-
- name: Create Documentation for up-streamer
working-directory: ${{github.workspace}}
run: RUSTDOCFLAGS=-Dwarnings cargo doc -p up-streamer --no-deps --no-default-features

- name: Create Documentation for up-linux-streamer
working-directory: ${{github.workspace}}
run: RUSTDOCFLAGS=-Dwarnings cargo doc -p up-linux-streamer --no-deps --no-default-features

6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions up-linux-streamer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ edition.workspace = true
keywords.workspace = true
license.workspace = true

[features]
default = ["bundled-vsomeip"]
bundled-vsomeip = ["up-transport-vsomeip/bundled"]

[dependencies]
async-trait = { workspace = true }
clap = { version = "4.5.9", features = ["derive"] }
Expand All @@ -20,8 +24,7 @@ tokio = { workspace = true }
up-rust = { workspace = true }
up-streamer = { path = "../up-streamer" }
up-transport-zenoh = { git = "https://github.com/eclipse-uprotocol/up-transport-zenoh-rust.git", rev = "7c839e7a94f526a82027564a609f48a79a3f4eae" }
up-transport-vsomeip = { git = "https://github.com/PLeVasseur/up-client-vsomeip-rust.git", branch = "feature/up-transport-vsomeip-rust_initial-implementation" }
#up-transport-vsomeip = { git = "https://github.com/eclipse-uprotocol/up-transport-vsomeip-rust.git", rev = "" }
up-transport-vsomeip = { git = "https://github.com/eclipse-uprotocol/up-transport-vsomeip-rust.git", rev = "acbb0d0c9b8b48dd35c74f461e97151f1e922000", default-features = false }
zenoh = { version = "0.11.0-rc.3", features = ["unstable"]}
usubscription-static-file = {path = "../example-utils/usubscription-static-file"}
chrono = "0.4"
Expand Down
4 changes: 4 additions & 0 deletions up-linux-streamer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ Concrete implementation of a uStreamer as a binary.

Reference the `DEFAULT_CONFIG.json5` configuration file to understand configuration options.

### Bundled vsomeip or bring your own

The default is to build a bundled version of vsomeip for use by the `up-transport-vsomeip` crate.

If you wish to bring your own vsomeip install, you can use the flag `--no-default-features` flag when building with `cargo build`. For more details on required environment variables when building `up-transport-vsomeip-rust`, reference the README for [vsomeip-sys](https://github.com/eclipse-uprotocol/up-transport-vsomeip-rust/tree/main/vsomeip-sys).

0 comments on commit bd19272

Please sign in to comment.