diff --git a/.github/PROJECT_SYNC.md b/.github/PROJECT_SYNC.md index 61a27160027..958ddbfcdd5 100644 --- a/.github/PROJECT_SYNC.md +++ b/.github/PROJECT_SYNC.md @@ -46,9 +46,11 @@ or deletes source Issues/PRs. skip unchanged values and clear stale text. Paginate every GraphQL connection, reject stalled cursors, and serialize runs. Apply mode prints the plan first; on failure it reports confirmed, outcome-unknown and unattempted mutation counts, - with affected item/field, so partial writes can be reconciled. Apply uses four + with affected item/field, so partial writes can be reconciled. Apply uses eight workers across distinct Project items; mutations within each item stay ordered. This is bounded concurrency, not a guarantee against GitHub rate limits. + The synchronization job has a 120-minute total execution budget, including + checkout, scanning and writes; advancing to another step does not reset it. - Full scans log phase/page and candidate progress to the Actions log. Stable release membership is determined with one `git tag --contains` graph walk per distinct merge commit instead of one `git merge-base` process per commit/tag diff --git a/.github/workflows/project-sync.yml b/.github/workflows/project-sync.yml index 143469108da..98b08ba28df 100644 --- a/.github/workflows/project-sync.yml +++ b/.github/workflows/project-sync.yml @@ -34,7 +34,7 @@ jobs: # Configure this environment to allow only the default branch before adding secrets. environment: project-sync runs-on: ubuntu-latest - timeout-minutes: 30 + timeout-minutes: 120 steps: - name: Validate manual branch if: github.event_name == 'workflow_dispatch' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) diff --git a/scripts/sync_github_project.py b/scripts/sync_github_project.py index 5deb0dcb50b..c60abdd6aab 100644 --- a/scripts/sync_github_project.py +++ b/scripts/sync_github_project.py @@ -23,7 +23,7 @@ "Closed unmerged", ) DELIVERY_OPTIONS = ("未关联实现", "尚未合入", "已合入待发布", "已发布") -APPLY_WORKERS = 4 +APPLY_WORKERS = 8 def connection(query, path, *, initial=None, progress=None, **variables): diff --git a/tests/test_project_delivery.py b/tests/test_project_delivery.py index 9295972aa6b..2d7eee0e369 100644 --- a/tests/test_project_delivery.py +++ b/tests/test_project_delivery.py @@ -648,7 +648,7 @@ def test_dry_run_does_not_mutate_and_apply_skips_equal_fields(self): api.call_args_list[1].args[1]["value"], {"singleSelectOptionId": "D"} ) - def test_apply_uses_four_workers_and_keeps_each_item_mutations_sequential(self): + def test_apply_uses_eight_workers_and_keeps_each_item_mutations_sequential(self): plan = [ { "content": f"C{index}", @@ -664,6 +664,7 @@ def test_apply_uses_four_workers_and_keeps_each_item_mutations_sequential(self): } active, maximum, active_per_item, maximum_per_item = 0, 0, {}, {} queries, lock = [], threading.Lock() + first_mutations = threading.Barrier(8) def api(query, variables): nonlocal active, maximum @@ -678,6 +679,8 @@ def api(query, variables): active_per_item[variables["item"]], ) queries.append((variables["item"], variables["field"])) + if variables["field"] == "S": + first_mutations.wait(timeout=10) time.sleep(0.01) with lock: active -= 1 @@ -686,8 +689,8 @@ def api(query, variables): with patch.object(sync, "graphql", side_effect=api): sync.apply_plan("P", fields, plan, apply=True) - self.assertEqual(sync.APPLY_WORKERS, 4) - self.assertEqual(maximum, 4) + self.assertEqual(sync.APPLY_WORKERS, 8) + self.assertEqual(maximum, 8) self.assertEqual(set(maximum_per_item.values()), {1}) self.assertEqual(len(queries), 16) diff --git a/tests/test_sync_github_project.py b/tests/test_sync_github_project.py index 6810e903488..b3d21dc13dd 100644 --- a/tests/test_sync_github_project.py +++ b/tests/test_sync_github_project.py @@ -303,13 +303,20 @@ def test_schedule_uses_configured_default_branch(self): class WorkflowSecurityTests(unittest.TestCase): + def test_sync_job_has_120_minute_timeout(self): + workflow = ( + SCRIPT.parents[1] / ".github/workflows/project-sync.yml" + ).read_text() + job = workflow.split(" sync:\n", 1)[1].split(" steps:", 1)[0] + self.assertIn(" timeout-minutes: 120\n", job) + def test_fork_pull_request_events_are_filtered_at_job_boundary(self): workflow = ( SCRIPT.parents[1] / ".github/workflows/project-sync.yml" ).read_text() - job_condition = workflow.split(" sync:\n", 1)[1].split( - " environment:", 1 - )[0] + job_condition = workflow.split(" sync:\n", 1)[1].split(" environment:", 1)[ + 0 + ] self.assertIn("github.event_name != 'pull_request_target'", job_condition) self.assertIn( "github.event.pull_request.head.repo.full_name == github.repository",