Skip to content
Merged
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
19 changes: 18 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ build:per_shared --host_platform=@score_bazel_platforms//:x86_64-linux
build:per-x86_64-linux --config=per_shared
build:per-x86_64-linux --platforms=@score_bazel_platforms//:x86_64-linux
build:per-x86_64-linux --extra_toolchains=@gcc_toolchain//:host_gcc_12

build:per-x86_64-linux --extra_toolchains=@score_toolchains_rust//toolchains/ferrocene:ferrocene_x86_64_unknown_linux_gnu
# -------------------------------------------------------------------------------
# Config dedicated to target platform CPU:x86_64 and OS:QNX
# -------------------------------------------------------------------------------
build:per-x86_64-qnx --config=per_shared
build:per-x86_64-qnx --platforms=@score_toolchains_qnx//platforms:x86_64-qnx
build:per-x86_64-qnx --extra_toolchains=@toolchains_qnx_qcc//:qcc_x86_64
build:per-x86_64-qnx --extra_toolchains=@toolchains_qnx_ifs//:ifs_x86_64
build:per-x86_64-qnx --extra_toolchains=@score_toolchains_rust//toolchains/ferrocene:ferrocene_x86_64_pc_nto_qnx800

# -------------------------------------------------------------------------------
# Config dedicated to target platform CPU:arm64 and OS:QNX
Expand All @@ -66,6 +67,22 @@ build:per-arm64-qnx --config=per_shared
build:per-arm64-qnx --platforms=@score_toolchains_qnx//platforms:aarch64-qnx8_0
build:per-arm64-qnx --extra_toolchains=@toolchains_qnx_qcc//:qcc_aarch64
build:per-arm64-qnx --extra_toolchains=@toolchains_qnx_ifs//:ifs_aarch64
build:per-arm64-qnx --extra_toolchains=@score_toolchains_rust//toolchains/ferrocene:ferrocene_aarch64_unknown_nto_qnx800


# -------------------------------------------------------------------------------
# Ferrocene Rust coverage config
# -------------------------------------------------------------------------------
build:ferrocene-coverage --@rules_rust//rust/settings:extra_rustc_flag=-Cinstrument-coverage
build:ferrocene-coverage --@rules_rust//rust/settings:extra_rustc_flag=-Clink-dead-code
build:ferrocene-coverage --@rules_rust//rust/settings:extra_rustc_flag=-Ccodegen-units=1
build:ferrocene-coverage --@rules_rust//rust/settings:extra_rustc_flag=-Cdebuginfo=2
build:ferrocene-coverage --@rules_rust//rust/settings:extra_exec_rustc_flag=-Cinstrument-coverage
build:ferrocene-coverage --@rules_rust//rust/settings:extra_exec_rustc_flag=-Clink-dead-code
build:ferrocene-coverage --@rules_rust//rust/settings:extra_exec_rustc_flag=-Ccodegen-units=1
build:ferrocene-coverage --@rules_rust//rust/settings:extra_exec_rustc_flag=-Cdebuginfo=2
Comment thread
dcalavrezo-qorix marked this conversation as resolved.
test:ferrocene-coverage --run_under=@score_tooling//coverage:llvm_profile_wrapper


# -------------------------------------------------------------------------------
# Import local user workspace file, if exists
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/rust_coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# *******************************************************************************
# Copyright (c) 2026 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: Rust Coverage (Demo)
on:
pull_request:
types: [opened, reopened, synchronize]
workflow_dispatch:

jobs:
rust_coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.2

- name: Setup Bazel
uses: bazel-contrib/setup-bazel@0.14.0

- name: Run Rust tests with coverage instrumentation
run: |
set -euo pipefail
bazel test --config=per-x86_64-linux --config=ferrocene-coverage \
--nocache_test_results \
//src/rust/...

- name: Generate Ferrocene coverage reports
run: |
set -euo pipefail
bazel run //:rust_coverage -- --min-line-coverage 90

- name: Locate coverage artifacts
run: |
echo "COVERAGE_DIR=$(bazel info bazel-bin)/coverage/rust-tests" >> "${GITHUB_ENV}"

- name: Upload coverage HTML
uses: actions/upload-artifact@v4
with:
name: rust-coverage-html
path: ${{ env.COVERAGE_DIR }}
18 changes: 17 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

load("@rules_rust//rust:defs.bzl", "rust_clippy")
load("@score_docs_as_code//:docs.bzl", "docs")
load("@score_tooling//:defs.bzl", "cli_helper", "copyright_checker", "dash_license_checker", "setup_starpls", "use_format_targets")
load("@score_tooling//:defs.bzl", "cli_helper", "copyright_checker", "dash_license_checker", "rust_coverage_report", "setup_starpls", "use_format_targets")
load("//:project_config.bzl", "PROJECT_CONFIG")

