Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/PROJECT_SYNC.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/project-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion scripts/sync_github_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"Closed unmerged",
)
DELIVERY_OPTIONS = ("未关联实现", "尚未合入", "已合入待发布", "已发布")
APPLY_WORKERS = 4
APPLY_WORKERS = 8


def connection(query, path, *, initial=None, progress=None, **variables):
Expand Down
9 changes: 6 additions & 3 deletions tests/test_project_delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)

Expand Down
13 changes: 10 additions & 3 deletions tests/test_sync_github_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading