Skip to content

Commit

Permalink
Merge pull request #23 from yodaldevoid/ci_coverage_fix_yang2
Browse files Browse the repository at this point in the history
[yang2] Fix CI tests
  • Loading branch information
rwestphal authored Dec 6, 2024
2 parents d596554 + 4774953 commit 4e5b2bd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 42 deletions.
36 changes: 12 additions & 24 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ name: CI

on:
push:
branches: [ master ]
branches:
- "**"
pull_request:
branches: [ master ]
branches:
- "master"
- "yang2"

env:
CARGO_TERM_COLOR: always
Expand All @@ -17,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- uses: Swatinem/rust-cache@v2
Expand All @@ -33,7 +36,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Run Clippy
Expand All @@ -42,36 +45,21 @@ jobs:
test:
name: Tests and Coverage Report
env:
yang2_rs: rust_ci_github_actions_workflow
CARGO_INCREMENTAL: 0
RUSTFLAGS: -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort
RUSTFLAGS: -Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort
RUSTDOCFLAGS: -Cpanic=abort
LLVM_PROFILE_FILE: yang_rs-%p-%m.profraw
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- name: Cache dependencies
uses: actions/cache@v2
env:
cache-name: cache-dependencies
- uses: dtolnay/rust-toolchain@nightly
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
target
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
components: llvm-tools-preview
- name: Generate test result and coverage report
run: |
cargo install cargo2junit grcov;
cargo test --features bundled $CARGO_OPTIONS -- -Z unstable-options --format json | cargo2junit > results.xml;
grcov . -s . -t lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" --ignore "examples/*" --ignore "libyang2-sys/*" -o lcov.info;
grcov . -s . --binary-path ./target/debug/ -t lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" --ignore "examples/*" --ignore "libyang3-sys/*" -o lcov.info;
- name: Upload test results
uses: EnricoMi/publish-unit-test-result-action@v1
with:
Expand Down
14 changes: 7 additions & 7 deletions src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,10 +727,10 @@ unsafe impl<'a> Binding<'a> for DataTree<'a> {
}
}

unsafe impl<'a> Send for DataTree<'a> {}
unsafe impl<'a> Sync for DataTree<'a> {}
unsafe impl Send for DataTree<'_> {}
unsafe impl Sync for DataTree<'_> {}

impl<'a> Drop for DataTree<'a> {
impl Drop for DataTree<'_> {
fn drop(&mut self) {
unsafe { ffi::lyd_free_all(self.raw) };
}
Expand Down Expand Up @@ -1079,8 +1079,8 @@ impl<'a, 'b> DataNodeRef<'a, 'b> {
}
}

impl<'a, 'b> Data<'b> for DataNodeRef<'a, 'b> {
fn tree(&self) -> &DataTree<'b> {
impl<'a> Data<'a> for DataNodeRef<'_, 'a> {
fn tree(&self) -> &DataTree<'a> {
self.tree
}

Expand Down Expand Up @@ -1139,7 +1139,7 @@ impl<'a, 'b> NodeIterable<'a> for DataNodeRef<'a, 'b> {
}
}

impl<'a, 'b> PartialEq for DataNodeRef<'a, 'b> {
impl PartialEq for DataNodeRef<'_, '_> {
fn eq(&self, other: &DataNodeRef<'_, '_>) -> bool {
self.raw == other.raw
}
Expand Down Expand Up @@ -1191,7 +1191,7 @@ unsafe impl<'a, 'b> Binding<'a> for Metadata<'a, 'b> {
}
}

impl<'a, 'b> PartialEq for Metadata<'a, 'b> {
impl PartialEq for Metadata<'_, '_> {
fn eq(&self, other: &Metadata<'_, '_>) -> bool {
self.raw == other.raw
}
Expand Down
22 changes: 11 additions & 11 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,12 @@ unsafe impl<'a> Binding<'a> for SchemaModule<'a> {
unsafe fn from_raw(
context: &'a Context,
raw: *mut ffi::lys_module,
) -> SchemaModule<'_> {
) -> SchemaModule<'a> {
SchemaModule { context, raw }
}
}

impl<'a> PartialEq for SchemaModule<'a> {
impl PartialEq for SchemaModule<'_> {
fn eq(&self, other: &SchemaModule<'_>) -> bool {
self.raw == other.raw
}
Expand Down Expand Up @@ -948,7 +948,7 @@ unsafe impl<'a> Binding<'a> for SchemaNode<'a> {
unsafe fn from_raw(
context: &'a Context,
raw: *mut ffi::lysc_node,
) -> SchemaNode<'_> {
) -> SchemaNode<'a> {
let nodetype = unsafe { (*raw).nodetype } as u32;
let kind = match nodetype {
ffi::LYS_CONTAINER => SchemaNodeKind::Container,
Expand Down Expand Up @@ -986,7 +986,7 @@ impl<'a> NodeIterable<'a> for SchemaNode<'a> {
}
}

impl<'a> PartialEq for SchemaNode<'a> {
impl PartialEq for SchemaNode<'_> {
fn eq(&self, other: &SchemaNode<'_>) -> bool {
self.raw == other.raw
}
Expand All @@ -997,7 +997,7 @@ unsafe impl Sync for SchemaNode<'_> {}

// ===== impl SchemaStmtMust =====

impl<'a> SchemaStmtMust<'a> {
impl SchemaStmtMust<'_> {
// TODO: XPath condition

/// description substatement.
Expand Down Expand Up @@ -1028,7 +1028,7 @@ unsafe impl<'a> Binding<'a> for SchemaStmtMust<'a> {
unsafe fn from_raw(
_context: &'a Context,
raw: *mut ffi::lysc_must,
) -> SchemaStmtMust<'_> {
) -> SchemaStmtMust<'a> {
SchemaStmtMust {
raw,
_marker: std::marker::PhantomData,
Expand All @@ -1041,7 +1041,7 @@ unsafe impl Sync for SchemaStmtMust<'_> {}

// ===== impl SchemaStmtWhen =====

impl<'a> SchemaStmtWhen<'a> {
impl SchemaStmtWhen<'_> {
// TODO: XPath condition

/// description substatement.
Expand All @@ -1062,7 +1062,7 @@ unsafe impl<'a> Binding<'a> for SchemaStmtWhen<'a> {
unsafe fn from_raw(
_context: &'a Context,
raw: *mut *mut ffi::lysc_when,
) -> SchemaStmtWhen<'_> {
) -> SchemaStmtWhen<'a> {
let raw = unsafe { *raw };
SchemaStmtWhen {
raw,
Expand All @@ -1076,7 +1076,7 @@ unsafe impl Sync for SchemaStmtWhen<'_> {}

// ===== impl SchemaLeafType =====

impl<'a> SchemaLeafType<'a> {
impl SchemaLeafType<'_> {
/// Returns the resolved base type.
pub fn base_type(&self) -> DataValueType {
let base_type = unsafe { (*self.raw).basetype };
Expand Down Expand Up @@ -1111,7 +1111,7 @@ unsafe impl<'a> Binding<'a> for SchemaLeafType<'a> {
unsafe fn from_raw(
context: &'a Context,
raw: *mut ffi::lysc_type,
) -> SchemaLeafType<'_> {
) -> SchemaLeafType<'a> {
SchemaLeafType { context, raw }
}
}
Expand Down Expand Up @@ -1210,7 +1210,7 @@ unsafe impl<'a> Binding<'a> for SchemaExtInstance<'a> {
unsafe fn from_raw(
context: &'a Context,
raw: *mut ffi::lysc_ext_instance,
) -> SchemaExtInstance<'_> {
) -> SchemaExtInstance<'a> {
SchemaExtInstance { context, raw }
}
}
Expand Down

0 comments on commit 4e5b2bd

Please sign in to comment.