From ca2f0b6b70b50ef74bc3093d314cc7974c6df9db Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Thu, 23 Jun 2022 00:27:04 +0200 Subject: [PATCH] iox-#5 Add coverage --- .github/workflows/rust.yml | 55 +++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index db49cc1..8061bd8 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,4 +1,4 @@ -name: Rust Build & Test (Ubuntu, macOS, Windows) +name: Build & Test on: push: @@ -15,12 +15,22 @@ jobs: strategy: matrix: os: [ubuntu-latest, macOS-latest] #Todo add windows-latest - rust: [stable, nightly] + toolchain: [stable, nightly] steps: - uses: hecrj/setup-rust-action@v1 with: - rust-version: ${{ matrix.rust }} + rust-version: ${{ matrix.toolchain }} + - name: Setup cache + uses: actions/cache@v2 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: cache-${{ runner.os }}-toolchain-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.toml') }} - uses: actions/checkout@v3 with: submodules: recursive @@ -33,3 +43,42 @@ jobs: run: cargo build --all --examples - name: Run tests run: cargo test -- --test-threads=1 # prevent running multiple RouDiEnvironments in parallel + + coverage: + runs-on: ubuntu-latest + steps: + - uses: hecrj/setup-rust-action@v1 + with: + rust-version: nightly + components: llvm-tools-preview + - name: Setup cache + uses: actions/cache@v2 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: coverage-llvm-tools-preview-cache-${{ runner.os }}-toolchain-nightly-${{ hashFiles('**/Cargo.toml') }} + - uses: actions/checkout@v3 + with: + submodules: recursive + - name: Install dependencies + run: | + sudo apt update + sudo apt install -y libacl1-dev libncurses5-dev + cargo install grcov + - name: Build + env: + RUSTFLAGS: -Cinstrument-coverage + run: cargo build + - name: Run test + env: + LLVM_PROFILE_FILE: iceoryx-rs-%p-%m.profraw + RUSTFLAGS: -Cinstrument-coverage + run: cargo test -- --test-threads=1 # prevent running multiple RouDiEnvironments in parallel + - name: Generate coverage + run: | + grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing -o ./lcov.info + bash <(curl -s https://codecov.io/bash) -f lcov.info