# Creates all documentation targets:
Expand Down Expand Up @@ -84,6 +84,22 @@ cli_helper(
visibility = ["//visibility:public"],
)

rust_coverage_report(
name = "rust_coverage",
bazel_configs = [
"per-x86_64-linux",
"ferrocene-coverage",
],
query = 'kind("rust_test", //src/rust/...)',
visibility = ["//visibility:public"],
)

alias(
name = "rust_coverage_report",
actual = ":rust_coverage",
visibility = ["//visibility:public"],
)

# Add target for formatting checks
use_format_targets()

Expand Down
40 changes: 2 additions & 38 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ bazel_dep(name = "rules_rust", version = "0.61.0")
# Shared Rust policies (Clippy config, etc.), overridden locally during development.
bazel_dep(name = "score_rust_policies", version = "0.0.2", dev_dependency = True)

rust = use_extension("@rules_rust//rust:extensions.bzl", "rust", dev_dependency = True)
rust.toolchain(
edition = "2021",
versions = ["1.85.0"],
)

# bazel cc rules
bazel_dep(name = "rules_cc", version = "0.1.2")

Expand Down Expand Up @@ -93,30 +87,12 @@ bazel_dep(name = "score_platform", version = "0.5.2", dev_dependency = True)

bazel_dep(name = "score_process", version = "1.3.2")
bazel_dep(name = "score_python_basics", version = "0.3.4")
bazel_dep(name = "score_tooling", version = "1.0.3")

# ToDo: remove this once 1.0.4 is released,
# since it will contain updated cr_checker
git_override(
module_name = "score_tooling",
commit = "654664dae7df2700fd5840c5ed6c07ac6c61705d", #until 1.0.4 is released
remote = "https://github.com/eclipse-score/tooling.git",
)
bazel_dep(name = "score_tooling", version = "1.1.0")

# ToDo: implicit dependencies for score_tooling, but needed directly here??
bazel_dep(name = "aspect_rules_lint", version = "1.10.2")
bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2")

## additional settings / config
bazel_dep(name = "rust_qnx8_toolchain", version = "1.0.0", dev_dependency = True)
archive_override(
module_name = "rust_qnx8_toolchain",
strip_prefix = "qnx8",
urls = [
"https://github.com/qorix-group/rust-lang-qnx8/releases/download/1.0.0/qnx8_rust_toolchain.tar.gz",
],
)

## temporary overrides / tools
# Testing utils dependency.
# Direct usage of tag in git_override reports false problem in editor, using hash of a tag
Expand All @@ -135,13 +111,7 @@ git_override(
remote = "https://github.com/eclipse-score/baselibs.git",
)

bazel_dep(name = "score_toolchains_rust", version = "0.1", dev_dependency = True)
git_override(
module_name = "score_toolchains_rust",
commit = "5614e4b273f2f5302d47a05d7e58dae86f97a3c3",
remote = "https://github.com/eclipse-score/toolchains_rust.git",
)

bazel_dep(name = "score_toolchains_rust", version = "0.4.0", dev_dependency = True)
bazel_dep(name = "custom_qemu", version = "1.0.0", dev_dependency = True)
archive_override(
module_name = "custom_qemu",
Expand All @@ -152,11 +122,5 @@ archive_override(
],
)

# Registers the custom Rust toolchain wired to @qnx_rust
register_toolchains(
"@score_toolchains_rust//toolchains/aarch64-unknown-qnx8_0:toolchain_aarch64_qnx8_0",
dev_dependency = True,
)

# S-CORE crates
bazel_dep(name = "score_crates", version = "0.0.6")
12 changes: 12 additions & 0 deletions src/rust/rust_kvs/examples/basic.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
// *******************************************************************************
// Copyright (c) 2026 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
// *******************************************************************************
//! Example for basic operations.
//! - Creating KVS instance using `KvsBuilder` with `kvs_load` modes.
//! - Basic key-value operations: `get_value`, `get_value_as`, `set_value`, `get_all_keys`.
Expand Down
12 changes: 12 additions & 0 deletions src/rust/rust_kvs/examples/custom_types.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
// *******************************************************************************
// Copyright (c) 2026 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
// *******************************************************************************
//! Example for custom types usage for KVS, with serialization and deserialization.
//! - Implementing serialization/deserialization traits for custom types.
//! - Handling external and nested types.
Expand Down
12 changes: 12 additions & 0 deletions src/rust/rust_kvs/examples/defaults.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
// *******************************************************************************
// Copyright (c) 2026 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
// *******************************************************************************
//! Example for default values.
//! - Creating KVS instance using `KvsBuilder` with `defaults` modes.
//! - Default-specific APIs: `get_default_value`, `is_value_default`.
Expand Down
12 changes: 12 additions & 0 deletions src/rust/rust_kvs/examples/snapshots.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
// *******************************************************************************
// Copyright (c) 2026 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
// *******************************************************************************
//! Example for snapshots handling.
//! - Snapshot count and max count.
//! - Snapshot restore.
Expand Down
5 changes: 3 additions & 2 deletions src/rust/rust_kvs/src/error_code.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2025 Contributors to the Eclipse Foundation
// *******************************************************************************
// Copyright (c) 2026 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
Expand All @@ -8,7 +9,7 @@
// <https://www.apache.org/licenses/LICENSE-2.0>
//
// SPDX-License-Identifier: Apache-2.0

