From 0127faa5815f07eb391efca79e07920d3562a043 Mon Sep 17 00:00:00 2001 From: Ivano Matrisciano Date: Wed, 15 Jul 2026 10:11:02 +0200 Subject: [PATCH] chore(plugins)!: remove Matter SDK plugin --- .github/workflows/spread-manual.yaml | 34 ---- docs/explanation/cryptography.rst | 4 - docs/reference/plugins.rst | 1 - docs/reference/plugins/matter_sdk_plugin.rst | 110 ------------ snapcraft/parts/lifecycle.py | 2 +- snapcraft/parts/plugins/__init__.py | 2 - snapcraft/parts/plugins/matter_sdk_plugin.py | 163 ------------------ snapcraft/parts/plugins/register.py | 2 - .../spread/_common/matter-sdk/snapcraft.yaml | 46 ----- tests/spread/_common/matter-sdk/task.yaml | 47 ----- .../plugins/matter-sdk/snapcraft.yaml | 46 ----- .../plugins/matter-sdk/task.yaml | 40 ----- tests/spread/core26/matter-sdk | 1 - .../craft-parts/matter-sdk/snapcraft.yaml | 48 ------ .../plugins/craft-parts/matter-sdk/task.yaml | 43 ----- .../parts/plugins/test_matter_sdk_plugin.py | 116 ------------- tests/unit/parts/test_lifecycle.py | 23 +-- 17 files changed, 3 insertions(+), 725 deletions(-) delete mode 100644 docs/reference/plugins/matter_sdk_plugin.rst delete mode 100644 snapcraft/parts/plugins/matter_sdk_plugin.py delete mode 100644 tests/spread/_common/matter-sdk/snapcraft.yaml delete mode 100644 tests/spread/_common/matter-sdk/task.yaml delete mode 100644 tests/spread/core24-suites/plugins/matter-sdk/snapcraft.yaml delete mode 100644 tests/spread/core24-suites/plugins/matter-sdk/task.yaml delete mode 120000 tests/spread/core26/matter-sdk delete mode 100644 tests/spread/plugins/craft-parts/matter-sdk/snapcraft.yaml delete mode 100644 tests/spread/plugins/craft-parts/matter-sdk/task.yaml delete mode 100644 tests/unit/parts/plugins/test_matter_sdk_plugin.py diff --git a/.github/workflows/spread-manual.yaml b/.github/workflows/spread-manual.yaml index 3e05a7f9d3..46518aa664 100644 --- a/.github/workflows/spread-manual.yaml +++ b/.github/workflows/spread-manual.yaml @@ -132,40 +132,6 @@ jobs: spread google:ubuntu-22.04-64:tests/spread/core22/remote-build \ google:ubuntu-24.04-64:tests/spread/core24/remote-build \ google:fedora-39-64:tests/spread/core24/remote-build:no_platforms - - - name: Discard spread workers - if: always() - run: | - shopt -s nullglob - for r in .spread-reuse.*.yaml; do - spread -discard -reuse-pid="$(echo "$r" | grep -o -E '[0-9]+')" - done - - matter-sdk: - needs: [predicate, snap-build] - if: needs.predicate.outputs.should_run == 'true' - runs-on: [spread-installed] - steps: - - name: Cleanup job workspace - run: | - rm -rf "${{ github.workspace }}" - mkdir "${{ github.workspace }}" - - name: Checkout snapcraft - uses: actions/checkout@v7 - with: - fetch-depth: 0 - submodules: true - - name: Download snap artifact - uses: actions/download-artifact@v8 - with: - name: snap - path: tests - - name: matter-sdk test - run: | - spread \ - google:ubuntu-22.04-64:tests/spread/plugins/craft-parts/matter-sdk \ - google:ubuntu-22.04-64:tests/spread/core24-suites/plugins/matter-sdk - - name: Discard spread workers if: always() run: | diff --git a/docs/explanation/cryptography.rst b/docs/explanation/cryptography.rst index bf634757c0..72dc849467 100644 --- a/docs/explanation/cryptography.rst +++ b/docs/explanation/cryptography.rst @@ -53,10 +53,6 @@ build tools, and which build tools they use to download and verify dependencies. - ``flutter`` - Git - * - :ref:`Matter SDK ` - - ``matter`` - - Git - core22 ------ diff --git a/docs/reference/plugins.rst b/docs/reference/plugins.rst index 53f5611d0e..b6b2ba374d 100644 --- a/docs/reference/plugins.rst +++ b/docs/reference/plugins.rst @@ -29,7 +29,6 @@ This section contains an in-depth description of the plugins available in Snapcr /common/craft-parts/reference/plugins/jlink_plugin plugins/kernel_plugin /common/craft-parts/reference/plugins/make_plugin - plugins/matter_sdk_plugin plugins/maven_plugin /common/craft-parts/reference/plugins/maven_use_plugin /common/craft-parts/reference/plugins/meson_plugin diff --git a/docs/reference/plugins/matter_sdk_plugin.rst b/docs/reference/plugins/matter_sdk_plugin.rst deleted file mode 100644 index e3df14beff..0000000000 --- a/docs/reference/plugins/matter_sdk_plugin.rst +++ /dev/null @@ -1,110 +0,0 @@ -.. _reference_matter_sdk_plugin: - -Matter SDK plugin -================= - -.. admonition:: Experimental - :class: important - - The Matter SDK plugin is experimental and subject to change. It can only be used - by setting the ``--enable-experimental-plugins`` flag during a build. - -.. note:: - - This plugin is only available on snaps with base core22 or higher. See - :ref:`base-snaps` for more details. It is supported on Snapcraft 8.1.0 and later. - -The Matter SDK plugin simplifies the building of parts that use the `connectedhomeip -`_ Matter SDK. It abstracts away SDK -setup and configuration when creating a snapped Matter application. - - -Keys ----- - -This plugin provides one unique key. - - -matter-sdk-version -~~~~~~~~~~~~~~~~~~ - -**Type**: string - -*Required* - -The Matter SDK version the plugin will use. This value must match one of the `existing -tags ` in the SDK repository. - - -Dependencies ------------- - -This plugin has no dependencies. - - -How it works ------------- - -The project file for a snap using this plugin should include the following: - - -Plugin part -~~~~~~~~~~~ - -Bootstrapping the SDK requires resource-intensive operations such as cloning several -repositories and building the various artifacts. To save resources and allow for caching -while iterating over the application build, the plugin should be used in a standalone -part. For example: - -.. code-block:: yaml - :caption: snapcraft.yaml - - parts: - matter-sdk: - plugin: matter-sdk - matter-sdk-version: v1.3.0.0 - - -Application part -~~~~~~~~~~~~~~~~ - -The application's part should be built after staging the SDK. - -The application can use any of the existing :ref:`Snapcraft plugins -`, but it must be made aware of the directories where the SDK was -built. This can be done by sourcing the bash script generated by the Matter SDK plugin -at ``$CRAFT_STAGE/matter-sdk-env.sh``. For example: - -.. code-block:: yaml - :caption: snapcraft.yaml - - parts: - [...] - my-app: - after: - - matter-sdk - plugin: nil - override-build: | - # Prepare the environment for using the SDK - source $CRAFT_STAGE/matter-sdk-env.sh - - # Build the Matter application - [...] - - -Layout mapping -~~~~~~~~~~~~~~ - -The plugin changes the SDK's default paths from ``/tmp`` to ``/mnt`` for writing storage -and platform configurations. This allows applications to retain data across reboots. To -enable this functionality, declare the following layout to bind a writable directory -inside the snap to ``/mnt``. - -.. code-block:: yaml - :caption: snapcraft.yaml - - layout: - /mnt: - bind: $SNAP_COMMON/mnt - -For more details on defining layouts, refer to :ref:`reference-layouts`. diff --git a/snapcraft/parts/lifecycle.py b/snapcraft/parts/lifecycle.py index ce680b7d9a..3fd7459ba7 100644 --- a/snapcraft/parts/lifecycle.py +++ b/snapcraft/parts/lifecycle.py @@ -47,7 +47,7 @@ import argparse -_EXPERIMENTAL_PLUGINS = ["kernel", "initrd", "matter-sdk"] +_EXPERIMENTAL_PLUGINS = ["kernel", "initrd"] def run(command_name: str, parsed_args: "argparse.Namespace") -> None: diff --git a/snapcraft/parts/plugins/__init__.py b/snapcraft/parts/plugins/__init__.py index 054e74bbf4..c533826ef2 100644 --- a/snapcraft/parts/plugins/__init__.py +++ b/snapcraft/parts/plugins/__init__.py @@ -23,7 +23,6 @@ from .flutter_plugin import FlutterPlugin from .initrd_plugin import InitrdPlugin from .kernel_plugin import KernelPlugin -from .matter_sdk_plugin import MatterSdkPlugin from .poetry_plugin import PoetryPlugin from .python_plugin import PythonPlugin from .uv_plugin import UvPlugin @@ -33,7 +32,6 @@ "CondaPlugin", "FlutterPlugin", "InitrdPlugin", - "MatterSdkPlugin", "KernelPlugin", "PoetryPlugin", "PythonPlugin", diff --git a/snapcraft/parts/plugins/matter_sdk_plugin.py b/snapcraft/parts/plugins/matter_sdk_plugin.py deleted file mode 100644 index 036fbe288a..0000000000 --- a/snapcraft/parts/plugins/matter_sdk_plugin.py +++ /dev/null @@ -1,163 +0,0 @@ -# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- -# -# Copyright 2023-2024 Canonical Ltd. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 3 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -"""The matter SDK plugin.""" - -import os -from typing import Literal, cast - -from craft_parts import infos, plugins -from typing_extensions import override - -# The repository where the matter SDK resides. -MATTER_SDK_REPO = "https://github.com/project-chip/connectedhomeip" - - -class MatterSdkPluginProperties(plugins.PluginProperties, frozen=True): - """The part properties used by the matter SDK plugin.""" - - plugin: Literal["matter-sdk"] = "matter-sdk" - - matter_sdk_version: str - - -class MatterSdkPlugin(plugins.Plugin): - """A plugin for matter SDK project. - - This plugin uses the common plugin keywords. - For more information check the 'plugins' topic. - - Additionally, this plugin uses the following plugin-specific keywords: - - matter-sdk-version - (str, no default) - The matter SDK version to use for the build. - """ - - properties_class = MatterSdkPluginProperties - - def __init__( - self, - *, - properties: plugins.PluginProperties, - part_info: infos.PartInfo, - ) -> None: - super().__init__(properties=properties, part_info=part_info) - - self.matter_sdk_dir = part_info.part_build_dir - self.snap_arch = os.getenv("SNAP_ARCH") - - @override - def get_pull_commands(self) -> list[str]: - options = cast(MatterSdkPluginProperties, self._options) - commands = [] - - # Clone Matter SDK repository - commands.extend( - [ - " git init", - f" git remote add origin {MATTER_SDK_REPO}", - f" git fetch --depth 1 origin {options.matter_sdk_version}", - " git checkout FETCH_HEAD", - ] - ) - - # Checkout submodules for Linux platform - commands.extend(["scripts/checkout_submodules.py --shallow --platform linux"]) - - return commands - - @override - def get_build_packages(self) -> set[str]: - return { - "clang", - "cmake", - "generate-ninja", - "git", - "libavahi-client-dev", - "libcairo2-dev", - "libdbus-1-dev", - "libgirepository1.0-dev", - "libglib2.0-dev", - "libreadline-dev", - "libssl-dev", - "ninja-build", - "pkg-config", - "python3-dev", - "python3-pip", - "python3-venv", - "unzip", - "wget", - } - - @override - def get_build_environment(self) -> dict[str, str]: - return {} - - @override - def get_build_snaps(self) -> set[str]: - return set() - - @override - def get_build_commands(self) -> list[str]: - commands = [] - - # The project writes its data to /tmp which isn't persisted. - - # Setting TMPDIR env var when running the app isn't sufficient as - # chip_[config,counter,factory,kvs].ini still get written under /tmp. - # The chip-tool currently has no way of overriding the default paths to - # storage and security config files. - - # Snap does not allow bind mounting a persistent directory on /tmp, - # so we need to replace it in the source with another path, e.g. /mnt. - # The consumer snap needs to bind mount a persisted directory within - # the confined snap space on /mnt. - - # Replace storage paths - commands.extend( - [ - r"sed -i 's/\/tmp/\/mnt/g' src/platform/Linux/CHIPLinuxStorage.h", - r"sed -i 's/\/tmp/\/mnt/g' src/platform/Linux/CHIPPlatformConfig.h", - ] - ) - - # Store the initial value of PATH before executing the bootstrap script - commands.extend(["OLD_PATH=$PATH"]) - - # Bootstrapping script for building Matter SDK with minimal "build" requirements - # and setting up the environment. - commands.extend( - ["set +u && source scripts/setup/bootstrap.sh --platform build && set -u"] - ) - - commands.extend(["echo 'Built Matter SDK'"]) - - # Compare the difference between the original PATH and the modified PATH - commands.extend( - [ - 'MATTER_SDK_PATHS="${PATH%$OLD_PATH}"', - ] - ) - - # Prepend the Matter SDK related PATH to the beginning of the PATH environment variable, - # and save it to the staging area as matter-sdk-env.sh file. - commands.extend( - [ - 'echo "export PATH=$MATTER_SDK_PATHS\\$PATH" >> $CRAFT_STAGE/matter-sdk-env.sh', - ] - ) - - return commands diff --git a/snapcraft/parts/plugins/register.py b/snapcraft/parts/plugins/register.py index a313406c09..1b36c060a2 100644 --- a/snapcraft/parts/plugins/register.py +++ b/snapcraft/parts/plugins/register.py @@ -26,7 +26,6 @@ from .flutter_plugin import FlutterPlugin from .initrd_plugin import InitrdPlugin from .kernel_plugin import KernelPlugin -from .matter_sdk_plugin import MatterSdkPlugin def get_plugins(core22: bool) -> dict[str, PluginType]: @@ -40,7 +39,6 @@ def get_plugins(core22: bool) -> dict[str, PluginType]: "flutter": FlutterPlugin, "kernel": KernelPlugin, "initrd": InitrdPlugin, - "matter-sdk": MatterSdkPlugin, } | python_common.get_python_plugins() return plugins diff --git a/tests/spread/_common/matter-sdk/snapcraft.yaml b/tests/spread/_common/matter-sdk/snapcraft.yaml deleted file mode 100644 index fd2f527a03..0000000000 --- a/tests/spread/_common/matter-sdk/snapcraft.yaml +++ /dev/null @@ -1,46 +0,0 @@ -name: matter-lighting -summary: Matter plugin test -description: An lighting application to test the matter plugin. -version: "1.0" - -base: core24 - -grade: stable -confinement: strict - -layout: - /mnt: - bind: $SNAP_COMMON/mnt - -apps: - matter-lighting: - daemon: simple - command: bin/lighting-app - install-mode: disable - plugs: - - network - - network-bind - - bluez - - avahi-control - -parts: - matter-sdk: - plugin: matter-sdk - matter-sdk-version: "v1.4.0.0" - - lighting: - plugin: nil - after: [matter-sdk] - override-build: | - # Source the Matter SDK environment variables - source $CRAFT_STAGE/matter-sdk-env.sh - - # Build the lighting app for snapcraft spread testing purposes - cd ../../matter-sdk/build/examples/lighting-app/linux - gn gen out/build - ninja -C out/build - - ldd out/build/chip-lighting-app - - mkdir -p $CRAFT_PART_INSTALL/bin - cp out/build/chip-lighting-app $CRAFT_PART_INSTALL/bin/lighting-app diff --git a/tests/spread/_common/matter-sdk/task.yaml b/tests/spread/_common/matter-sdk/task.yaml deleted file mode 100644 index 78f61448d1..0000000000 --- a/tests/spread/_common/matter-sdk/task.yaml +++ /dev/null @@ -1,47 +0,0 @@ -summary: Matter SDK plugin test -kill-timeout: 180m - -manual: true - -prepare: | - #shellcheck source=tests/spread/tools/snapcraft-yaml.sh - . "$TOOLS_DIR/snapcraft-yaml.sh" - set_base "snapcraft.yaml" - -execute: | - # Build and install the snap - snapcraft pack - snap install "matter-lighting_1.0_amd64.snap" --dangerous - - start_time=$(date +"%Y-%m-%d %H:%M:%S") - snap start matter-lighting - - # wait for the snap to finish setting up - sleep 60 - - # Check if storage path replacement from /tmp to SNAP_COMMON/mnt works - for file in /tmp/chip_*; do - if [ -e "$file" ]; then - echo "Error: $file should not exist." - exit 1 - fi - done - - if ! find /var/snap/matter-lighting/common/mnt/ -maxdepth 1 -name "chip_*" | grep -q .; then - echo "Error: /var/snap/matter-lighting/common/mnt/chip_* does not exist." - exit 1 - fi - - # Check if server initialization is complete for matter-lighting - if ! journalctl --since "$start_time" | grep matter-lighting | grep "CHIP:SVR: Server initialization complete"; then - echo "Error: matter-lighting initialization failed." - exit 1 - fi - -restore: | - snapcraft clean - rm -f ./*.snap - - #shellcheck source=tests/spread/tools/snapcraft-yaml.sh - . "$TOOLS_DIR/snapcraft-yaml.sh" - restore_yaml "snapcraft.yaml" diff --git a/tests/spread/core24-suites/plugins/matter-sdk/snapcraft.yaml b/tests/spread/core24-suites/plugins/matter-sdk/snapcraft.yaml deleted file mode 100644 index fd2f527a03..0000000000 --- a/tests/spread/core24-suites/plugins/matter-sdk/snapcraft.yaml +++ /dev/null @@ -1,46 +0,0 @@ -name: matter-lighting -summary: Matter plugin test -description: An lighting application to test the matter plugin. -version: "1.0" - -base: core24 - -grade: stable -confinement: strict - -layout: - /mnt: - bind: $SNAP_COMMON/mnt - -apps: - matter-lighting: - daemon: simple - command: bin/lighting-app - install-mode: disable - plugs: - - network - - network-bind - - bluez - - avahi-control - -parts: - matter-sdk: - plugin: matter-sdk - matter-sdk-version: "v1.4.0.0" - - lighting: - plugin: nil - after: [matter-sdk] - override-build: | - # Source the Matter SDK environment variables - source $CRAFT_STAGE/matter-sdk-env.sh - - # Build the lighting app for snapcraft spread testing purposes - cd ../../matter-sdk/build/examples/lighting-app/linux - gn gen out/build - ninja -C out/build - - ldd out/build/chip-lighting-app - - mkdir -p $CRAFT_PART_INSTALL/bin - cp out/build/chip-lighting-app $CRAFT_PART_INSTALL/bin/lighting-app diff --git a/tests/spread/core24-suites/plugins/matter-sdk/task.yaml b/tests/spread/core24-suites/plugins/matter-sdk/task.yaml deleted file mode 100644 index 12a190c9ce..0000000000 --- a/tests/spread/core24-suites/plugins/matter-sdk/task.yaml +++ /dev/null @@ -1,40 +0,0 @@ -summary: Core24 matter SDK plugin test -manual: true -kill-timeout: 180m - -systems: - - ubuntu-22.04-64 - -restore: | - snapcraft clean - rm -f ./*.snap - -execute: | - # Build and install the snap - snapcraft pack - snap install "matter-lighting_1.0_amd64.snap" --dangerous - - start_time=$(date +"%Y-%m-%d %H:%M:%S") - snap start matter-lighting - - # wait for the snap to finish setting up - sleep 60 - - # Check if storage path replacement from /tmp to SNAP_COMMON/mnt works - for file in /tmp/chip_*; do - if [ -e "$file" ]; then - echo "Error: $file should not exist." - exit 1 - fi - done - - if ! find /var/snap/matter-lighting/common/mnt/ -maxdepth 1 -name "chip_*" | grep -q .; then - echo "Error: /var/snap/matter-lighting/common/mnt/chip_* does not exist." - exit 1 - fi - - # Check if server initialization is complete for matter-lighting - if ! journalctl --since "$start_time" | grep matter-lighting | grep "CHIP:SVR: Server initialization complete"; then - echo "Error: matter-lighting initialization failed." - exit 1 - fi diff --git a/tests/spread/core26/matter-sdk b/tests/spread/core26/matter-sdk deleted file mode 120000 index bd921ee517..0000000000 --- a/tests/spread/core26/matter-sdk +++ /dev/null @@ -1 +0,0 @@ -../_common/matter-sdk \ No newline at end of file diff --git a/tests/spread/plugins/craft-parts/matter-sdk/snapcraft.yaml b/tests/spread/plugins/craft-parts/matter-sdk/snapcraft.yaml deleted file mode 100644 index 73766084c8..0000000000 --- a/tests/spread/plugins/craft-parts/matter-sdk/snapcraft.yaml +++ /dev/null @@ -1,48 +0,0 @@ -name: matter-lighting -summary: Matter plugin test -description: An lighting application to test the matter plugin. -version: "1.0" - -base: core22 - -grade: stable -build-base: core22 -confinement: strict - -layout: - /mnt: - bind: $SNAP_COMMON/mnt - -apps: - matter-lighting: - daemon: simple - command: bin/lighting-app - install-mode: disable - plugs: - - network - - network-bind - - bluez - - avahi-control - -parts: - matter-sdk: - plugin: matter-sdk - matter-sdk-version: "1536ca20c5917578ca40ce509400e97b52751788" # use this commit with ptpython version fix; needs to be updated once matter sdk have a stable release - - lighting: - plugin: nil - after: [matter-sdk] - override-build: | - # Source the Matter SDK environment variables - source $CRAFT_STAGE/matter-sdk-env.sh - - # Build the lighting app for snapcraft spread testing purposes - cd ../../matter-sdk/build/examples/lighting-app/linux - gn gen out/build - ninja -C out/build - - ldd out/build/chip-lighting-app - - mkdir -p $CRAFT_PART_INSTALL/bin - cp out/build/chip-lighting-app $CRAFT_PART_INSTALL/bin/lighting-app - diff --git a/tests/spread/plugins/craft-parts/matter-sdk/task.yaml b/tests/spread/plugins/craft-parts/matter-sdk/task.yaml deleted file mode 100644 index 091d1a4309..0000000000 --- a/tests/spread/plugins/craft-parts/matter-sdk/task.yaml +++ /dev/null @@ -1,43 +0,0 @@ -summary: Craft Parts matter SDK plugin test -manual: true -kill-timeout: 180m - -systems: - - ubuntu-22.04-64 - -environment: - SNAPCRAFT_ENABLE_EXPERIMENTAL_PLUGINS: 1 - -restore: | - snapcraft clean - rm -f ./*.snap - -execute: | - # Build and install the snap - snapcraft pack - snap install "matter-lighting_1.0_amd64.snap" --dangerous - - start_time=$(date +"%Y-%m-%d %H:%M:%S") - snap start matter-lighting - - # wait for the snap to finish setting up - sleep 60 - - # Check if storage path replacement from /tmp to SNAP_COMMON/mnt works - for file in /tmp/chip_*; do - if [ -e "$file" ]; then - echo "Error: $file should not exist." - exit 1 - fi - done - - if ! find /var/snap/matter-lighting/common/mnt/ -maxdepth 1 -name "chip_*" | grep -q .; then - echo "Error: /var/snap/matter-lighting/common/mnt/chip_* does not exist." - exit 1 - fi - - # Check if server initialization is complete for matter-lighting - if ! journalctl --since "$start_time" | grep matter-lighting | grep "CHIP:SVR: Server initialization complete"; then - echo "Error: matter-lighting initialization failed." - exit 1 - fi diff --git a/tests/unit/parts/plugins/test_matter_sdk_plugin.py b/tests/unit/parts/plugins/test_matter_sdk_plugin.py deleted file mode 100644 index bd56e49930..0000000000 --- a/tests/unit/parts/plugins/test_matter_sdk_plugin.py +++ /dev/null @@ -1,116 +0,0 @@ -# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- -# -# Copyright 2023 Canonical Ltd. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License version 3 as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see . - - -import pytest -from craft_parts import Part, PartInfo, ProjectInfo - -from snapcraft.parts.plugins import MatterSdkPlugin - -# The repository where the matter SDK resides. -MATTER_SDK_REPO = "https://github.com/project-chip/connectedhomeip" - - -@pytest.fixture(autouse=True) -def part_info(new_dir): - yield PartInfo( - project_info=ProjectInfo( - application_name="test", project_name="test-snap", cache_dir=new_dir - ), - part=Part("my-part", {}), - ) - - -def test_get_pull_commands(part_info): - properties = MatterSdkPlugin.properties_class.unmarshal( - {"matter-sdk-version": "master"} - ) - plugin = MatterSdkPlugin(properties=properties, part_info=part_info) - - sdk_version = properties.matter_sdk_version - - expected_commands = [ - " git init", - f" git remote add origin {MATTER_SDK_REPO}", - f" git fetch --depth 1 origin {sdk_version}", - " git checkout FETCH_HEAD", - "scripts/checkout_submodules.py --shallow --platform linux", - ] - - assert plugin.get_pull_commands() == expected_commands - - -def test_get_build_snaps(part_info): - properties = MatterSdkPlugin.properties_class.unmarshal( - {"matter-sdk-version": "master"} - ) - plugin = MatterSdkPlugin(properties=properties, part_info=part_info) - assert plugin.get_build_snaps() == set() - - -def test_get_build_packages(part_info): - properties = MatterSdkPlugin.properties_class.unmarshal( - {"matter-sdk-version": "master"} - ) - plugin = MatterSdkPlugin(properties=properties, part_info=part_info) - assert plugin.get_build_packages() == { - "clang", - "cmake", - "generate-ninja", - "git", - "libavahi-client-dev", - "libcairo2-dev", - "libdbus-1-dev", - "libgirepository1.0-dev", - "libglib2.0-dev", - "libreadline-dev", - "libssl-dev", - "ninja-build", - "pkg-config", - "python3-dev", - "python3-pip", - "python3-venv", - "unzip", - "wget", - } - - -def test_get_build_environment(part_info): - properties = MatterSdkPlugin.properties_class.unmarshal( - {"matter-sdk-version": "master"} - ) - plugin = MatterSdkPlugin(properties=properties, part_info=part_info) - - assert plugin.get_build_environment() == {} - - -def test_get_build_commands(part_info): - properties = MatterSdkPlugin.properties_class.unmarshal( - {"matter-sdk-version": "master"} - ) - plugin = MatterSdkPlugin(properties=properties, part_info=part_info) - - expected_commands = [ - r"sed -i 's/\/tmp/\/mnt/g' src/platform/Linux/CHIPLinuxStorage.h", - r"sed -i 's/\/tmp/\/mnt/g' src/platform/Linux/CHIPPlatformConfig.h", - "OLD_PATH=$PATH", - "set +u && source scripts/setup/bootstrap.sh --platform build && set -u", - "echo 'Built Matter SDK'", - 'MATTER_SDK_PATHS="${PATH%$OLD_PATH}"', - 'echo "export PATH=$MATTER_SDK_PATHS\\$PATH" >> $CRAFT_STAGE/matter-sdk-env.sh', - ] - - assert plugin.get_build_commands() == expected_commands diff --git a/tests/unit/parts/test_lifecycle.py b/tests/unit/parts/test_lifecycle.py index bf89869652..3187de2186 100644 --- a/tests/unit/parts/test_lifecycle.py +++ b/tests/unit/parts/test_lifecycle.py @@ -35,7 +35,7 @@ from snapcraft.models import MANDATORY_ADOPTABLE_FIELDS, Project from snapcraft.parts import lifecycle as parts_lifecycle from snapcraft.parts import set_global_environment, yaml_utils -from snapcraft.parts.plugins import KernelPlugin, MatterSdkPlugin +from snapcraft.parts.plugins import KernelPlugin from snapcraft.parts.update_metadata import update_project_metadata _SNAPCRAFT_YAML_FILENAMES = [ @@ -1121,9 +1121,7 @@ def test_lifecycle_adopt_project_vars(snapcraft_yaml, new_dir): def test_check_experimental_plugins_disabled(snapcraft_yaml, mocker): - craft_parts.plugins.register( - {"kernel": KernelPlugin, "matter-sdk": MatterSdkPlugin} - ) + craft_parts.plugins.register({"kernel": KernelPlugin}) project = Project.unmarshal( snapcraft_yaml( base="core22", @@ -1137,23 +1135,6 @@ def test_check_experimental_plugins_disabled(snapcraft_yaml, mocker): "Plugin 'kernel' in part 'foo' is unstable and may change in the future." ) - project = Project.unmarshal( - snapcraft_yaml( - base="core22", - parts={ - "foo": { - "plugin": "matter-sdk", - "matter-sdk-version": "1536ca20c5917578ca40ce509400e97b52751788", - } - }, - ) - ) - with pytest.raises(errors.SnapcraftError) as raised: - parts_lifecycle._check_experimental_plugins(project, False) - assert str(raised.value) == ( - "Plugin 'matter-sdk' in part 'foo' is unstable and may change in the future." - ) - def test_check_experimental_plugins_enabled(snapcraft_yaml, mocker): craft_parts.plugins.register({"kernel": KernelPlugin})