Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Azure DevOps pipeline intended to keep the ADO internal/main branch aligned with the public GitHub main branch by creating/updating an automation sync PR.
Changes:
- Introduces a scheduled ADO YAML pipeline that fetches GitHub
main, fast-forward checksinternal/main, force-updates a sync branch, and creates/updates a PR with optional auto-complete. - Adds parameters for repo/branch targets and debug/auto-complete behavior.
| if [ -z "${pr_id}" ]; then | ||
| echo "Creating a new sync PR." | ||
| create_payload="$(python3 <<'PY' | ||
| import json | ||
| import os | ||
|
|
||
| print(json.dumps({ | ||
| "sourceRefName": os.environ["SYNC_REF"], | ||
| "targetRefName": os.environ["TARGET_PR_REF"], | ||
| "title": os.environ["PR_TITLE"], | ||
| "description": os.environ["PR_DESCRIPTION"], | ||
| })) | ||
| PY | ||
| )" |
There was a problem hiding this comment.
The Python heredoc used to build create_payload is not indented under the bash: | block (e.g., import json, import os, and the PY terminator are at YAML top-level). This makes the pipeline YAML invalid and will fail to parse. Indent the heredoc content/terminator so it stays inside the bash literal block, or switch to generating the JSON payload without a heredoc (e.g., python3 -c ...).
| import json | ||
| import os | ||
|
|
||
| payload = { | ||
| "title": os.environ["PR_TITLE"], | ||
| "description": os.environ["PR_DESCRIPTION"], | ||
| "completionOptions": { | ||
| "deleteSourceBranch": True, | ||
| "mergeStrategy": "rebase", | ||
| "transitionWorkItems": False, | ||
| }, | ||
| } | ||
|
|
||
| requested_for_id = os.environ.get("BUILD_REQUESTEDFORID", "") | ||
| enable_auto_complete = os.environ.get("ENABLE_AUTO_COMPLETE", "false").lower() == "true" | ||
|
|
||
| if enable_auto_complete and requested_for_id: | ||
| payload["autoCompleteSetBy"] = {"id": requested_for_id} | ||
|
|
||
| print(json.dumps(payload)) | ||
| PY |
There was a problem hiding this comment.
Same YAML parsing issue for update_payload: the Python heredoc content (import json, import os, etc.) and PY terminator are not indented under the bash: | step, so they are treated as top-level YAML lines and break the pipeline definition. Indent the heredoc consistently within the bash block (or avoid heredocs).
| import json | |
| import os | |
| payload = { | |
| "title": os.environ["PR_TITLE"], | |
| "description": os.environ["PR_DESCRIPTION"], | |
| "completionOptions": { | |
| "deleteSourceBranch": True, | |
| "mergeStrategy": "rebase", | |
| "transitionWorkItems": False, | |
| }, | |
| } | |
| requested_for_id = os.environ.get("BUILD_REQUESTEDFORID", "") | |
| enable_auto_complete = os.environ.get("ENABLE_AUTO_COMPLETE", "false").lower() == "true" | |
| if enable_auto_complete and requested_for_id: | |
| payload["autoCompleteSetBy"] = {"id": requested_for_id} | |
| print(json.dumps(payload)) | |
| PY | |
| import json | |
| import os | |
| payload = { | |
| "title": os.environ["PR_TITLE"], | |
| "description": os.environ["PR_DESCRIPTION"], | |
| "completionOptions": { | |
| "deleteSourceBranch": True, | |
| "mergeStrategy": "rebase", | |
| "transitionWorkItems": False, | |
| }, | |
| } | |
| requested_for_id = os.environ.get("BUILD_REQUESTEDFORID", "") | |
| enable_auto_complete = os.environ.get("ENABLE_AUTO_COMPLETE", "false").lower() == "true" | |
| if enable_auto_complete and requested_for_id: | |
| payload["autoCompleteSetBy"] = {"id": requested_for_id} | |
| print(json.dumps(payload)) | |
| PY |
| - bash: | | ||
| set -euo pipefail | ||
|
|
||
| if [ "${DEBUG_ENABLED}" = "true" ]; then | ||
| set -x | ||
| fi | ||
|
|
There was a problem hiding this comment.
This pipeline inlines a fairly large/complex multi-step sync implementation inside a single bash: | block, which is brittle to YAML indentation issues (and already led to parsing errors in the heredocs below). Consider moving the logic into a checked-in script (e.g., under eng/pipelines/steps/ or a dedicated eng/scripts/ location) and invoking it from the YAML, to improve maintainability and reduce YAML fragility.
|
I got this: #4221 |
Completely untested, but considering there's competing PRs for what I've been assigned to work on as DRI, might as well just throw it out there. If people actually want this approach, I'll finish it up.
🤖
This is just a first draft from the 🤖