Skip to content

[DO NOT MERGE] Astro reorg scripts#38325

Open
jhgilbert wants to merge 74 commits into
masterfrom
jen.gilbert/astro-reorg-scripts
Open

[DO NOT MERGE] Astro reorg scripts#38325
jhgilbert wants to merge 74 commits into
masterfrom
jen.gilbert/astro-reorg-scripts

Conversation

@jhgilbert

@jhgilbert jhgilbert commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

What does this PR do? What is the motivation?

We won't actually merge this into master, I'm just setting up a PR for easy code review.

What to review

The config dictating which files will go where:

  • astro_reorg/config.yaml

You can ignore most of the diff, but a few scripts are worth reviewing:

  • astro_reorg/execute_reorg.py, which reorgs any regular branch
  • astro_reorg/resolve_pr_conflicts.py, which processes all of the PRs in the docs repo to auto-fix any conflicts that arose from the reorg being merged into master

Resources

You may find astro_reorg/docs/pr_handling_details.md useful, since it describes the resolving script's flow in English.

How this was tested

I set up a test run as described in astro_reorg/docs/test_setup.md, then ran the resolver script against it. The results are linked below.

For example, you can see that the changes in this autofix PR correctly replay the changes seen in this closed conflicting PR, except the changes are applied to the new hugo folder.

You can view all test PRs (including past test PRs) here. The 4 open PRs and 2 recently closed PRs are the same ones listed below.

Test PRs, and their expected result (this list was generated by create_test_prs.py)

[TEST] Minor wording tweak in getting started intro (auto-fixable)

Auto-fixed. The conflict is purely reorg-caused (file moved from content/ to hugo/content/). The resolver opens a new PR with the commit replayed at the post-reorg path, closes this PR, and labels it astro-reorg-autofixed.

  • Expected result verified by Jen

[TEST] WIP PR with reorg conflict (should be skipped by resolver)

Skipped (WIP). The conflict is reorg-caused and would otherwise be auto-fixable, but the PR carries the WORK IN PROGRESS label. The resolver posts a comment explaining the situation, applies astro-reorg-skip, and leaves the PR open for the author to act on.

  • Expected result verified by Jen

[TEST] Unresolvable reorg conflict (base edited the same line) (not auto-fixable)

Manual review (unresolvable reorg conflict). The conflict is classified as reorg-caused, but the base branch also edited the same line at the post-reorg path (hugo/content/en/getting_started/_index.md), so git am --3way cannot replay the patch. The resolver labels this PR astro-reorg-manual-review and posts a comment.

  • Expected result verified by Jen

[TEST] Non-reorg conflict on a top-level file (not auto-fixable)

Manual review (non-reorg conflict). The conflict is in CONTRIBUTING.md, a top-level file the reorg never moves. The resolver classifies it as an unrelated conflict and immediately labels this PR astro-reorg-manual-review without attempting an auto-fix.

  • Expected result verified by Jen

NOTE: I don't like how this is handled, since the comment is confusing here (it acts as though the conflicts are from the reorg, but they aren't). I think this case should be labeled with astro-reorg-no-conflicts and skipped. I've added a comment in the code of this PR so I don't forget to adjust it.

[TEST] New page with nav link, no base conflict (auto-fixable)

Auto-fixed. The PR adds a new page at a pre-reorg path (a "wrong-path addition") and links it in the nav menu. Both changes are reorg-caused and the base branch did not touch that menu line, so the resolver replays both commits cleanly at the post-reorg paths, opens a new PR, closes this one, and labels it astro-reorg-autofixed.

  • Expected result verified by Jen

[TEST] New page with nav link (base edited the same menu line) (not auto-fixable)

Manual review (unresolvable reorg conflict). The PR adds a new page at a pre-reorg path and inserts a nav menu entry. The conflict is classified as reorg-caused, but the base branch also renamed the same menu heading, so git am --3way cannot replay the nav edit. The resolver labels this PR astro-reorg-manual-review and posts a comment.

  • Expected result verified by Jen

Logs that you might find useful

Output from create_test_prs.py

astro_reorg/create_test_prs.py 

=== building conflicting base mock-reorged-master-7-20-1231-conflict-1cb2b2c0 ===
  Pushed conflicting base: mock-reorged-master-7-20-1231-conflict-1cb2b2c0

=== jen.gilbert/astro-reorg-test-wording-5fd3e80e ===
  Opened PR against mock-reorged-master-7-20-1231-conflict-1cb2b2c0: https://github.com/DataDog/documentation/pull/38317

