Skip to content

Commit 162df09

Browse files
arkqenkiusz
andauthored
Install matter-yamltests files in matter namespace (project-chip#38534)
* Install matter-yamltests files in matter namespace * Update imports in tests * Update yamltests imports * pytests: Include py_matter_idl in venv Include matter.idl when pytest deps are requested. Add pytest deps to venv used to run chip-repl tests. Signed-off-by: Maciej Grela <[email protected]> * Update tests requirements * Install testing requirements in python-venv * Add tests requirements to cache key * Install matter-yamltests in cert-bins docker image * Update matter-yamltests sources --------- Signed-off-by: Maciej Grela <[email protected]> Co-authored-by: Maciej Grela <[email protected]>
1 parent 623db56 commit 162df09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+123
-122
lines changed

.github/actions/bootstrap-cache/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ runs:
1111
attempt_limit: 3
1212
attempt_delay: 2000
1313
with: |
14-
key: ${{ runner.os }}-env-${{ hashFiles('scripts/setup/*', 'scripts/py_matter_idl/*', 'third_party/pigweed/**', '/etc/lsb-release') }}
14+
key: ${{ runner.os }}-env-${{ hashFiles('scripts/setup/*', 'scripts/tests/requirements.txt', 'scripts/py_matter_idl/*', 'third_party/pigweed/**', '/etc/lsb-release') }}
1515
path: |
1616
.environment
1717
build_overrides/pigweed_environment.gni

.github/actions/bootstrap/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ runs:
2525
# In addition to the various setup files, the work directory matters as well,
2626
# because the bootstrapped Pigweed environment contains absolute paths.
2727
echo "Calculating bootstrap cache key for '$PWD'"
28-
FILES_HASH="${{ hashFiles('scripts/setup/*', 'scripts/py_matter_idl/*', 'third_party/pigweed/**') }}"
28+
FILES_HASH="${{ hashFiles('scripts/setup/*', 'scripts/tests/requirements.txt', 'scripts/py_matter_idl/*', 'third_party/pigweed/**') }}"
2929
case "$RUNNER_OS" in
3030
macOS) OS_HASH="$(sw_vers | shasum -a 256 | cut -d' ' -f1)";;
3131
*) OS_HASH="$(shasum -a 256 /etc/lsb-release | cut -d' ' -f1)";;

.github/workflows/tests.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,11 @@ jobs:
233233
"
234234
- name: Build Apps
235235
run: |
236-
scripts/run_in_build_env.sh './scripts/build_python.sh --install_virtual_env out/venv'
236+
./scripts/run_in_build_env.sh \
237+
"./scripts/build_python.sh \
238+
--install_virtual_env out/venv \
239+
--include_pytest_deps yes \
240+
"
237241
./scripts/run_in_build_env.sh \
238242
"./scripts/build/build_examples.py \
239243
--target linux-x64-chip-tool${CHIP_TOOL_VARIANT}-${BUILD_VARIANT} \

BUILD.gn

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,23 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
7676
}
7777
}
7878

79-
# Matter's in-tree pw_python_package or pw_python_distribution targets.
80-
_matter_python_packages = [
81-
"//examples/chef",
82-
"//examples/common/pigweed/rpc_console/py:chip_rpc",
83-
"//integrations/mobly:chip_mobly",
84-
"//scripts/py_matter_yamltests:matter_yamltests",
85-
"//src/python_testing/matter_testing_infrastructure:chip-testing",
86-
]
87-
8879
pw_python_venv("matter_build_venv") {
8980
path = "$root_build_dir/python-venv"
9081
constraints = pw_build_PIP_CONSTRAINTS
9182
requirements = pw_build_PIP_REQUIREMENTS
9283

84+
# Extra packages required for running tests.
85+
requirements += [ "//scripts/tests/requirements.txt" ]
86+
9387
# Packages available to import within GN's build venv.
94-
source_packages = _matter_python_packages +
95-
[ "$dir_pw_env_setup:core_pigweed_python_packages" ]
88+
# Matter's in-tree pw_python_package or pw_python_distribution targets.
89+
source_packages = [
90+
"//examples/chef",
91+
"//examples/common/pigweed/rpc_console/py:chip_rpc",
92+
"//integrations/mobly:chip_mobly",
93+
"//src/python_testing/matter_testing_infrastructure:chip-testing",
94+
"$dir_pw_env_setup:core_pigweed_python_packages",
95+
]
9696
}
9797

