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
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@

@startuml

package "SampleLibraryAPI" as SampleLibraryAPI {
interface "GetNumber" as GetNumber
' interface "SetNumber" as SetNumber
namespace safety_software_seooc_example {
interface "SampleLibraryAPI" as SampleLibraryAPI {
+ GetNumber(): int
}
}

@enduml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ package "Safety Software SEooC Example" as safety_software_seooc_example <<SEooC
}
}

package "SampleLibraryAPI" as SampleLibraryAPI
interface "SampleLibraryAPI" as SampleLibraryAPI

component_example --> SampleLibraryAPI
safety_software_seooc_example )-d- SampleLibraryAPI

@enduml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ScoreReq.FailureMode SampleFailureMode{
failureeffect = "The world as we know it will end"
version = 1
safety = ScoreReq.Asil.B
interface = "SampleLibraryAPI.GetNumber"
interface = "safety_software_seooc_example.SampleLibraryAPI.GetNumber"
}

ScoreReq.FailureMode SampleFailureMode2{
Expand All @@ -29,5 +29,5 @@ ScoreReq.FailureMode SampleFailureMode2{
failureeffect = "Downstream consumers time out"
version = 1
safety = ScoreReq.Asil.D
interface = "SampleLibraryAPI.GetNumber"
interface = "safety_software_seooc_example.SampleLibraryAPI.GetNumber"
}
10 changes: 6 additions & 4 deletions bazel/rules/rules_score/private/architectural_design.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def _run_puml_parser(ctx, puml_file):
Args:
ctx: Rule context
puml_file: The .puml File object to parse

Returns:
Tuple of (fbs_output, lobster_output) declared output Files.
"""
Expand Down Expand Up @@ -79,7 +78,6 @@ def _parse_puml_diagrams(ctx, files):
Args:
ctx: Rule context
files: List of File objects

Returns:
Tuple of (fbs_outputs, lobster_outputs) lists of generated Files.
"""
Expand All @@ -92,13 +90,14 @@ def _parse_puml_diagrams(ctx, files):
lobster_outputs.append(lobster)
return fbs_outputs, lobster_outputs

def _run_validation(ctx, component_fbs_files, sequence_fbs_files, internal_api_fbs_files):
def _run_validation(ctx, component_fbs_files, sequence_fbs_files, public_api_fbs_files, internal_api_fbs_files):
"""Run the architectural-design validation profile.

Args:
ctx: Rule context
component_fbs_files: Component-diagram FlatBuffer files generated from this target's static inputs.
sequence_fbs_files: Sequence-diagram FlatBuffer files generated from this target's dynamic inputs.
public_api_fbs_files: List of public-API FlatBuffer files generated from this target's public_api inputs.
internal_api_fbs_files: List of internal-API FlatBuffer files generated from this target's internal_api inputs.
Returns:
Struct with file and name fields describing the validation log entry.
Expand All @@ -111,9 +110,10 @@ def _run_validation(ctx, component_fbs_files, sequence_fbs_files, internal_api_f
input_bundle = {
"component_diagrams": [f.path for f in component_fbs_files],
"sequence_diagrams": [f.path for f in sequence_fbs_files],
"public_api_diagrams": [f.path for f in public_api_fbs_files],
"internal_api_diagrams": [f.path for f in internal_api_fbs_files],
},
inputs = component_fbs_files + sequence_fbs_files + internal_api_fbs_files,
inputs = component_fbs_files + sequence_fbs_files + public_api_fbs_files + internal_api_fbs_files,
mnemonic = "ArchitecturalDesignValidate",
maturity = ctx.attr.maturity,
log_level = get_log_level(ctx),
Expand Down Expand Up @@ -193,6 +193,7 @@ def _architectural_design_impl(ctx):
ctx,
static_fbs_list,
dynamic_fbs_list,
public_api_fbs_list,
internal_api_fbs_list,
)

Expand All @@ -203,6 +204,7 @@ def _architectural_design_impl(ctx):
ArchitecturalDesignInfo(
static = static_fbs,
dynamic = dynamic_fbs,
public_api = public_api_fbs,
internal_api = internal_api_fbs,
name = ctx.label.name,
public_api_lobster_files = public_api_lobster,
Expand Down
1 change: 1 addition & 0 deletions bazel/rules/rules_score/providers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ ArchitecturalDesignInfo = provider(
fields = {
"static": "Depset of FlatBuffers binaries for static architecture diagrams (class diagrams, component diagrams, etc.)",
"dynamic": "Depset of FlatBuffers binaries for dynamic architecture diagrams (sequence diagrams, activity diagrams, etc.)",
"public_api": "Depset of FlatBuffers binaries for public API diagrams (class diagrams, etc.)",
"internal_api": "Depset of FlatBuffers binaries for internal API diagrams (class diagrams, etc.)",
"name": "Name of the architectural design target",
"public_api_lobster_files": "Depset of .lobster traceability files generated from public_api diagrams.",
Expand Down
2 changes: 2 additions & 0 deletions validation/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ rust_library(
"src/validators/bazel_component_validator.rs",
"src/validators/class_design_implementation_validator.rs",
"src/validators/component_internal_api_validator.rs",
"src/validators/component_public_api_validator.rs",
"src/validators/component_sequence_validator.rs",
"src/validators/mod.rs",
"src/validators/sequence_internal_api_validator.rs",
"src/validators/shared/diagram_analysis.rs",
"src/validators/shared/helpers.rs",
"src/validators/shared/mod.rs",
"src/validators/test/component_internal_api_validator_test.rs",
"src/validators/test/component_public_api_validator_test.rs",
"src/validators/test/component_sequence_validator_test.rs",
"src/validators/test/fixtures.rs",
"src/validators/test/sequence_internal_api_validator_test.rs",
Expand Down
40 changes: 40 additions & 0 deletions validation/core/integration_test/component_public_api/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# *******************************************************************************
# 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
# *******************************************************************************

load("@rules_rust//rust:defs.bzl", "rust_test")

filegroup(
name = "component_public_api_test_data",
srcs = [
"//validation/core/integration_test/component_public_api/negative_case_sensitive:case_data",
"//validation/core/integration_test/component_public_api/negative_public_api_lack_of_relationship:case_data",
"//validation/core/integration_test/component_public_api/negative_public_api_missing:case_data",
"//validation/core/integration_test/component_public_api/negative_public_api_wrong_type:case_data",
"//validation/core/integration_test/component_public_api/positive_public_api_match:case_data",
],
)

rust_test(
name = "component_public_api_integration_test",
srcs = ["component_public_api_suite.rs"],
crate_root = "component_public_api_suite.rs",
data = [
":component_public_api_test_data",
],
deps = [
"//validation/core:validation_cli",
"//validation/core/integration_test:test_framework",
"@crates//:serde",
"@crates//:serde_json",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// *******************************************************************************
// 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
// *******************************************************************************

use test_framework::{
assert_cli_result, collect_case_fbs_files, load_expected_yaml_fixture, run_validation_profile,
CliRunResult,
};

const SUITE_DIR: &str = "component_public_api";

fn run_case_from_cli(
case_dir: &str,
component_fbs_paths: &[String],
public_api_fbs_paths: &[String],
) -> CliRunResult {
run_validation_profile(
&format!("component_public_api_{case_dir}"),
"architectural-design",
serde_json::json!({
"component_diagrams": component_fbs_paths,
"public_api_diagrams": public_api_fbs_paths,
}),
)
}

fn assert_case(case_dir: &str) {
let expected = load_expected_yaml_fixture(SUITE_DIR, case_dir);
let component_fbs_paths = collect_case_fbs_files(SUITE_DIR, case_dir, "component");
let public_api_fbs_paths = collect_case_fbs_files(SUITE_DIR, case_dir, "public_api");

let result = if !component_fbs_paths.is_empty() && !public_api_fbs_paths.is_empty() {
run_case_from_cli(case_dir, &component_fbs_paths, &public_api_fbs_paths)
} else {
panic!(
"missing generated FBS fixtures for {case_dir}: expected component/*.fbs.bin and public_api/*.fbs.bin",
);
};

assert_cli_result(case_dir, &expected, &result);
}

#[test]
fn positive_public_api_match_suite_case() {
assert_case("positive_public_api_match");
}

#[test]
fn negative_public_api_missing_suite_case() {
assert_case("negative_public_api_missing");
}

#[test]
fn negative_public_api_wrong_type_suite_case() {
assert_case("negative_public_api_wrong_type");
}

#[test]
fn negative_case_sensitive_suite_case() {
assert_case("negative_case_sensitive");
}

#[test]
fn negative_public_api_lack_of_relationship_suite_case() {
assert_case("negative_public_api_lack_of_relationship");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# *******************************************************************************
# 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
# *******************************************************************************

load("//bazel/rules/rules_score:rules_score.bzl", "architectural_design")
load("//validation/core/integration_test:puml_fixture.bzl", "provider_fbs_fixture_bundle")

architectural_design(
name = "design",
maturity = "development",
public_api = ["public_api.puml"],
static = ["static_design.puml"],
visibility = ["//visibility:private"],
)

provider_fbs_fixture_bundle(
name = "fbs",
visibility = ["//visibility:private"],
deps = [":design"],
)

filegroup(
name = "case_data",
srcs = [
"expected.yaml",
":fbs",
],
visibility = ["//validation/core/integration_test:__subpackages__"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# *******************************************************************************
# 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
# *******************************************************************************
should_pass: false
error_contains: |
Missing public APIs : "SampleLibraryAPI"
Action : Declare each public API interface in the public API class diagram or remove it from the component diagram
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
' *******************************************************************************
' 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
' *******************************************************************************

@startuml public_api

interface "Sample Library API" as SAMPLELIBRARYAPI <<interface>> {
+GetNumber(): int
}

@enduml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
' *******************************************************************************
' 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
' *******************************************************************************

@startuml static_design

package "Sample Seooc" as sample_seooc <<SEooC>> {
component "Component Example" as component_example <<component>> {
component "Unit 1" as unit_1 <<unit>>
}

portout sample_seooc_public_api_port
}

interface "SampleLibraryAPI" as SampleLibraryAPI
sample_seooc_public_api_port )-d- SampleLibraryAPI

@enduml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# *******************************************************************************
# 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
# *******************************************************************************

load("//bazel/rules/rules_score:rules_score.bzl", "architectural_design")
load("//validation/core/integration_test:puml_fixture.bzl", "provider_fbs_fixture_bundle")

architectural_design(
name = "design",
maturity = "development",
public_api = ["public_api.puml"],
static = ["static_design.puml"],
visibility = ["//visibility:private"],
)

provider_fbs_fixture_bundle(
name = "fbs",
visibility = ["//visibility:private"],
deps = [":design"],
)

filegroup(
name = "case_data",
srcs = [
"expected.yaml",
":fbs",
],
visibility = ["//validation/core/integration_test:__subpackages__"],
)
Loading
Loading