diff --git a/.bazelignore b/.bazelignore new file mode 100644 index 000000000..1dc4fc581 --- /dev/null +++ b/.bazelignore @@ -0,0 +1 @@ +qnx_qemu diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 000000000..5dfac971c --- /dev/null +++ b/.bazelrc @@ -0,0 +1,58 @@ +# ******************************************************************************* +# Copyright (c) 2025 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 +# ******************************************************************************* + +common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/ +common --registry=https://bcr.bazel.build + + +# Flags needed by score-baselibs and communication modules. +# Do not add more! +build --@score-baselibs//score/mw/log/detail/flags:KUse_Stub_Implementation_Only=False +build --@score-baselibs//score/mw/log/flags:KRemote_Logging=False +build --@score-baselibs//score/json:base_library=nlohmann +build --@communication//score/mw/com/flags:tracing_library=stub + +# stop legacy behavior of creating __init__.py files +build --incompatible_default_to_explicit_init_py +build --incompatible_strict_action_env +build --experimental_retain_test_configuration_across_testonly #https://github.com/bazelbuild/bazel/issues/6842 + +test --test_tag_filters=-manual +test --test_output=errors + +build:_bl_common --host_platform=@score_bazel_platforms//:x86_64-linux + +# This config is for internal module usage ONLY. +build:bl-x86_64-linux --config=_bl_common +build:bl-x86_64-linux --platforms=@score_bazel_platforms//:x86_64-linux +build:bl-x86_64-linux --extra_toolchains=@gcc_toolchain//:host_gcc_12 + +# This config is for internal module usage ONLY. +build:bl-x86_64-qnx --config=_bl_common +build:bl-x86_64-qnx --platforms=@score_bazel_platforms//:x86_64-qnx +build:bl-x86_64-qnx --extra_toolchains=@toolchains_qnx_qcc//:qcc_x86_64 + +# This config is for internal module usage ONLY. +test:bl-x86_64-linux --config=_bl_common +test:bl-x86_64-linux --build_tests_only +test:bl-x86_64-linux --test_tag_filters=-manual +test:bl-x86_64-linux --test_output=errors + + +# config from communication .bazelrc file +# unshare /dev/shm and /tmp +test --sandbox_tmpfs_path=/dev/shm +test --sandbox_tmpfs_path=/tmp + +# user specific overrides (like proxy settings) +try-import %workspace%/user.bazelrc diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 000000000..56b6be4eb --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +8.3.1 diff --git a/.github/workflows/test_integration.yml b/.github/workflows/test_integration.yml new file mode 100644 index 000000000..40837fec7 --- /dev/null +++ b/.github/workflows/test_integration.yml @@ -0,0 +1,78 @@ +# ******************************************************************************* +# Copyright (c) 2025 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 +# ******************************************************************************* + +# Workflow configuration for S-CORE CI - Bazel Build & Test baselibs +# This workflow runs Bazel build and test when triggered by specific pull request events. + +name: Bazel Build some repositories +on: + workflow_dispatch: + push: +jobs: + integration_test: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4.2.2 + - name: Setup Bazel + uses: bazel-contrib/setup-bazel@0.15.0 + with: + # Avoid downloading Bazel every time. + bazelisk-cache: true + # Store build cache per workflow. + disk-cache: ${{ github.workflow }} + # Share repository cache between workflows. + repository-cache: true + - name: Show disk space before build + run: | + echo 'Disk space before build:' + df -h + echo 'Inode usage before build:' + df -i + echo 'Largest top-level directories:' + du -h -d 1 2>/dev/null | sort -h | tail -n 20 || true + - name: Bazel build targets + run: | + echo 'Starting Bazel build (disk space snapshot):' + df -h | sed 's/^/PRE-BUILD DF /' + ./integration_test.sh + - name: Show disk space after build + if: always() + run: | + echo 'Disk space after build:' + df -h + echo 'Inode usage after build:' + df -i + echo 'Largest top-level directories after build:' + du -h -d 1 2>/dev/null | sort -h | tail -n 20 || true + - name: Publish build summary + if: always() + run: | + if [ -f _logs/build_summary.md ]; then + { + echo '## Bazel Build Summary' + echo + # Append the markdown directly so tables render (no leading indentation) + cat _logs/build_summary.md + } >> "$GITHUB_STEP_SUMMARY" + else + echo "No build summary file found (_logs/build_summary.md)" >> "$GITHUB_STEP_SUMMARY" + fi + - name: Upload logs artifact + if: always() + uses: actions/upload-artifact@v4 + with: + name: bazel-build-logs + path: _logs/ + if-no-files-found: warn + retention-days: 14 diff --git a/.gitignore b/.gitignore index 6c272cae4..2ab8efb04 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ # Bazel bazel-* MODULE.bazel.lock +user.bazelrc + +_logs # Ruff .ruff_cache diff --git a/BUILD b/BUILD new file mode 100644 index 000000000..83cf914f6 --- /dev/null +++ b/BUILD @@ -0,0 +1,28 @@ +# ******************************************************************************* +# Copyright (c) 2025 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("@score_docs_as_code//:docs.bzl", "docs") + +# docs( +# data = [ +# # TODO: add all modules that have docs +# ], +# source_dir = "docs", +# ) + +# Simple filegroup target to demonstrate the build system works +filegroup( + name = "readme", + srcs = ["README.md"], + visibility = ["//visibility:public"], +) diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 000000000..afc27c157 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,107 @@ +# ******************************************************************************* +# Copyright (c) 2025 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 +# ******************************************************************************* + +module( + name = "score_reference_integration", + version = "0.0.0", + compatibility_level = 0, +) + +include("//:score_modules.MODULE.bazel") + +# for building documentation, verifying traceability etc. +bazel_dep(name = "score_platform", version = "0.3.0") +bazel_dep(name = "score_bazel_platforms", version = "0.0.2") + +# QNX toolchain +bazel_dep(name = "score_toolchains_qnx", version = "0.0.2") +toolchains_qnx = use_extension("@score_toolchains_qnx//:extensions.bzl", "toolchains_qnx") +toolchains_qnx.sdp( + sha256 = "f2e0cb21c6baddbcb65f6a70610ce498e7685de8ea2e0f1648f01b327f6bac63", + strip_prefix = "installation", + url = "https://www.qnx.com/download/download/79858/installation.tgz", +) +use_repo(toolchains_qnx, "toolchains_qnx_sdp") +use_repo(toolchains_qnx, "toolchains_qnx_qcc") + +#gcc toolchain for baselibs +bazel_dep(name = "score_toolchains_gcc", version = "0.5", dev_dependency=False) +gcc = use_extension("@score_toolchains_gcc//extentions:gcc.bzl", "gcc", dev_dependency=False) +gcc.toolchain( + url = "https://github.com/eclipse-score/toolchains_gcc_packages/releases/download/0.0.1/x86_64-unknown-linux-gnu_gcc12.tar.gz", + sha256 = "457f5f20f57528033cb840d708b507050d711ae93e009388847e113b11bf3600", + strip_prefix = "x86_64-unknown-linux-gnu", +) +gcc.extra_features( + features = [ + "minimal_warnings", + "treat_warnings_as_errors", + ], +) +gcc.warning_flags( + minimal_warnings = ["-Wall", "-Wno-error=deprecated-declarations", "-Wno-error=narrowing"], + strict_warnings = ["-Wextra", "-Wpedantic"], + treat_warnings_as_errors = ["-Werror"], +) +use_repo(gcc, "gcc_toolchain", "gcc_toolchain_gcc") +register_toolchains("@gcc_toolchain//:all") + +# LLVM Toolchains +bazel_dep(name = "toolchains_llvm", version = "1.2.0") # persistency module uses 1.2.0 and does not work with 1.4.0 yet +llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") +llvm.toolchain( + cxx_standard = {"": "c++17"}, + llvm_version = "19.1.0", +) +use_repo(llvm, "llvm_toolchain") +use_repo(llvm, "llvm_toolchain_llvm") + +register_toolchains("@llvm_toolchain//:all") + +## needed additions to build +bazel_dep(name = "testing-utils") +git_override( + module_name = "testing-utils", + commit = "a847c7464cfa47e000141631d1223b92560d2e58", # tag v0.2.0 + remote = "https://github.com/qorix-group/testing_tools.git", +) + +# # TODO: What is this for? +archive_override( + module_name = "rules_boost", + strip_prefix = "rules_boost-master", + urls = ["https://github.com/nelhage/rules_boost/archive/refs/heads/master.tar.gz"], +) + +# # TODO: we cannot use communication without including TRLC here? +bazel_dep(name = "trlc", version = "0.0.0") +git_override( + module_name = "trlc", + remote = "https://github.com/bmw-software-engineering/trlc.git", + commit = "650b51a47264a4f232b3341f473527710fc32669", # trlc-2.0.2 release +) + +# System/Basics + +## Python +bazel_dep(name = "rules_python", version = "1.4.1") + +PYTHON_VERSION = "3.12" + +python = use_extension("@rules_python//python/extensions:python.bzl", "python") +python.toolchain( + configure_coverage_tool = True, + is_default = True, + python_version = PYTHON_VERSION, +) +use_repo(python) diff --git a/README.md b/README.md index 9a09bd208..99cc231ae 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,122 @@ -# reference_integration -Score project integration repository +# Reference Integration + +Integration workspace for the Eclipse Score project. This repository is used to validate cross-module builds (e.g. baselibs, communication, persistency, feo, etc.) from a single Bazel workspace. + +## โœ… Working Build Commands + +### Baselibs + +```bash +bazel build --config bl-x86_64-linux @score-baselibs//score/... --verbose_failures +``` + +### Communication + +```bash +bazel build --config bl-x86_64-linux @communication//score/... @communication//third_party/... --verbose_failures +``` + +### Persistency + +```bash +bazel build \ + @score_persistency//src/... \ + @score_persistency//tests/cpp_test_scenarios/... \ + @score_persistency//tests/rust_test_scenarios/... \ + --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux \ + --copt=-Wno-deprecated-declarations \ + --verbose_failures +``` + +> Note: Python tests for `@score_persistency` cannot be built from this integration workspace due to Bazel external repository visibility limitations. The pip extension and Python dependencies must be accessed within their defining module. + +## โš ๏ธ Observed Issues + +### communication: score/mw/com/requirements +Problems when building from a different repo: +- Some `BUILD` files use `@//third_party` instead of `//third_party` (repository-qualified vs. local label mismatch). +- `runtime_test.cpp:get_path` is checking `safe_posix_platform` (likely an outdated module name) instead of `external/communication+/`. +- fixed in feature/build_from_reference_repo https://github.com/etas-contrib/score_communication.git + +### communication: get_git_info +@communication//third_party/... here get_git_info is causing problems because it cannot find github root from e.g. +/home/runner/.bazel/sandbox/processwrapper-sandbox/1689/execroot/_main/bazel-out/k8-opt-exec-ST-8abfa5a323e1/bin/external/communication+/third_party/traceability/tools/source_code_linker/parsed_source_files_for_source_code_linker.runfiles/communication+/third_party/traceability/tools/source_code_linker/get_git_info.py +is this needed? should we fix it? + +### Toolchain / Version Drift +- Persistency uses `llvm_toolchain 1.2.0` while baselibs uses `1.4.0`. Aligning versions may reduce incompatibilities. Also Persistency does not work with `1.4.0`. + +## ๐Ÿšง Not Yet Working + +```bash +bazel build @score_persistency//src/cpp/... --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux + +bazel build @feo//... --verbose_failures +``` + + +```bash +bazel mod graph +``` +It is working with latest baselibs (dev_dependency = True for score_toolchains_qnx), but communication is not building with it. + +### Missing System Packages (for feo build) +Install required system dependencies: +```bash +sudo apt-get update +sudo apt-get install -y protobuf-compiler libclang-dev +``` + +## ๐Ÿงช To Be Done + +```bash +bazel test @itf//... +``` + +Add test targets once cross-repo visibility constraints are clarified. + +Configuration handling (instead of baselibs.bazelrc,...) + +## ๐ŸŒ Proxy & Dependency Handling + +`starpls.bzl` (see: https://github.com/eclipse-score/tooling/blob/main/starpls/starpls.bzl) uses `curl` directly, which: +- Bypasses Bazel's fetch/dependency tracking. +- May fail in a proxy-restricted environment. + +### Possible Workaround +Use a `local_path_override` and set proxy environment variables before invoking the rule: + +```bash +export http_proxy=http://127.0.0.1:3128 +export https_proxy=http://127.0.0.1:3128 +export HTTP_PROXY=http://127.0.0.1:3128 +export HTTPS_PROXY=http://127.0.0.1:3128 +``` + +Example Bazel module override snippet: +```python +local_path_override(module_name = "score_tooling", path = "../tooling") +``` + +### Suggested Improvements +- Replace raw `curl` calls with Bazel `http_archive` or `repository_ctx.download` for reproducibility. +- Parameterize proxy usage via environment or Bazel config flags. + +## ๐Ÿ” Next Investigation Targets +- Normalize third-party label usage (`@//third_party` vs `//third_party`). +- Update `runtime_test.cpp:get_path` logic for new module layout. +- Unify LLVM toolchain versions across modules. +- Introduce integration tests for `@itf` once build succeeds. + +## ๐Ÿ“Œ Quick Reference + +| Area | Status | Action | +|------|--------|--------| +| baselibs build | โœ… | Keep as baseline | +| communication build | โœ… | Fix label style inconsistencies | +| persistency (Python tests) | ๐Ÿšซ | Not supported cross-repo | +| feo build | โŒ | Install system deps + inspect failures | +| itf tests | โณ | Add after build stabilization | + +## ๐Ÿ—‚ Notes +Keep this file updated as integration issues are resolved. Prefer converting ad-hoc shell steps into Bazel rules or documented scripts under `tools/` for repeatability. diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1 @@ +# placeholder diff --git a/integration_test.sh b/integration_test.sh new file mode 100755 index 000000000..75da1b4fc --- /dev/null +++ b/integration_test.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash +set -euox pipefail + +# Integration build script. +# Captures warning counts for regression tracking. + +CONFIG=${CONFIG:-bl-x86_64-linux} +LOG_DIR=${LOG_DIR:-_logs/logs} +SUMMARY_FILE=${SUMMARY_FILE:-_logs/build_summary.md} +mkdir -p "${LOG_DIR}" || true + +declare -A BUILD_TARGET_GROUPS=( + [baselibs]="@score-baselibs//score/..." + [communication]="@communication//score/... @communication//third_party/..." + [persistency]="@score_persistency//src/... @score_persistency//tests/cpp_test_scenarios/... @score_persistency//tests/rust_test_scenarios/..." + [score-mw-log]="@score-mw-log//src/..." +) + +warn_count() { + # Grep typical compiler and Bazel warnings; adjust patterns as needed. + local file=$1 + # Count lines with 'warning:' excluding ones from system headers optionally later. + grep -i 'warning:' "$file" | wc -l || true +} + +depr_count() { + local file=$1 + grep -i 'deprecated' "$file" | wc -l || true +} + +timestamp() { date '+%Y-%m-%d %H:%M:%S'; } + +echo "=== Integration Build Started $(timestamp) ===" | tee "${SUMMARY_FILE}" +echo "Config: ${CONFIG}" | tee -a "${SUMMARY_FILE}" +echo "" >> "${SUMMARY_FILE}" +echo "## Build Groups Summary" >> "${SUMMARY_FILE}" +echo "" >> "${SUMMARY_FILE}" +# Markdown table header +{ + echo "| Group | Status | Duration (s) | Warnings | Deprecated refs |"; + echo "|-------|--------|--------------|----------|-----------------|"; +} >> "${SUMMARY_FILE}" + +overall_warn_total=0 +overall_depr_total=0 + +for group in "${!BUILD_TARGET_GROUPS[@]}"; do + targets="${BUILD_TARGET_GROUPS[$group]}" + log_file="${LOG_DIR}/${group}.log" + # Log build group banner only to stdout/stderr (not into summary table file) + echo "--- Building group: ${group} ---" + # GitHub Actions log grouping start + echo "::group::Bazel build (${group})" + start_ts=$(date +%s) + if [[ "$group" == "persistency" ]]; then + # Extra flags only for persistency group. + set +e + bazel build --config "${CONFIG}" \ + ${targets} \ + --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux \ + --copt=-Wno-deprecated-declarations \ + --verbose_failures 2>&1 | tee "$log_file" + build_status=${PIPESTATUS[0]} + set -e + else + set +e + bazel build --config "${CONFIG}" ${targets} --verbose_failures 2>&1 | tee "$log_file" + build_status=${PIPESTATUS[0]} + set -e + fi + echo "::endgroup::" # End Bazel build group + end_ts=$(date +%s) + duration=$(( end_ts - start_ts )) + w_count=$(warn_count "$log_file") + d_count=$(depr_count "$log_file") + overall_warn_total=$(( overall_warn_total + w_count )) + overall_depr_total=$(( overall_depr_total + d_count )) + # Append as a markdown table row (duration without trailing 's') + if [[ ${build_status} -eq 0 ]]; then + status_symbol="โœ…" + else + status_symbol="โŒ(${build_status})" + fi + echo "| ${group} | ${status_symbol} | ${duration} | ${w_count} | ${d_count} |" | tee -a "${SUMMARY_FILE}" +done + +# Append aggregate totals row to summary table +echo "| TOTAL | | | ${overall_warn_total} | ${overall_depr_total} |" >> "${SUMMARY_FILE}" + +# Display the full build summary explicitly at the end +echo '::group::Build Summary' +echo '=== Build Summary (echo) ===' +cat "${SUMMARY_FILE}" || echo "(Could not read summary file ${SUMMARY_FILE})" +echo '::endgroup::' + +exit 0 \ No newline at end of file diff --git a/known_good.json b/known_good.json new file mode 100644 index 000000000..80969b5bd --- /dev/null +++ b/known_good.json @@ -0,0 +1,38 @@ +{ + "timestamp": "2025-08-13T12:55:10Z", + "modules": [ + { + "name": "score-baselibs", + "hash": "5b3a469d80c6480f633ffc789ffb1277ee89fd7f", + "repo": "https://github.com/etas-contrib/score_baselibs.git" + }, + { + "name": "score-mw-log", + "hash": "fffdb25cd7784c46a4e6d72b46309790f1fcd9ed", + "repo": "https://github.com/eclipse-score/logging.git" + }, + { + "name": "score_persistency", + "hash": "c3b737bb45ba9ddc9db0a3940ab2490c75fc3c02", + "repo": "https://github.com/eclipse-score/persistency.git" + }, + { + "name": "inc_orchestrator", + "hash": "9f8ed482bdf786117eb3c4c1be14a1ee58a120ab", + "repo": "https://github.com/eclipse-score/inc_orchestrator.git" + }, + { + "name": "communication", + "hash": "f9db227e7e78be748dbd07090886739da38d004c", + "repo": "https://github.com/etas-contrib/score_communication.git" + }, + { + "name": "score_tooling", + "hash": "b8f58954485d8a19856a3aacdc69a6cbdd12972d", + "repo": "https://github.com/eclipse-score/tooling.git" + } + ], + "manifest_sha256": "4c9b7f...", + "suite": "full", + "duration_s": 742 +} \ No newline at end of file diff --git a/score_modules.MODULE.bazel b/score_modules.MODULE.bazel new file mode 100644 index 000000000..0fb42c4cc --- /dev/null +++ b/score_modules.MODULE.bazel @@ -0,0 +1,54 @@ +# will be generated from known-good.json by script later + +# Dependencies for integration + +## --- baselibs --- +bazel_dep(name = "score-baselibs", version = "0.0.0") +git_override( + module_name = "score-baselibs", + remote = "https://github.com/etas-contrib/score_baselibs.git", + commit = "5b3a469d80c6480f633ffc789ffb1277ee89fd7f", + # TODO: change to eclipse-score repo and a proper commit +) + +## --- logging --- +bazel_dep(name = "score-mw-log", version = "0.0.0") +git_override( + module_name = "score-mw-log", + remote = "https://github.com/eclipse-score/logging.git", + # 2025-10-24 + commit = "fffdb25cd7784c46a4e6d72b46309790f1fcd9ed", +) + +## --- persistency --- +bazel_dep(name = "score_persistency", version = "0.0.0") +git_override( + module_name = "score_persistency", + remote = "https://github.com/eclipse-score/persistency.git", + commit = "c3b737bb45ba9ddc9db0a3940ab2490c75fc3c02", +) + +## --- orchestration --- +bazel_dep(name = "inc_orchestrator", version = "0.0.0") +git_override( + module_name = "inc_orchestrator", + remote = "https://github.com/eclipse-score/inc_orchestrator.git", + commit = "9f8ed482bdf786117eb3c4c1be14a1ee58a120ab", +) + +## --- communication --- +bazel_dep(name = "communication", version = "0.0.0") +git_override( + module_name = "communication", + remote = "https://github.com/etas-contrib/score_communication.git", + commit = "f9db227e7e78be748dbd07090886739da38d004c", + # TODO: change to eclipse-score repo and a proper commit +) + +# Tooling +bazel_dep(name = "score_tooling", version = "0.0.0") +git_override( + module_name = "score_tooling", + remote = "https://github.com/eclipse-score/tooling.git", + commit = "b8f58954485d8a19856a3aacdc69a6cbdd12972d", +)