From 2b13eb61238affd1703ffe560fd8a2d798710a71eca731e651a1db08564c0efb Mon Sep 17 00:00:00 2001 From: Andrii Nikitin Date: Thu, 26 Feb 2026 14:10:39 +0100 Subject: [PATCH] t: add TC-SYNC-007 for target branch synchronization Implement integration test test_007_change_target_branch to verify that changing the target branch of a package PR automatically updates the corresponding project PR's target branch. The test is marked as xfail since the functionality is not yet implemented. Updated integration/test-plan.md accordingly. --- integration/test-plan.md | 10 +++-- integration/tests/test_pr_workflow.py | 0 integration/tests/workflow_pr_sync_test.py | 51 ++++++++++++++++++++++ 3 files changed, 57 insertions(+), 4 deletions(-) mode change 100755 => 100644 integration/tests/test_pr_workflow.py mode change 100755 => 100644 integration/tests/workflow_pr_sync_test.py diff --git a/integration/test-plan.md b/integration/test-plan.md index c9ae045..a9fd4e5 100644 --- a/integration/test-plan.md +++ b/integration/test-plan.md @@ -59,17 +59,18 @@ The testing will be conducted in a dedicated test environment that mimics the pr | **TC-SYNC-002** | P | **Update ProjectGit PR from PackageGit PR** | 1. Push a new commit to an existing PackageGit PR. | 1. The corresponding ProjectGit PR's head branch is updated with the new commit. | High | | **TC-SYNC-003** | P | **WIP Flag Synchronization** | 1. Mark a PackageGit PR as "Work In Progress".
2. Remove the WIP flag from the PackageGit PR. | 1. The corresponding ProjectGit PR is also marked as "Work In Progress".
2. The WIP flag on the ProjectGit PR is removed. | Medium | | **TC-SYNC-004** | - | **WIP Flag (multiple referenced package PRs)** | 1. Create a ProjectGit PR that references multiple PackageGit PRs.
2. Mark one of the PackageGit PRs as "Work In Progress".
3. Remove the "Work In Progress" flag from all PackageGit PRs. | 1. The ProjectGit PR is marked as "Work In Progress".
2. The "Work In Progress" flag is removed from the ProjectGit PR only after it has been removed from all associated PackageGit PRs. | Medium | -| **TC-SYNC-005** | x | **NoProjectGitPR = true, edits disabled** | 1. Set `NoProjectGitPR = true` in `workflow.config`.
2. Create a PackageGit PR without "Allow edits from maintainers" enabled.
3. Push a new commit to the PackageGit PR. | 1. No ProjectGit PR is created.
2. The bot adds a warning comment to the PackageGit PR explaining that it cannot update the PR. | High | -| **TC-SYNC-006** | x | **NoProjectGitPR = true, edits enabled** | 1. Set `NoProjectGitPR = true` in `workflow.config`.
2. Create a PackageGit PR with "Allow edits from maintainers" enabled.
3. Push a new commit to the PackageGit PR. | 1. No ProjectGit PR is created.
2. The submodule commit on the project PR is updated with the new commit from the PackageGit PR. | High | +| **TC-SYNC-005** | m | **NoProjectGitPR = true, edits disabled** | 1. Set `NoProjectGitPR = true` in `workflow.config`.
2. Create a PackageGit PR without "Allow edits from maintainers" enabled.
3. Push a new commit to the PackageGit PR. | 1. No ProjectGit PR is created.
2. The bot adds a warning comment to the PackageGit PR explaining that it cannot update the PR. | High | +| **TC-SYNC-006** | m | **NoProjectGitPR = true, edits enabled** | 1. Set `NoProjectGitPR = true` in `workflow.config`.
2. Create a PackageGit PR with "Allow edits from maintainers" enabled.
3. Push a new commit to the PackageGit PR. | 1. No ProjectGit PR is created.
2. The submodule commit on the project PR is updated with the new commit from the PackageGit PR. | High | +| **TC-SYNC-007** | m | **Change target branch** | 1. Create a Package PR targeting 'main'.
2. Change the target branch of the Package PR to 'merge'. | 1. The target branch of the corresponding Project PR is updated to 'merge' automatically. | High | | **TC-COMMENT-001** | - | **Detect duplicate comments** | 1. Create a PackageGit PR.
2. Wait for the `workflow-pr` bot to act on the PR.
3. Edit the body of the PR to trigger the bot a second time. | 1. The bot should not post a duplicate comment. | High | | **TC-REVIEW-001** | P | **Add mandatory reviewers** | 1. Create a new PackageGit PR. | 1. All mandatory reviewers are added to both the PackageGit and ProjectGit PRs. | High | | **TC-REVIEW-002** | - | **Add advisory reviewers** | 1. Create a new PackageGit PR with advisory reviewers defined in the configuration. | 1. Advisory reviewers are added to the PR, but their approval is not required for merging. | Medium | | **TC-REVIEW-003** | - | **Re-add reviewers** | 1. Push a new commit to a PackageGit PR after it has been approved. | 1. The original reviewers are re-added to the PR. | Medium | -| **TC-REVIEW-004** | x | **Package PR created by a maintainer** | 1. Create a PackageGit PR from the account of a package maintainer. | 1. No review is requested from other package maintainers. | High | +| **TC-REVIEW-004** | X | **Package PR created by a maintainer** | 1. Create a PackageGit PR from the account of a package maintainer. | 1. No review is requested from other package maintainers. | High | | **TC-REVIEW-005** | P | **Package PR created by an external user (approve)** | 1. Create a PackageGit PR from the account of a user who is not a package maintainer.
2. One of the package maintainers approves the PR. | 1. All package maintainers are added as reviewers.
2. Once one maintainer approves the PR, the other maintainers are removed as reviewers. | High | | **TC-REVIEW-006** | P | **Package PR created by an external user (reject)** | 1. Create a PackageGit PR from the account of a user who is not a package maintainer.
2. One of the package maintainers rejects the PR. | 1. All package maintainers are added as reviewers.
2. Once one maintainer rejects the PR, the other maintainers are removed as reviewers. | High | | **TC-REVIEW-007** | P | **Package PR created by a maintainer with ReviewRequired=true** | 1. Set `ReviewRequired = true` in `workflow.config`.
2. Create a PackageGit PR from the account of a package maintainer. | 1. A review is requested from other package maintainers if available. | High | -| **TC-MERGE-001** | x | **Automatic Merge** | 1. Create a PackageGit PR.
2. Ensure all mandatory reviews are completed on both project and package PRs. | 1. The PR is automatically merged. | High | +| **TC-MERGE-001** | X | **Automatic Merge** | 1. Create a PackageGit PR.
2. Ensure all mandatory reviews are completed on both project and package PRs. | 1. The PR is automatically merged. | High | | **TC-MERGE-002** | - | **ManualMergeOnly with Package Maintainer** | 1. Create a PackageGit PR with `ManualMergeOnly` set to `true`.
2. Ensure all mandatory reviews are completed on both project and package PRs.
3. Comment "merge ok" on the package PR from the account of a package maintainer for that package. | 1. The PR is merged. | High | | **TC-MERGE-003** | - | **ManualMergeOnly with unauthorized user** | 1. Create a PackageGit PR with `ManualMergeOnly` set to `true`.
2. Ensure all mandatory reviews are completed on both project and package PRs.
3. Comment "merge ok" on the package PR from the account of a user who is not a maintainer for that package. | 1. The PR is not merged. | High | | **TC-MERGE-004** | - | **ManualMergeOnly with multiple packages** | 1. Create a ProjectGit PR that references multiple PackageGit PRs with `ManualMergeOnly` set to `true`.
2. Ensure all mandatory reviews are completed on both project and package PRs.
3. Comment "merge ok" on each package PR from the account of a package maintainer. | 1. The PR is merged only after "merge ok" is commented on all associated PackageGit PRs. | High | @@ -86,4 +87,5 @@ The testing will be conducted in a dedicated test environment that mimics the pr * P = implemented and passing; * x = likely implemented, but investigation is needed; * X = implemented and likely to pass, but someteimes may fail, but troubleshooting is needed; +* m = bot functionality is missing in the branch, the test is waiting for implementation in the code base * - = test is not implemented diff --git a/integration/tests/test_pr_workflow.py b/integration/tests/test_pr_workflow.py old mode 100755 new mode 100644 diff --git a/integration/tests/workflow_pr_sync_test.py b/integration/tests/workflow_pr_sync_test.py old mode 100755 new mode 100644 index 73e6cbe..e405961 --- a/integration/tests/workflow_pr_sync_test.py +++ b/integration/tests/workflow_pr_sync_test.py @@ -324,3 +324,54 @@ index 0000000..f587a12 print("Verification complete: Manually created Project PR was updated by the bot as expected.") +@pytest.mark.t007 +@pytest.mark.xfail(reason="test is ready; bot functionality is missing: it creates a new project PR instead of updating existing") +def test_007_change_target_branch(gitea_env): + """Target branch in project PR is updated when package PR target branch changes""" + # 1. Create a Package PR targeting 'main' + diff = "diff --git a/target_test.txt b/target_test.txt\nnew file mode 100644\nindex 0000000..e69de29\n" + package_pr = gitea_env.create_gitea_pr("pool/pkgA", diff, "Target Branch Test PR", False, base_branch="main") + package_pr_number = package_pr["number"] + + # 2. Poll for forwarded Project PR + forwarded_pr_number = None + print(f"Polling pool/pkgA PR #{package_pr_number} timeline for forwarded PR event...") + for _ in range(20): + time.sleep(1) + timeline_events = gitea_env.get_timeline_events("pool/pkgA", package_pr_number) + for event in timeline_events: + if event.get("type") == "pull_ref": + if not (ref_issue := event.get("ref_issue")): + continue + url_to_check = ref_issue.get("html_url", "") + match = re.search(r"products/SLFO/pulls/(\d+)", url_to_check) + if match: + forwarded_pr_number = match.group(1) + break + if forwarded_pr_number: + break + + assert forwarded_pr_number is not None, "Workflow bot did not create a forwarded PR." + + # Verify initial target branch + project_pr_details = gitea_env.get_pr_details("products/SLFO", forwarded_pr_number) + assert project_pr_details["base"]["ref"] == "main" + + # 3. User changes the target branch in the package PR to 'merge' + print(f"Changing target branch of Package PR #{package_pr_number} to 'merge'") + gitea_env.update_gitea_pr_properties("pool/pkgA", package_pr_number, base="merge") + + # 4. Check that target branch in the project PR gets updated by the bots automatically + updated_successfully = False + print(f"Polling Project PR #{forwarded_pr_number} for target branch update...") + for _ in range(20): + time.sleep(1) + project_pr_details = gitea_env.get_pr_details("products/SLFO", forwarded_pr_number) + if project_pr_details["base"]["ref"] == "merge": + updated_successfully = True + print("Project PR target branch updated to 'merge'") + break + + assert updated_successfully, "Target branch in Project PR was not updated to 'merge'" + + -- 2.51.1