[Github Actions] Added monorepo_source_of_truth flag (#1525)

此提交包含在:
amd-hsivasun
2025-10-23 16:37:12 -04:00
提交者 GitHub
父節點 45528ea3fc
當前提交 43687b24f8
共有 5 個檔案被更改,包括 41 行新增29 行删除
+32 -16
查看文件
@@ -6,7 +6,8 @@
"branch": "amd-staging",
"category": "projects",
"auto_subtree_pull": false,
"auto_subtree_push": true
"auto_subtree_push": true,
"monorepo_source_of_truth": true
},
{
"name": "clr",
@@ -14,7 +15,8 @@
"branch": "develop",
"category": "projects",
"auto_subtree_pull": false,
"auto_subtree_push": true
"auto_subtree_push": true,
"monorepo_source_of_truth": true
},
{
"name": "hip",
@@ -22,7 +24,8 @@
"branch": "develop",
"category": "projects",
"auto_subtree_pull": false,
"auto_subtree_push": true
"auto_subtree_push": true,
"monorepo_source_of_truth": true
},
{
"name": "hipother",
@@ -30,7 +33,8 @@
"branch": "develop",
"category": "projects",
"auto_subtree_pull": false,
"auto_subtree_push": true
"auto_subtree_push": true,
"monorepo_source_of_truth": true
},
{
"name": "hip-tests",
@@ -38,7 +42,8 @@
"branch": "develop",
"category": "projects",
"auto_subtree_pull": false,
"auto_subtree_push": true
"auto_subtree_push": true,
"monorepo_source_of_truth": true
},
{
"name": "rdc",
@@ -46,7 +51,8 @@
"branch": "amd-staging",
"category": "projects",
"auto_subtree_pull": false,
"auto_subtree_push": true
"auto_subtree_push": true,
"monorepo_source_of_truth": true
},
{
"name": "rocm-core",
@@ -54,7 +60,8 @@
"branch": "amd-mainline",
"category": "projects",
"auto_subtree_pull": false,
"auto_subtree_push": true
"auto_subtree_push": true,
"monorepo_source_of_truth": true
},
{
"name": "rocminfo",
@@ -62,7 +69,8 @@
"branch": "amd-staging",
"category": "projects",
"auto_subtree_pull": false,
"auto_subtree_push": true
"auto_subtree_push": true,
"monorepo_source_of_truth": true
},
{
"name": "rocm-smi-lib",
@@ -70,7 +78,8 @@
"branch": "amd-staging",
"category": "projects",
"auto_subtree_pull": false,
"auto_subtree_push": true
"auto_subtree_push": true,
"monorepo_source_of_truth": true
},
{
"name": "rocprofiler",
@@ -78,7 +87,8 @@
"branch": "amd-staging",
"category": "projects",
"auto_subtree_pull": false,
"auto_subtree_push": true
"auto_subtree_push": true,
"monorepo_source_of_truth": true
},
{
"name": "rocprofiler-compute",
@@ -86,7 +96,8 @@
"branch": "develop",
"category": "projects",
"auto_subtree_pull": false,
"auto_subtree_push": true
"auto_subtree_push": true,
"monorepo_source_of_truth": true
},
{
"name": "rocprofiler-register",
@@ -94,7 +105,8 @@
"branch": "amd-staging",
"category": "projects",
"auto_subtree_pull": false,
"auto_subtree_push": true
"auto_subtree_push": true,
"monorepo_source_of_truth": true
},
{
"name": "rocprofiler-sdk",
@@ -102,7 +114,8 @@
"branch": "amd-staging",
"category": "projects",
"auto_subtree_pull": false,
"auto_subtree_push": true
"auto_subtree_push": true,
"monorepo_source_of_truth": true
},
{
"name": "rocprofiler-systems",
@@ -110,7 +123,8 @@
"branch": "amd-staging",
"category": "projects",
"auto_subtree_pull": false,
"auto_subtree_push": true
"auto_subtree_push": true,
"monorepo_source_of_truth": true
},
{
"name": "rocr-runtime",
@@ -118,7 +132,8 @@
"branch": "develop",
"category": "projects",
"auto_subtree_pull": false,
"auto_subtree_push": true
"auto_subtree_push": true,
"monorepo_source_of_truth": true
},
{
"name": "roctracer",
@@ -126,7 +141,8 @@
"branch": "amd-staging",
"category": "projects",
"auto_subtree_pull": false,
"auto_subtree_push": true
"auto_subtree_push": true,
"monorepo_source_of_truth": true
}
]
}
+5 -11
查看文件
@@ -51,20 +51,12 @@ def parse_arguments(argv: Optional[List[str]] = None) -> argparse.Namespace:
parser.add_argument("--config", required=False, default=".github/repos-config.json", help="Path to the repos-config.json file")
parser.add_argument("--require-auto-pull", action="store_true", help="Only include entries with auto_subtree_pull=true")
parser.add_argument("--require-auto-push", action="store_true", help="Only include entries with auto_subtree_push=true")
parser.add_argument("--require-monorepo-source", action="store_true", help="Only include entries with monorepo_source_of_truth=true")
parser.add_argument("--dry-run", action="store_true", help="Print results without writing to GITHUB_OUTPUT.")
parser.add_argument("--debug", action="store_true", help="Enable debug logging")
return parser.parse_args(argv)
def get_valid_prefixes(config: List[RepoEntry]) -> Set[str]:
"""Extract valid subtree prefixes from the configuration."""
valid_prefixes = {
f"{entry.category}/{entry.name}"
for entry in config
}
logger.debug("Valid subtrees:\n" + "\n".join(sorted(valid_prefixes)))
return valid_prefixes
def get_valid_prefixes(config: List[RepoEntry], require_auto_pull: bool = False, require_auto_push: bool = False) -> Set[str]:
def get_valid_prefixes(config: List[RepoEntry], require_auto_pull: bool = False, require_auto_push: bool = False, require_monorepo_source: bool = False) -> Set[str]:
"""Extract valid subtree prefixes from the configuration based on filters."""
valid_prefixes = set()
for entry in config:
@@ -72,6 +64,8 @@ def get_valid_prefixes(config: List[RepoEntry], require_auto_pull: bool = False,
continue
if require_auto_push and not getattr(entry, "auto_subtree_push", False):
continue
if require_monorepo_source and not getattr(entry, "monorepo_source_of_truth", False):
continue
valid_prefixes.add(f"{entry.category}/{entry.name}")
logger.debug("Valid subtrees:\n" + "\n".join(sorted(valid_prefixes)))
return valid_prefixes
@@ -131,7 +125,7 @@ def main(argv=None) -> None:
logger.error(f"SHA-based Git CLI fallback failed: {e}")
sys.exit(1)
valid_prefixes = get_valid_prefixes(config, args.require_auto_pull, args.require_auto_push)
valid_prefixes = get_valid_prefixes(config, args.require_auto_pull, args.require_auto_push, args.require_monorepo_source)
matched_subtrees = find_matched_subtrees(changed_files, valid_prefixes)
output_subtrees(matched_subtrees, args.dry_run)
+2
查看文件
@@ -33,6 +33,7 @@ class RepoEntry(BaseModel):
url : Individual GitHub org plus repo names in matching case and punctuation. (e.g., "ROCm/rocBLAS")
branch : The base branch of the sub-repo to target (e.g., "develop").
category : Directory category in the super-repo (e.g., "projects" or "shared").
monorepo_source_of_truth : Whether this project has completed migration to monorepo as source of truth.
"""
name: str
url: str
@@ -40,6 +41,7 @@ class RepoEntry(BaseModel):
category: str
auto_subtree_pull: bool
auto_subtree_push: bool
monorepo_source_of_truth: bool
class RepoConfig(BaseModel):
"""
+1 -1
查看文件
@@ -96,7 +96,7 @@ jobs:
--repo "${{ github.repository }}" \
--pr "${{ github.event.pull_request.number }}" \
--config ".github/repos-config.json" \
--require-auto-push
--require-monorepo-source
- name: Cancel in-progress/not-started runs for current PR
id: cancel-in-progress
+1 -1
查看文件
@@ -118,7 +118,7 @@ git push origin develop
1. **Update repos-config.json:**
- Update the true/false values in the [`repos-config.json`](/.github/repos-config.json) file that automated workflows use to determine which way the source gets synchronized..
- `auto_subtree_pull` should now be false, `auto_subtree_push` should now be true for this migrated project.
- `auto_subtree_pull` should now be false, `auto_subtree_push` should now be true for this migrated project. `monorepo_source_of_truth` should be true to reflect the new source of truth is the monorepo.
- Make this change on both the `develop` and `release-staging` branches.
- https://github.com/ROCm/rocm-systems/blob/develop/.github/repos-config.json
- https://github.com/ROCm/rocm-systems/blob/release-staging/rocm-rel-7.0/.github/repos-config.json