From cf35f3a246194b659a4570d3abea339e49a0a92b Mon Sep 17 00:00:00 2001 From: WanqQixiang Date: Fri, 23 Jan 2026 10:35:58 +0800 Subject: [PATCH] CI: skip TC_IDM_10_3 for main branch --- .gitlab-ci.yml | 7 +++++- conftest.py | 13 ++++++++++ examples/pytest_esp_matter_light.py | 4 +-- tools/ci/certification_test_commands.json | 3 ++- tools/ci/pytest_cert_helper.py | 30 ++++++++++++----------- 5 files changed, 39 insertions(+), 18 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 55d404d0e..5ee0b8cf4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -551,7 +551,12 @@ pytest_esp32c6_esp_matter_dut: - cp ${ESP_MATTER_PATH}/tools/ci/extended_color_light_wifi_pics_code.txt $ESP_MATTER_PATH/connectedhomeip/connectedhomeip/src/python_testing/ - pip install -r tools/ci/requirements-pytest.txt - python3 -c "import os; os.environ['TEST_CHUNK'] = '$TEST_CHUNK'" - - pytest examples/ --target esp32c6 -m esp_matter_dut --junitxml=XUNIT_RESULT.xml --certification-json=$ESP_MATTER_PATH/tools/ci/certification_test_commands.json + - | + if [ $CI_PIPELINE_SOURCE == "merge_request_event" ]; then + pytest examples/ --target esp32c6 -m esp_matter_dut --junitxml=XUNIT_RESULT.xml --certification-json=$ESP_MATTER_PATH/tools/ci/certification_test_commands.json --ci-branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + else + pytest examples/ --target esp32c6 -m esp_matter_dut --junitxml=XUNIT_RESULT.xml --certification-json=$ESP_MATTER_PATH/tools/ci/certification_test_commands.json + fi tags: ["esp32c6", "esp_matter_dut"] parallel: matrix: diff --git a/conftest.py b/conftest.py index b4681f518..aa4ebfcdf 100644 --- a/conftest.py +++ b/conftest.py @@ -127,11 +127,24 @@ def pytest_addoption(parser): default="certification_test_commands.json", help="Path to the certification test commands JSON file", ) + parser.addoption( + "--ci-branch", + action="store", + default="main", + help="Branch on which the CI runs", + ) + @pytest.fixture(scope="session") def certification_tests(request): return request.config.getoption("--certification-json") + +@pytest.fixture(scope="session") +def ci_branch(request): + return request.config.getoption("--ci-branch") + + @pytest.fixture(autouse=True) @multi_dut_fixture def junit_properties( diff --git a/examples/pytest_esp_matter_light.py b/examples/pytest_esp_matter_light.py index 229b55564..f8c38a169 100644 --- a/examples/pytest_esp_matter_light.py +++ b/examples/pytest_esp_matter_light.py @@ -116,7 +116,7 @@ def test_matter_commissioning_c2(dut:Dut) -> None: ) # Matter over wifi commissioning -def test_matter_commissioning_c6(dut:Dut, certification_tests: str) -> None: +def test_matter_commissioning_c6(dut:Dut, certification_tests: str, ci_branch: str) -> None: light = dut # BLE start advertising light.expect(r'Configuring CHIPoBLE advertising', timeout=20) @@ -144,7 +144,7 @@ def test_matter_commissioning_c6(dut:Dut, certification_tests: str) -> None: light.write('matter esp factoryreset') time.sleep(10) - run_python_certification_tests(light, certification_tests) + run_python_certification_tests(light, certification_tests, ci_branch) result = re.findall(r'Run command failure', str(out_str)) if len(result) != 0: diff --git a/tools/ci/certification_test_commands.json b/tools/ci/certification_test_commands.json index bdf7512b2..28a2c5965 100644 --- a/tools/ci/certification_test_commands.json +++ b/tools/ci/certification_test_commands.json @@ -101,7 +101,8 @@ "TC_IDM_10_3": { "script": "TC_DeviceConformance.py", "test_case": "test_TC_IDM_10_3", - "args": "" + "args": "", + "skip_on_branch": "main" }, "TC_IDM_10_2": { "script": "TC_DeviceConformance.py", diff --git a/tools/ci/pytest_cert_helper.py b/tools/ci/pytest_cert_helper.py index 04c4c1498..b8d617b43 100644 --- a/tools/ci/pytest_cert_helper.py +++ b/tools/ci/pytest_cert_helper.py @@ -19,7 +19,7 @@ gitlab_api = GitLabAPI() PYTEST_SSID = gitlab_api.ci_gitlab_pytest_ssid PYTEST_PASSPHRASE = gitlab_api.ci_gitlab_pytest_passphrase -def load_test_commands(certification_tests: str): +def load_test_commands(certification_tests: str, ci_branch:str): if not PYTEST_SSID or not PYTEST_PASSPHRASE: raise ValueError("CI_GITLAB_PYTEST_SSID and CI_GITLAB_PYTEST_PASSPHRASE must be set as environment variables") @@ -36,19 +36,21 @@ def load_test_commands(certification_tests: str): for test_case_name, test_config in test_cases.items(): script = test_config["script"] args = test_config.get("args", "") - - if "test_case" in test_config: - test_param = f"--tests {test_config['test_case']}" - storage_path = f"--storage-path logs/{test_config['test_case']}.json" - command = f"python3 {script} {common_args} {storage_path} {test_param} {args}".strip() + if ci_branch == test_config.get("skip_on_branch", ""): + print(f"Skip {test_case_name} for {ci_branch} branch") else: - storage_path = f"--storage-path logs/{test_case_name}.json" - command = f"python3 {script} {common_args} {storage_path} {args}".strip() + if "test_case" in test_config: + test_param = f"--tests {test_config['test_case']}" + storage_path = f"--storage-path logs/{test_config['test_case']}.json" + command = f"python3 {script} {common_args} {storage_path} {test_param} {args}".strip() + else: + storage_path = f"--storage-path logs/{test_case_name}.json" + command = f"python3 {script} {common_args} {storage_path} {args}".strip() - test_commands.append({ - "name": test_case_name, - "command": command - }) + test_commands.append({ + "name": test_case_name, + "command": command + }) return test_commands @@ -115,9 +117,9 @@ def update_mr_description_with_results(markdown_content, chunk_id=None): except Exception as e: print(f"Failed to update MR description: {e}") -def run_python_certification_tests(dut:Dut, certification_tests:str) -> None: +def run_python_certification_tests(dut:Dut, certification_tests:str, ci_branch:str) -> None: light = dut - test_commands = load_test_commands(certification_tests) + test_commands = load_test_commands(certification_tests, ci_branch) num_commands = len(test_commands) mid_index = (num_commands+1) // 2