=== jen.gilbert/astro-reorg-test-wip-1420b043 ===
  Opened PR against mock-reorged-master-7-20-1231-conflict-1cb2b2c0: https://github.com/DataDog/documentation/pull/38318

=== jen.gilbert/astro-reorg-test-unresolvable-reorg-e26f305a ===
  Opened PR against mock-reorged-master-7-20-1231-conflict-1cb2b2c0: https://github.com/DataDog/documentation/pull/38319

=== jen.gilbert/astro-reorg-test-non-reorg-conflict-be03247a ===
  Opened PR against mock-reorged-master-7-20-1231-conflict-1cb2b2c0: https://github.com/DataDog/documentation/pull/38320

=== jen.gilbert/astro-reorg-test-new-page-nav-autofixable-0dee841d ===
  Opened PR against mock-reorged-master-7-20-1231-conflict-1cb2b2c0: https://github.com/DataDog/documentation/pull/38321

=== jen.gilbert/astro-reorg-test-new-page-nav-conflict-7fc55c47 ===
  Opened PR against mock-reorged-master-7-20-1231-conflict-1cb2b2c0: https://github.com/DataDog/documentation/pull/38322

Created 6 PR(s):
  https://github.com/DataDog/documentation/pull/38317
  https://github.com/DataDog/documentation/pull/38318
  https://github.com/DataDog/documentation/pull/38319
  https://github.com/DataDog/documentation/pull/38320
  https://github.com/DataDog/documentation/pull/38321
  https://github.com/DataDog/documentation/pull/38322

Wrote /Users/jen.gilbert/go/src/github.com/DataDog/documentation/astro_reorg/docs/test_pr_list.md

View all test PRs:
  https://github.com/DataDog/documentation/pulls?q=is%3Apr+is%3Aopen+label%3Aastro-reorg-testing

Dry-run conflict resolution (no changes made):
  python3 astro_reorg/resolve_pr_conflicts.py --base-branch mock-reorged-master-7-20-1231-conflict-1cb2b2c0 --limit 6

Live conflict resolution (applies fixes and labels):
  python3 astro_reorg/resolve_pr_conflicts.py --no-dry-run --base-branch mock-reorged-master-7-20-1231-conflict-1cb2b2c0 --limit 6

Output from resolve_pr_conflicts.py

python3 astro_reorg/resolve_pr_conflicts.py --no-dry-run --base-branch mock-reorged-master-7-20-1231-conflict-1cb2b2c0 --limit 6
Fetching origin/mock-reorged-master-7-20-1231-conflict-1cb2b2c0...
Found 6 open PR(s) to check.
Limit: will stop after acting on 6 PR(s).

PR #38322: [TEST] New page with nav link (base edited the same menu line) (not auto-fixable)
  mergeable: CONFLICTING
  Reorg-caused conflicts : ['config/_default/menus/main.en.yaml']
  Unrelated conflicts    : none
  All conflicts are reorg-caused — attempting auto-fix.
  git am failed:
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"

  Auto-fix failed or not applicable — labeling for manual review.
  Added label 'astro-reorg-manual-review' to PR #38322
  Added label 'WORK IN PROGRESS' to PR #38322
  Posted comment on PR #38322
  Added label 'astro-reorg-processed' to PR #38322

PR #38321: [TEST] New page with nav link, no base conflict (auto-fixable)
  mergeable: CONFLICTING
  Reorg-caused conflicts : ['config/_default/menus/main.en.yaml']
  Unrelated conflicts    : none
  All conflicts are reorg-caused — attempting auto-fix.
  Pushed fix to branch 'reorg-fix/pr-38321'
  Opened fix PR: https://github.com/DataDog/documentation/pull/38323
  Added label 'WORK IN PROGRESS' to PR #38323
  Added label 'astro-reorg-auto-pr' to PR #38323
  Added label 'Do Not Merge' to PR #38323
  Closed PR #38321 with comment pointing to fix PR #38323
  Added label 'astro-reorg-autofixed' to PR #38321
  Added label 'astro-reorg-processed' to PR #38321

PR #38320: [TEST] Non-reorg conflict on a top-level file (not auto-fixable)
  mergeable: CONFLICTING
  Reorg-caused conflicts : none
  Unrelated conflicts    : ['CONTRIBUTING.md']
  Non-reorg conflicts present — labeling for manual review.
  Added label 'astro-reorg-manual-review' to PR #38320
  Added label 'WORK IN PROGRESS' to PR #38320
  Posted comment on PR #38320
  Added label 'astro-reorg-processed' to PR #38320