9898
pw_python_pip_install("pip_install_matter_packages") {
@@ -122,6 +122,7 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
122122
if (chip_enable_python_modules) {
123123
deps = [
124124
"${chip_root}/scripts:matter_yamltests_distribution.wheel",
125+
"${chip_root}/scripts/py_matter_yamltests:matter-yamltests.wheel",
125126
"${chip_root}/src/controller/python:chip-repl",
126127
"${chip_root}/src/python_testing/matter_testing_infrastructure:chip-testing.wheel",
127128
]
@@ -252,8 +253,8 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
252253
"//:fake_platform_tests",
253254
"//examples/chef:chef.tests",
254255
"//scripts/build:build_examples.tests",
255-
"//scripts/py_matter_idl:matter_idl.tests",
256-
"//scripts/py_matter_yamltests:matter_yamltests.tests",
256+
"//scripts/py_matter_idl:matter-idl.tests",
257+
"//scripts/py_matter_yamltests:matter-yamltests.tests",
257258
"//src:tests_run",
258259
"//src/python_testing/matter_testing_infrastructure:chip-testing.tests",
259260

integrations/docker/images/chip-cert-bins/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,6 @@ COPY --from=chip-build-cert-bins /root/connectedhomeip/out/python_env python_env
312312
COPY --from=chip-build-cert-bins /root/connectedhomeip/src/python_testing python_testing/scripts/sdk
313313
COPY --from=chip-build-cert-bins /root/connectedhomeip/data_model python_testing/data_model
314314

315-
COPY --from=chip-build-cert-bins /root/connectedhomeip/scripts/tests/requirements.txt /tmp/requirements.txt
316-
RUN pip install --break-system-packages -r /tmp/requirements.txt && rm /tmp/requirements.txt
317-
318315
COPY --from=chip-build-cert-bins /root/connectedhomeip/src/python_testing/requirements.txt /tmp/requirements.txt
319316
RUN pip install --break-system-packages -r /tmp/requirements.txt && rm /tmp/requirements.txt
320317

@@ -333,6 +330,8 @@ RUN set -x && DEBIAN_FRONTEND=noninteractive apt-get update; apt-get install -fy
333330
RUN apt-get remove -y python3-gi
334331

335332
RUN pip install --break-system-packages --no-cache-dir \
333+
python_lib/python/obj/scripts/py_matter_idl/matter-idl._build_wheel/matter_idl-*.whl \
334+
python_lib/python/obj/scripts/py_matter_yamltests/matter-yamltests._build_wheel/matter_yamltests-*.whl \
336335
python_lib/obj/src/python_testing/matter_testing_infrastructure/chip-testing._build_wheel/chip_testing-*.whl \
337336
python_lib/controller/python/chip*.whl
338337

scripts/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import("$dir_pw_build/python_dist.gni")
2323
# out/obj/scripts/matter_yamltests_distribution/ <- source files here
2424
# out/obj/scripts/matter_yamltests_distribution._build_wheel/matter_yamltests-0.0.1-py3-none-any.whl
2525
pw_python_distribution("matter_yamltests_distribution") {
26-
packages = [ "${chip_root}/scripts/py_matter_yamltests:matter_yamltests" ]
26+
packages = [ "${chip_root}/scripts/py_matter_yamltests:matter-yamltests" ]
2727
generate_setup_cfg = {
2828
name = "matter_yamltests"
2929
version = "0.0.1"

scripts/build_python.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,12 @@ WHEEL=("$OUTPUT_ROOT"/controller/python/chip*.whl)
187187
WHEEL+=("$OUTPUT_ROOT"/obj/src/python_testing/matter_testing_infrastructure/chip-testing._build_wheel/chip_testing*.whl)
188188

189189
if [ "$install_pytest_requirements" = "yes" ]; then
190-
# Add the matter_yamltests_distribution wheel
191-
WHEEL+=("$OUTPUT_ROOT"/obj/scripts/matter_yamltests_distribution._build_wheel/matter_yamltests-*.whl)
190+
# Add wheels with YAML testing support.
191+
WHEEL+=(
192+
# Add matter-idl as well as matter-yamltests depends on it.
193+
"$OUTPUT_ROOT"/python/obj/scripts/py_matter_idl/matter-idl._build_wheel/matter_idl-*.whl
194+
"$OUTPUT_ROOT"/python/obj/scripts/py_matter_yamltests/matter-yamltests._build_wheel/matter_yamltests-*.whl
195+
)
192196
fi
193197

194198
if [ -n "$extra_packages" ]; then

scripts/py_matter_idl/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import("$dir_pw_build/python.gni")
2020

2121
import("${chip_root}/scripts/py_matter_idl/files.gni")
2222

23-
pw_python_package("matter_idl") {
23+
pw_python_package("matter-idl") {
2424
setup = [
2525
"setup.py",
2626
"setup.cfg",

scripts/py_matter_yamltests/BUILD.gn

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,48 @@ import("//build_overrides/chip.gni")
1818
import("//build_overrides/pigweed.gni")
1919
import("$dir_pw_build/python.gni")
2020

21-
pw_python_package("matter_yamltests") {
21+
pw_python_package("matter-yamltests") {
2222
setup = [
2323
"setup.py",
2424
"setup.cfg",
2525
"pyproject.toml",
2626
]
2727

2828
sources = [
29-
"matter_yamltests/__init__.py",
30-
"matter_yamltests/adapter.py",
31-
"matter_yamltests/constraints.py",
32-
"matter_yamltests/definitions.py",
33-
"matter_yamltests/errors.py",
34-
"matter_yamltests/fixes.py",
35-
"matter_yamltests/hooks.py",
36-
"matter_yamltests/parser.py",
37-
"matter_yamltests/parser_builder.py",
38-
"matter_yamltests/parser_config.py",
39-
"matter_yamltests/pics_checker.py",
40-
"matter_yamltests/pseudo_clusters/__init__.py",
41-
"matter_yamltests/pseudo_clusters/clusters/delay_commands.py",
42-
"matter_yamltests/pseudo_clusters/clusters/log_commands.py",
43-
"matter_yamltests/pseudo_clusters/clusters/system_commands.py",
44-
"matter_yamltests/pseudo_clusters/pseudo_cluster.py",
45-
"matter_yamltests/pseudo_clusters/pseudo_clusters.py",
46-
"matter_yamltests/py.typed",
47-
"matter_yamltests/runner.py",
48-
"matter_yamltests/websocket_runner.py",
49-
"matter_yamltests/yaml_loader.py",
29+
"matter/yamltests/__init__.py",
30+
"matter/yamltests/adapter.py",
31+
"matter/yamltests/constraints.py",
32+
"matter/yamltests/definitions.py",
33+
"matter/yamltests/errors.py",
34+
"matter/yamltests/fixes.py",
35+
"matter/yamltests/hooks.py",
36+
"matter/yamltests/parser.py",
37+
"matter/yamltests/parser_builder.py",
38+
"matter/yamltests/parser_config.py",
39+
"matter/yamltests/pics_checker.py",
40+
"matter/yamltests/pseudo_clusters/__init__.py",
41+
"matter/yamltests/pseudo_clusters/clusters/__init__.py",
42+
"matter/yamltests/pseudo_clusters/clusters/accessory_server_bridge.py",
43+
"matter/yamltests/pseudo_clusters/clusters/commissioner_commands.py",
44+
"matter/yamltests/pseudo_clusters/clusters/delay_commands.py",
45+
"matter/yamltests/pseudo_clusters/clusters/discovery_commands.py",
46+
"matter/yamltests/pseudo_clusters/clusters/equality_commands.py",
47+
"matter/yamltests/pseudo_clusters/clusters/log_commands.py",
48+
"matter/yamltests/pseudo_clusters/clusters/system_commands.py",
49+
"matter/yamltests/pseudo_clusters/clusters/webrtc.py",
50+
"matter/yamltests/pseudo_clusters/pseudo_cluster.py",
51+
"matter/yamltests/pseudo_clusters/pseudo_clusters.py",
52+
"matter/yamltests/runner.py",
53+
"matter/yamltests/websocket_runner.py",
54+
"matter/yamltests/yaml_loader.py",
5055
]
5156

52-
python_deps = [ "${chip_root}/scripts/py_matter_idl:matter_idl" ]
57+
inputs = [
58+
# Marker file to indicate to mypy that this package is type-annotated.
59+
"matter/yamltests/py.typed",
60+
]
61+
62+
python_deps = [ "${chip_root}/scripts/py_matter_idl:matter-idl" ]
5363

5464
tests = [
5565
"test_spec_definitions.py",

scripts/py_matter_yamltests/generate_pseudo_cluster_doc_tables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import os
1616
import xml.etree.ElementTree as ElementTree
1717

18-
from matter_yamltests.pseudo_clusters.pseudo_clusters import get_default_pseudo_clusters
18+
from matter.yamltests.pseudo_clusters.pseudo_clusters import get_default_pseudo_clusters
1919

2020
SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
2121
WARNING = ("<!---\n"

0 commit comments

Comments
 (0)