From 8a63f474690aa34383dfa5adc7818407c4ec8715 Mon Sep 17 00:00:00 2001 From: Pawel Rutka Date: Fri, 27 Feb 2026 09:29:36 +0100 Subject: [PATCH] Use showcase from single place and adapt docker runner --- .github/workflows/build_and_test_autosd.yml | 6 ++-- .vscode/settings.json | 7 ++++- MODULE.bazel | 15 ++-------- bazel_common/bundlers.bzl | 5 +++- bazel_common/score_images.MODULE.bazel | 18 +++++++++++ feature_integration_tests/itf/BUILD | 4 +-- images/autosd_x86_64/BUILD.bazel | 33 ++++++++++++++------- images/autosd_x86_64/build/image.aib.yml | 20 ++++++------- images/linux_x86_64/BUILD | 29 +++++------------- images/qnx_x86_64/build/BUILD | 4 +-- images/qnx_x86_64/build/system.build | 2 +- runners/docker_x86_64/scripts/run_docker.sh | 19 ++++++++---- runners/qemu_x86_64/scripts/run_qemu.sh | 13 +++++--- showcases/BUILD | 3 +- 14 files changed, 106 insertions(+), 72 deletions(-) create mode 100644 bazel_common/score_images.MODULE.bazel diff --git a/.github/workflows/build_and_test_autosd.yml b/.github/workflows/build_and_test_autosd.yml index 9bcead89de..03f50a2d83 100644 --- a/.github/workflows/build_and_test_autosd.yml +++ b/.github/workflows/build_and_test_autosd.yml @@ -43,11 +43,13 @@ jobs: run: | bazel build --config autosd-x86_64 //images/autosd_x86_64:image working-directory: ./images/autosd_x86_64 - - name: Copy showcases_all folder + - name: Copy showcases folder run: | set -e mkdir -p ./images/autosd_x86_64/build/rpms - cp -R bazel-bin/showcases/showcases_all ./images/autosd_x86_64/build/files/ + ls -la bazel-bin/showcases + ls -la bazel-bin/ + cp -R bazel-bin/showcases ./images/autosd_x86_64/build/files/ - name: Install AIB Tools run: | curl -o auto-image-builder.sh "https://gitlab.com/CentOS/automotive/src/automotive-image-builder/-/raw/main/auto-image-builder.sh?ref_type=heads" diff --git a/.vscode/settings.json b/.vscode/settings.json index 63fd298329..d3f4ffa531 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,5 +9,10 @@ "feature_integration_tests" ], "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true + "python.testing.pytestEnabled": true, + "search.exclude": { + "./build/**": true, + "./bazel-*/**": true, + "**/*.orig": true, + } } diff --git a/MODULE.bazel b/MODULE.bazel index 1c21842342..a9ccd47162 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -37,6 +37,9 @@ include("//bazel_common:score_modules_tooling.MODULE.bazel") # Score modules include("//bazel_common:score_modules_target_sw.MODULE.bazel") +# Score test images +include("//bazel_common:score_images.MODULE.bazel") + bazel_dep(name = "rules_boost", repo_name = "com_github_nelhage_rules_boost") archive_override( module_name = "rules_boost", @@ -68,15 +71,3 @@ toolchains_qnx.sdp( ) use_repo(toolchains_qnx, "toolchains_qnx_sdp") use_repo(toolchains_qnx, "toolchains_qnx_ifs") - -bazel_dep(name = "rules_oci", version = "1.8.0") - -oci = use_extension("@rules_oci//oci:extensions.bzl", "oci") -oci.pull( - name = "ubuntu_22_04", - digest = "sha256:3ba65aa20f86a0fad9df2b2c259c613df006b2e6d0bfcc8a146afb8c525a9751", - image = "ubuntu", - platforms = ["linux/amd64"], - tag = "22.04", -) -use_repo(oci, "ubuntu_22_04") diff --git a/bazel_common/bundlers.bzl b/bazel_common/bundlers.bzl index 173116d577..2bda48c266 100644 --- a/bazel_common/bundlers.bzl +++ b/bazel_common/bundlers.bzl @@ -10,7 +10,7 @@ # # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") +load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_files") load("@rules_pkg//pkg:pkg.bzl", "pkg_tar") def score_pkg_bundle(name, bins, config_data = None, package_dir = None, other_package_files = [], custom_layout = {}): @@ -69,6 +69,9 @@ def score_pkg_bundle(name, bins, config_data = None, package_dir = None, other_p srcs = bins + config_data_arr + list(custom_layout.keys()), renames = rename_dict, visibility = ["//visibility:public"], + attributes = pkg_attributes( + mode = "0755", # Simplify setup for now doing all executables + ), ) # Step 2: pkg_tar diff --git a/bazel_common/score_images.MODULE.bazel b/bazel_common/score_images.MODULE.bazel new file mode 100644 index 0000000000..edb236d0fa --- /dev/null +++ b/bazel_common/score_images.MODULE.bazel @@ -0,0 +1,18 @@ +bazel_dep(name = "rules_oci", version = "1.8.0") + +oci = use_extension("@rules_oci//oci:extensions.bzl", "oci") +oci.pull( + name = "ubuntu_22_04", + digest = "sha256:3ba65aa20f86a0fad9df2b2c259c613df006b2e6d0bfcc8a146afb8c525a9751", + image = "ubuntu", + platforms = ["linux/amd64"], + tag = "22.04", +) +oci.pull( + name = "centos_stream10", + digest = "sha256:01858c09da8f130c718c37673b83aaaf65c6493e66f4c674caffcffe9ed4c225", + image = "quay.io/centos/centos", + platforms = ["linux/amd64"], + tag = "stream10", +) +use_repo(oci, "centos_stream10", "ubuntu_22_04") diff --git a/feature_integration_tests/itf/BUILD b/feature_integration_tests/itf/BUILD index b796b26948..cf3c3cf78b 100644 --- a/feature_integration_tests/itf/BUILD +++ b/feature_integration_tests/itf/BUILD @@ -27,11 +27,11 @@ py_itf_test( ":all_tests", ], args = [ - "--docker-image-bootstrap=$(location //images/linux_x86_64:docker_image_tarball)", + "--docker-image-bootstrap=$(location //images/linux_x86_64:image_tarball)", "--docker-image=score_showcases:latest", ], data = [ - "//images/linux_x86_64:docker_image_tarball", + "//images/linux_x86_64:image_tarball", ], plugins = [ docker, diff --git a/images/autosd_x86_64/BUILD.bazel b/images/autosd_x86_64/BUILD.bazel index e452f00f97..2ad9c033bf 100644 --- a/images/autosd_x86_64/BUILD.bazel +++ b/images/autosd_x86_64/BUILD.bazel @@ -1,3 +1,5 @@ +load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball") + # ******************************************************************************* # Copyright (c) 2024 Contributors to the Eclipse Foundation # @@ -12,16 +14,10 @@ # ******************************************************************************* load("@rules_rpm//:defs.bzl", "rpm_package") -alias( - name = "image", - actual = "//showcases:showcases_all", - visibility = ["//visibility:public"], -) - rpm_package( name = "score-showcases", data = [ - "//showcases:showcases_all", + "//showcases", ], data_dir = "/usr/share/score/examples", description = "Eclipse S-CORE Reference Integration Showcases", @@ -33,12 +29,29 @@ sh_binary( name = "run", srcs = ["//runners/docker_x86_64/scripts:run_docker.sh"], args = [ - "$(location :image)", + "$(location :image_tarball)", ], data = [ - ":image", + ":image_tarball", ], env = { - "OCI_IMAGE": "quay.io/centos/centos:stream10", + "OCI_IMAGE": "score_showcases_autosd:latest", }, ) + +oci_image( + name = "image", + base = "@centos_stream10", + tars = [ + "//showcases:showcases_pkg_tar", + ], +) + +oci_tarball( + name = "image_tarball", + image = ":image", + repo_tags = ["score_showcases_autosd:latest"], + visibility = [ + "//feature_integration_tests/itf:__pkg__", + ], +) diff --git a/images/autosd_x86_64/build/image.aib.yml b/images/autosd_x86_64/build/image.aib.yml index 5fdd8e0598..0c5c3cb352 100644 --- a/images/autosd_x86_64/build/image.aib.yml +++ b/images/autosd_x86_64/build/image.aib.yml @@ -65,36 +65,36 @@ content: - path: /usr/bin/lola-ipc-test source_path: files/lola-ipc-test # showcases - - path: /usr/share/score/examples/showcases_all - source_glob: "files/showcases_all/**/*" + - path: /usr/share/score/examples/ + source_glob: "files/showcases/**/*" preserve_path: true max_files: 50 chmod_files: - path: /usr/bin/lola-ipc-test mode: "0755" # the following is a workaround because copied files lost their permissions - - path: /usr/share/score/examples/showcases_all/bin/cli + - path: /usr/share/score/examples/showcases/showcases/bin/cli mode: "0755" recursive: true - - path: /usr/share/score/examples/showcases_all/bin/control_daemon + - path: /usr/share/score/examples/showcases/showcases/bin/control_daemon mode: "0755" recursive: true - - path: /usr/share/score/examples/showcases_all/bin/cpp_supervised_app + - path: /usr/share/score/examples/showcases/showcases/bin/cpp_supervised_app mode: "0755" recursive: true - - path: /usr/share/score/examples/showcases_all/bin/ipc_bridge_cpp + - path: /usr/share/score/examples/showcases/showcases/bin/ipc_bridge_cpp mode: "0755" recursive: true - - path: /usr/share/score/examples/showcases_all/bin/launch_manager + - path: /usr/share/score/examples/showcases/showcases/bin/launch_manager mode: "0755" recursive: true - - path: /usr/share/score/examples/showcases_all/bin/lifecycle_signal.sh + - path: /usr/share/score/examples/showcases/showcases/bin/lifecycle_signal.sh mode: "0755" recursive: true - - path: /usr/share/score/examples/showcases_all/bin/orch_per_example + - path: /usr/share/score/examples/showcases/showcases/bin/orch_per_example mode: "0755" recursive: true - - path: /usr/share/score/examples/showcases_all/bin/rust_supervised_app + - path: /usr/share/score/examples/showcases/showcases/bin/rust_supervised_app mode: "0755" recursive: true # Required for testing the image only: diff --git a/images/linux_x86_64/BUILD b/images/linux_x86_64/BUILD index 8dfaa879a5..61ac4d1bce 100644 --- a/images/linux_x86_64/BUILD +++ b/images/linux_x86_64/BUILD @@ -14,44 +14,31 @@ load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball") load("@rules_pkg//pkg:tar.bzl", "pkg_tar") load("@rules_shell//shell:sh_binary.bzl", "sh_binary") -alias( - name = "image", - actual = "//showcases:showcases_all", - visibility = ["//visibility:public"], -) - sh_binary( name = "run", srcs = ["//runners/docker_x86_64/scripts:run_docker.sh"], args = [ - "$(location :image)", + "$(location :image_tarball)", ], data = [ - ":image", + ":image_tarball", ], -) - -pkg_tar( - name = "showcases_archive", - srcs = [ - "//showcases:showcases_all", - ], - symlinks = { - "showcases": "showcases_all", + env = { + "OCI_IMAGE": "score_showcases:latest", }, ) oci_image( - name = "docker_image", + name = "image", base = "@ubuntu_22_04", tars = [ - ":showcases_archive", + "//showcases:showcases_pkg_tar", ], ) oci_tarball( - name = "docker_image_tarball", - image = ":docker_image", + name = "image_tarball", + image = ":image", repo_tags = ["score_showcases:latest"], visibility = [ "//feature_integration_tests/itf:__pkg__", diff --git a/images/qnx_x86_64/build/BUILD b/images/qnx_x86_64/build/BUILD index dea5102c10..897ebfd791 100644 --- a/images/qnx_x86_64/build/BUILD +++ b/images/qnx_x86_64/build/BUILD @@ -50,12 +50,12 @@ qnx_ifs( ":system.build", ":system_dir", "//feature_integration_tests/configs:etc_configs", - "//showcases:showcases_all", + "//showcases", "@score_persistency//tests/test_scenarios/cpp:test_scenarios", ], build_file = "init.build", ext_repo_maping = { - "BUNDLE_PATH": "$(location //showcases:showcases_all)", + "BUNDLE_PATH": "$(location //showcases:showcases)", }, visibility = [ "//visibility:public", diff --git a/images/qnx_x86_64/build/system.build b/images/qnx_x86_64/build/system.build index 40ea2ed862..bf1226f22d 100644 --- a/images/qnx_x86_64/build/system.build +++ b/images/qnx_x86_64/build/system.build @@ -285,5 +285,5 @@ pci/pci_debug2.so # Enhanced PCI debugging support [perms=777] /cpp_tests_persistency = ${CPP_TEST_SCENARIOS_PATH} # Common showcases bundle -[perms=777] /showcases = ${BUNDLE_PATH} +[perms=777] / = ${BUNDLE_PATH} diff --git a/runners/docker_x86_64/scripts/run_docker.sh b/runners/docker_x86_64/scripts/run_docker.sh index 3db33a2038..45ea3011ac 100755 --- a/runners/docker_x86_64/scripts/run_docker.sh +++ b/runners/docker_x86_64/scripts/run_docker.sh @@ -15,13 +15,22 @@ set -euo pipefail -OVERLAY_TREE=$1 -OVERLAY_ABS_PATH=$(realpath ${OVERLAY_TREE}) -OCI_IMAGE=${OCI_IMAGE:=ubuntu:22.04} +OCI_TARBALL_IMAGE_SCRIPT=$1 +OCI_TARBALL_IMAGE_SCRIPT_ABS_PATH=$(realpath ${OCI_TARBALL_IMAGE_SCRIPT}) -echo "Starting docker with overlay image: ${OVERLAY_ABS_PATH}" +if [ -z "${OCI_IMAGE:-}" ]; then + echo "Error: OCI_IMAGE environment variable is not set." + exit 1 +fi +OCI_IMAGE=${OCI_IMAGE:=score_showcases:latest} + + +echo "Starting docker with OCI image tarball at: ${OCI_TARBALL_IMAGE_SCRIPT_ABS_PATH}" + +${OCI_TARBALL_IMAGE_SCRIPT_ABS_PATH} + +echo "Running docker with image: ${OCI_IMAGE}" docker run --rm -it \ - -v "${OVERLAY_ABS_PATH}:/showcases" \ ${OCI_IMAGE} \ bash -c "/showcases/bin/cli; exec bash" diff --git a/runners/qemu_x86_64/scripts/run_qemu.sh b/runners/qemu_x86_64/scripts/run_qemu.sh index 403e6f62b0..6482d23266 100755 --- a/runners/qemu_x86_64/scripts/run_qemu.sh +++ b/runners/qemu_x86_64/scripts/run_qemu.sh @@ -16,13 +16,18 @@ set -euo pipefail QNX_HOST=$1 - IFS_IMAGE=$2 + +# Set KVM options based on QEMU_NO_KVM if user does not have kvm - like nested VMs +if [ -z "${QEMU_NO_KVM:-}" ]; then + QEMU_KVM_OPTS="-enable-kvm -smp 2 -cpu host" +else + QEMU_KVM_OPTS="-smp 2 -cpu Cascadelake-Server-v5" +fi + echo "Starting QEMU with IFS image: ${IFS_IMAGE}" qemu-system-x86_64 \ - -enable-kvm \ - -smp 2 \ - -cpu host\ + ${QEMU_KVM_OPTS} \ -m 1G \ -pidfile /tmp/qemu.pid \ -nographic \ diff --git a/showcases/BUILD b/showcases/BUILD index 3fd3cd19ab..514b36add0 100644 --- a/showcases/BUILD +++ b/showcases/BUILD @@ -13,7 +13,7 @@ load("//bazel_common:bundlers.bzl", "score_pkg_bundle") score_pkg_bundle( - name = "showcases_all", + name = "showcases", bins = ["//showcases/cli"], other_package_files = [ "//showcases/standalone:comm_pkg_files", @@ -21,4 +21,5 @@ score_pkg_bundle( "//showcases/orchestration_persistency:orch_per_pkg_files", "//showcases/simple_lifecycle:simple_lifecycle_pkg_files", ], + package_dir = "showcases", )