From 43687b24f83e23e8ac0b5235906e37ed7e44df7a Mon Sep 17 00:00:00 2001 From: amd-hsivasun Date: Thu, 23 Oct 2025 16:37:12 -0400 Subject: [PATCH] [Github Actions] Added monorepo_source_of_truth flag (#1525) --- .github/repos-config.json | 48 ++++++++++++------- .github/scripts/pr_detect_changed_subtrees.py | 16 ++----- .github/scripts/repo_config_model.py | 2 + .github/workflows/azure-ci-dispatcher.yml | 2 +- docs/migration-process.md | 2 +- 5 files changed, 41 insertions(+), 29 deletions(-) diff --git a/.github/repos-config.json b/.github/repos-config.json index a38802e342..2a286f1d14 100644 --- a/.github/repos-config.json +++ b/.github/repos-config.json @@ -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 } ] } diff --git a/.github/scripts/pr_detect_changed_subtrees.py b/.github/scripts/pr_detect_changed_subtrees.py index 016370f1f2..c056595258 100644 --- a/.github/scripts/pr_detect_changed_subtrees.py +++ b/.github/scripts/pr_detect_changed_subtrees.py @@ -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) diff --git a/.github/scripts/repo_config_model.py b/.github/scripts/repo_config_model.py index cbca67d77a..d6204c57a8 100644 --- a/.github/scripts/repo_config_model.py +++ b/.github/scripts/repo_config_model.py @@ -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): """ diff --git a/.github/workflows/azure-ci-dispatcher.yml b/.github/workflows/azure-ci-dispatcher.yml index cdff34903b..a8300519fe 100644 --- a/.github/workflows/azure-ci-dispatcher.yml +++ b/.github/workflows/azure-ci-dispatcher.yml @@ -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 diff --git a/docs/migration-process.md b/docs/migration-process.md index d5853e4f97..9d20e7582c 100644 --- a/docs/migration-process.md +++ b/docs/migration-process.md @@ -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