PR #38319: [TEST] Unresolvable reorg conflict (base edited the same line) (not auto-fixable)
  mergeable: CONFLICTING
  Reorg-caused conflicts : ['content/en/getting_started/_index.md']
  Unrelated conflicts    : none
  All conflicts are reorg-caused — attempting auto-fix.
  git am failed:
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"

  Auto-fix failed or not applicable — labeling for manual review.
  Added label 'astro-reorg-manual-review' to PR #38319
  Added label 'WORK IN PROGRESS' to PR #38319
  Posted comment on PR #38319
  Added label 'astro-reorg-processed' to PR #38319

PR #38318: [TEST] WIP PR with reorg conflict (should be skipped by resolver)
  mergeable: CONFLICTING
  Reorg-caused conflicts : ['content/en/getting_started/learning_center.md']
  Unrelated conflicts    : none
  PR is marked WIP — skipping auto-fix, commenting and labeling.
  Posted comment on PR #38318
  Added label 'astro-reorg-skip' to PR #38318
  Added label 'astro-reorg-processed' to PR #38318

PR #38317: [TEST] Minor wording tweak in getting started intro (auto-fixable)
  mergeable: CONFLICTING
  Reorg-caused conflicts : ['content/en/getting_started/_index.md']
  Unrelated conflicts    : none
  All conflicts are reorg-caused — attempting auto-fix.
  Pushed fix to branch 'reorg-fix/pr-38317'
  Opened fix PR: https://github.com/DataDog/documentation/pull/38324
  Added label 'WORK IN PROGRESS' to PR #38324
  Added label 'astro-reorg-auto-pr' to PR #38324
  Added label 'Do Not Merge' to PR #38324
  Closed PR #38317 with comment pointing to fix PR #38324
  Added label 'astro-reorg-autofixed' to PR #38317
  Added label 'astro-reorg-processed' to PR #38317

Acted on 6 PR(s). Done.

View auto-fix PRs:
  https://github.com/DataDog/documentation/pulls?q=is%3Apr+is%3Aopen+label%3Aastro-reorg-auto-pr

@jhgilbert
jhgilbert requested review from a team as code owners July 20, 2026 17:58
@jhgilbert jhgilbert added the Do Not Merge Just do not merge this PR :) label Jul 20, 2026
@datadog-official

datadog-official Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Pipelines

⚠️ Warnings

🚦 2 Pipeline jobs failed

DataDog/documentation | build_preview   View in Datadog   GitLab

Merge label check | Merge is not allowed when 'Do Not Merge' label is present   View in Datadog   GitHub Actions

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 1171ea6 | Docs | Datadog PR Page | Give us feedback!

# The PR has conflicts that are NOT from the reorg. We must not
# touch it — just label it so a human can resolve it manually.
print(" Non-reorg conflicts present — labeling for manual review.")
send_to_manual_review(pr_number, dry_run)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to myself to handle this case slightly differently -- see my comments in the PR description.

"pr", "list", "--repo", REPO, "--state", "open",
"--base", BASE_BRANCH,
"--search", f"-label:{LABEL_NO_CONFLICTS} -label:{LABEL_MANUAL_REVIEW} "
f"-label:{LABEL_HELP_REQUESTED} -label:{LABEL_SKIP}",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also skip our autofix PRs -- I just noticed that this script tries to process the autofix PRs it made, which doesn't hurt anything (it doesn't find conflicts anyway) but wastes resources.

@hestonhoffman hestonhoffman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a couple comments and I'll DM you with a test I created for the 3-way merge stuff

Comment thread astro_reorg/config.yaml

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would fail if I ran it cos I have a few more gitignored files/directories that I've assembled over the years that aren't here, but I could add them if I need to run the script.

"--base", BASE_BRANCH,
"--search", f"-label:{LABEL_NO_CONFLICTS} -label:{LABEL_MANUAL_REVIEW} "
f"-label:{LABEL_HELP_REQUESTED} -label:{LABEL_SKIP}",
"--json", fields, "--limit", str(limit),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This limits the PRs fetched by gh, but the doc above calls limit the PRs to take action on, so I think limit is being conflated as both the amount of PRs to fetch and the number of PRs to act on. Perhaps default to ~150 as the gh --limit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Do Not Merge Just do not merge this PR :)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants