diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a6d34e1..4c8f2d1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,9 +2,12 @@ name: CI on: push: - branches: [ master ] + branches: + - "**" pull_request: - branches: [ master ] + branches: + - "master" + - "yang2" env: CARGO_TERM_COLOR: always @@ -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 @@ -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 @@ -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: diff --git a/src/data.rs b/src/data.rs index bd5e9d7..e133230 100644 --- a/src/data.rs +++ b/src/data.rs @@ -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) }; } @@ -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 } @@ -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 } @@ -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 } diff --git a/src/schema.rs b/src/schema.rs index d1995a7..762d3a4 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -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 } @@ -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, @@ -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 } @@ -997,7 +997,7 @@ unsafe impl Sync for SchemaNode<'_> {} // ===== impl SchemaStmtMust ===== -impl<'a> SchemaStmtMust<'a> { +impl SchemaStmtMust<'_> { // TODO: XPath condition /// description substatement. @@ -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, @@ -1041,7 +1041,7 @@ unsafe impl Sync for SchemaStmtMust<'_> {} // ===== impl SchemaStmtWhen ===== -impl<'a> SchemaStmtWhen<'a> { +impl SchemaStmtWhen<'_> { // TODO: XPath condition /// description substatement. @@ -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, @@ -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 }; @@ -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 } } } @@ -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 } } }