// *******************************************************************************
extern crate alloc;

use alloc::string::FromUtf8Error;
Expand Down
5 changes: 3 additions & 2 deletions src/rust/rust_kvs/src/json_backend.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2025 Contributors to the Eclipse Foundation
// *******************************************************************************
// Copyright (c) 2026 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
Expand All @@ -8,7 +9,7 @@
// <https://www.apache.org/licenses/LICENSE-2.0>
//
// SPDX-License-Identifier: Apache-2.0

// *******************************************************************************
use crate::error_code::ErrorCode;
use crate::kvs_api::{InstanceId, SnapshotId};
use crate::kvs_backend::KvsBackend;
Expand Down
5 changes: 3 additions & 2 deletions src/rust/rust_kvs/src/kvs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2025 Contributors to the Eclipse Foundation
// *******************************************************************************
// Copyright (c) 2026 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
Expand All @@ -8,7 +9,7 @@
// <https://www.apache.org/licenses/LICENSE-2.0>
//
// SPDX-License-Identifier: Apache-2.0

// *******************************************************************************
use crate::error_code::ErrorCode;
use crate::kvs_api::{InstanceId, KvsApi, KvsDefaults, KvsLoad, SnapshotId};
use crate::kvs_backend::KvsBackend;
Expand Down
5 changes: 3 additions & 2 deletions src/rust/rust_kvs/src/kvs_api.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2025 Contributors to the Eclipse Foundation
// *******************************************************************************
// Copyright (c) 2026 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
Expand All @@ -8,7 +9,7 @@
// <https://www.apache.org/licenses/LICENSE-2.0>
//
// SPDX-License-Identifier: Apache-2.0

// *******************************************************************************
use crate::error_code::ErrorCode;
use crate::kvs_value::KvsValue;
use core::fmt;
Expand Down
5 changes: 3 additions & 2 deletions src/rust/rust_kvs/src/kvs_backend.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2025 Contributors to the Eclipse Foundation
// *******************************************************************************
// Copyright (c) 2026 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
Expand All @@ -8,7 +9,7 @@
// <https://www.apache.org/licenses/LICENSE-2.0>
//
// SPDX-License-Identifier: Apache-2.0

// *******************************************************************************
use crate::error_code::ErrorCode;
use crate::kvs_api::{InstanceId, SnapshotId};
use crate::kvs_value::KvsMap;
Expand Down
5 changes: 3 additions & 2 deletions src/rust/rust_kvs/src/kvs_builder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2025 Contributors to the Eclipse Foundation
// *******************************************************************************
// Copyright (c) 2026 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
Expand All @@ -8,7 +9,7 @@
// <https://www.apache.org/licenses/LICENSE-2.0>
//
// SPDX-License-Identifier: Apache-2.0

// *******************************************************************************
use crate::error_code::ErrorCode;
use crate::json_backend::JsonBackendBuilder;
use crate::kvs::{Kvs, KvsParameters};
Expand Down
5 changes: 3 additions & 2 deletions src/rust/rust_kvs/src/kvs_mock.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2025 Contributors to the Eclipse Foundation
// *******************************************************************************
// Copyright (c) 2026 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
Expand All @@ -8,7 +9,7 @@
// <https://www.apache.org/licenses/LICENSE-2.0>
//
// SPDX-License-Identifier: Apache-2.0

// *******************************************************************************
Comment thread
dcalavrezo-qorix marked this conversation as resolved.
use crate::error_code::ErrorCode;
use crate::kvs_api::{KvsApi, SnapshotId};
use crate::kvs_value::{KvsMap, KvsValue};
Expand Down
5 changes: 3 additions & 2 deletions src/rust/rust_kvs/src/kvs_serialize.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2025 Contributors to the Eclipse Foundation
// *******************************************************************************
// Copyright (c) 2026 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
Expand All @@ -8,7 +9,7 @@
// <https://www.apache.org/licenses/LICENSE-2.0>
//
// SPDX-License-Identifier: Apache-2.0

// *******************************************************************************
use crate::error_code::ErrorCode;
use crate::kvs_value::{KvsMap, KvsValue};

Expand Down
Loading
Loading