Skip to content

GHA workflow PoC to configure submodule remote, branch#594

Closed
amd-justchen wants to merge 10 commits into
mainfrom
users/justchen/build-ci-config-submodule
Closed

GHA workflow PoC to configure submodule remote, branch#594
amd-justchen wants to merge 10 commits into
mainfrom
users/justchen/build-ci-config-submodule

Conversation

@amd-justchen
Copy link
Copy Markdown
Contributor

Implementing #559

This is an initial proof of concept that enables specifying the remote url and branch of a submodule when running the build workflow for linux and windows.

As of now this can be tested when running these build workflows from users/justchen/build-ci-config-submodule:
https://github.com/ROCm/TheRock/actions/workflows/build_windows_packages.yml
https://github.com/ROCm/TheRock/actions/workflows/linux_windows_packages.yml

There are now 3 additional input fields:

- name of subproject 
- url of subproject
- name of branch

To enable, either name of subproject or url of subproject, or both can be inputted.
If only url... is inputted then the name of subproject will be derived from the url.
if only name... is inputted then it will use the existing remote url.
similarly, if no branch is specified, the existing branch will be used.

Details can be found in the build logs under the Fetch submodule from remote step.
Internally, proj_path has to be retrieved based on the project name.

Example of url specified but no project name:

[*] Fetch submodule from remote using GHA inputs:
     proj_name: []
     proj_path: []
     proj_seturl: [https://github.com/amd-justchen/hipBLASLt]
     proj_branch: [testbranch-other]
[*] proj_name GHA Input not set, deriving from proj_seturl: [hipBLASLt]
[*] Existing submodule config for [hipBLASLt]:
submodule.hipBLASLt.path math-libs/BLAS/hipBLASLt
submodule.hipBLASLt.url https://github.com/ROCm/hipBLASLt.git
submodule.hipBLASLt.branch develop
[*] Submodule status [hipBLASLt]:-50d9abdddc0fda4b00313dfbc19e435d3b3a3500 math-libs/BLAS/hipBLASLt
[*] Setting remote url and branch for submodule [hipBLASLt]
[*] Modified submodule config for [hipBLASLt]:
submodule.hipBLASLt.path math-libs/BLAS/hipBLASLt
submodule.hipBLASLt.url https://github.com/amd-justchen/hipBLASLt
submodule.hipBLASLt.branch testbranch-other
[*] Fetching latest submodule commit from remote
Submodule 'hipBLASLt' (https://github.com/amd-justchen/hipBLASLt) registered for path 'math-libs/BLAS/hipBLASLt'
Cloning into 'C:/home/runner/_work/TheRock/TheRock/math-libs/BLAS/hipBLASLt'...
Submodule path 'math-libs/BLAS/hipBLASLt': checked out '35eb9960f2b16cda449249f00f71d1fefec6532d'
[+] Bump submodule [hipBLASLt]:+35eb9960f2b16cda449249f00f71d1fefec6532d math-libs/BLAS/hipBLASLt (remotes/origin/testbranch-other)

Example with default url, with subproject name specified:

[*] Fetch submodule from remote using GHA inputs:
     proj_name: [hipBLASLt]
     proj_path: []
     proj_seturl: []
     proj_branch: [staging]
[*] proj_name GHA Input set to: [hipBLASLt]
[*] Existing submodule config for [hipBLASLt]:
submodule.hipBLASLt.path math-libs/BLAS/hipBLASLt
submodule.hipBLASLt.url https://github.com/ROCm/hipBLASLt.git
submodule.hipBLASLt.branch develop
[*] Submodule status [hipBLASLt]:-50d9abdddc0fda4b00313dfbc19e435d3b3a3500 math-libs/BLAS/hipBLASLt
[*] Setting remote url and branch for submodule [hipBLASLt]
[*] Modified submodule config for [hipBLASLt]:
submodule.hipBLASLt.path math-libs/BLAS/hipBLASLt
submodule.hipBLASLt.url https://github.com/ROCm/hipBLASLt.git
submodule.hipBLASLt.branch staging
[*] Fetching latest submodule commit from remote
Submodule 'hipBLASLt' (https://github.com/ROCm/hipBLASLt.git) registered for path 'math-libs/BLAS/hipBLASLt'
Cloning into 'C:/home/runner/_work/TheRock/TheRock/math-libs/BLAS/hipBLASLt'...
Submodule path 'math-libs/BLAS/hipBLASLt': checked out '705c0a943b9f5cece2e32d35cdbd6d1c5fc34064'
[+] Bump submodule [hipBLASLt]:+705c0a943b9f5cece2e32d35cdbd6d1c5fc34064 math-libs/BLAS/hipBLASLt (mock-tag-test-263-g705c0a94)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

High level feedback: I see two main ways to build out #559 with GitHub Actions, and this PR currently sits a bit awkwardly between them, while I think we should lean strongly into one or the other.

  1. Modify an existing build/test workflow to edit the source tree as it runs.
  2. Create a branch with a modified source tree and run existing workflows on that branch.

For (1), you can either edit the source tree as you have it now, with commands like git submodule set-url or you can run fetch_sources.py first, then go into the submodule and make local changes using e.g. git fetch. Since the source tree is only used within the context of that workflow, there is no strong need to make those changes persistent (e.g. by writing patches to https://github.com/ROCm/TheRock/tree/main/patches or editing .gitmodules).

For (2), we would create branches like what @marbre has done for PRs like #532 (no patches affected) and #562 (one patch dropped).

  • The advantages to creating branches are that we can then run any workflows we want and any developer can also checkout that branch to try their own testing.
  • A disadvantage to creating a branch is that such branches can easily get orphaned and litter the repository. Branch naming, cleanup actions, or storing such branches in a fork could all help there.

I like option 2 for how well it composes with other development activities. If we took what you have for "set one subproject to this remote url and branch" and put it in a python script, we could use that script both "try jobs" (this PR) and for routine submodule updates.

That being said, option 1 is simpler so long as our build/test/etc. workflows are also simple. A try job that runs just

  1. change_subproject_ref.py
  2. fetch_sources.py
  3. cmake --build ...
    Should be pretty easy to reason about and maintain.

Comment on lines +12 to +20
project_name:
type: string
description: "name of subproject (etc. hipBLASLt) to configure remote url and branch to fetch. (disable w/ null name and url)"
project_seturl:
type: string
description: "url of subproject (etc. https://github.com/ROCm/hipBLASLt) (disable w/ null name and url)"
project_branch:
type: string
description: "name of branch (etc. develop) to configure remote url and branch to fetch"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's try to keep each workflow focused on one specific task. If there was one primary way to interface with the project then having a monolithic workflow could make sense, but we have a complex development model here with several ways to build/test/use artifacts. This new code could go in a workflow that composes with the existing workflows, to have:

  • modifying the source tree
  • building packages
  • running tests

With the "create a branch" approach mentioned in my other comment, we could have try_ci_from_remote.yml that does this:

  1. create a branch using inputs: project_name, project_url, project_ref (generalization of branch to also include commit hash or tag)
  2. Use something like https://github.com/benc-uk/workflow-dispatch (or a native way, or the GH CLI) to trigger ci.yml, build_linux_packages.yml, or whatever else we want using that branch
  3. Somehow wait for the results and report them back to the caller
  4. Delete the branch? Or leave cleanup to some other automation?

Comment on lines +82 to +86
- name: Fetch submodule from remote
run: |
proj_name="${{ inputs.project_name }}"
proj_branch="${{ inputs.project_branch }}"
proj_seturl="${{ inputs.project_seturl }}"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's move all this bash to a Python script so we can

  1. Reuse it between workflows
  2. Run it locally
  3. Add tests for it
  4. Add more sophisticated logging and error handling

@marbre
Copy link
Copy Markdown
Member

marbre commented Jan 9, 2026

@amd-justchen this seems stale. Please close if you do no longer to merge. I will remove myself as reviewer for now.

@marbre marbre removed their request for review January 9, 2026 17:20
@amd-justchen
Copy link
Copy Markdown
Contributor Author

@amd-justchen this seems stale. Please close if you do no longer to merge. I will remove myself as reviewer for now.

Will do!

Per #559 (comment) this has been implemented in a different PR

Just commenting that @marbre is now working on this feature as the scope is now larger than what was originally addressed with this PoC. See the recently added patch_monorepo.py with this PR #687 and #689

334f6c3

@github-project-automation github-project-automation Bot moved this from TODO to Done in TheRock Triage Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants