Skip to content

Commit 6af5773

Browse files
committed
[UpstreamMergeAutomation] Added details to PR description + clean up
Refined upstream merge automation by enhancing PR descriptions and cleaning up code. Removed hard-coded email IDs from configuration file. Signed-off-by: Shreejit-03 <shreejit.c@emerson.com>
1 parent 9a691ad commit 6af5773

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

scripts/dev/upstream_merge/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ The script is user configurable and uses `automation_conf.json` to define variou
9797
- **`build_args`**:
9898
String of extra arguments to pass to the build process (e.g., `"--org"` for NI corporate network builds).
9999

100-
- **`rt_target_IP`**:
101-
The IP address or hostname of the RT target where images will be installed and tested via SSH.
100+
- **`ssh_connection`**:
101+
The SSH connection of the RT target where images will be installed.
102+
Usage example: [username]@[hostname or IP address]
102103

103104
**`Note`**:
104105
- If the configuration file is `automation_conf.json`, you do not need to specify its path explicitly, as it is set as default. However, if you are using a different configuration file, you must provide its path using the `-c` argument.

scripts/dev/upstream_merge/automation_conf.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"fork_name": "myfork",
99
"email_log_level": 1,
1010
"log_level": 10,
11-
"email_from": "shreejit.c@emerson.com",
12-
"email_to": "pratheeksha.s.n@emerson.com",
11+
"email_from": "",
12+
"email_to": "",
1313
"username": "",
1414
"build_args":"",
15-
"rt_target_IP":""
15+
"ssh_connection":""
1616
}

scripts/dev/upstream_merge/json_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ def __init__(self, automation_conf_path, work_item_id):
2626
self.email_log_level = config.get("email_log_level")
2727
self.log_level = config.get("log_level")
2828
self.build_args = config.get("build_args", "")
29-
self.rt_target_IP = config.get("rt_target_IP")
29+
self.ssh_connection = config.get("ssh_connection")

scripts/dev/upstream_merge/upstream_merge_and_test.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,27 +120,26 @@ def merge_submodules_with_upstream(
120120
return merge_report
121121

122122

123-
def build_and_test(clean_build, rt_target_IP, build_args):
123+
def build_and_test(clean_build, ssh_connection, build_args):
124124
"""
125125
Build images and run tests on a VM if there are no merge errors.
126126
127127
:param clean_build: Boolean indicating whether to perform a clean build.
128-
:param rt_target_IP: The target IP address of the RT system.
128+
:param ssh_connection: The SSH connection string for the RT system.
129129
:param build_args: To build with NI specific arguments.
130130
:return: A tuple (status_code, message).
131131
Returns (0, None) on success, or error details on failure.
132132
"""
133133
success = setup_env_and_build_packages(build_args, clean_build)
134134
if success[0] != 0:
135135
return success
136-
success = install_and_test_image(rt_target_IP)
136+
success = install_and_test_image(ssh_connection)
137137
return success
138138

139139

140140
def push_submodules_and_create_PRs(
141141
merge_report,
142142
merge_branch_name,
143-
pr_title,
144143
pr_description,
145144
username
146145
):
@@ -153,11 +152,11 @@ def push_submodules_and_create_PRs(
153152
:param merge_report: Dictionary mapping GitRepo objects to
154153
(status, message).
155154
:param merge_branch_name: Name of the branch to push and create PRs from.
156-
:param pr_title: Title for the pull request.
157155
:param pr_description: Description for the pull request.
158156
:param username: GitHub username owning the downstream fork.
159157
:return: Dictionary with push and PR results for each sub-module.
160158
"""
159+
current_dir = os.getcwd()
161160
push_and_pr_results = {}
162161
for git_obj, (status, message) in list(merge_report.items()):
163162
if status == 0 and message is not None:
@@ -166,10 +165,11 @@ def push_submodules_and_create_PRs(
166165
git_obj,
167166
merge_branch_name,
168167
username,
169-
pr_title,
168+
f"{git_obj.local_repo.split('/')[-1]}: Merge latest upstream",
170169
pr_description
171170
)
172171

172+
os.chdir(current_dir)
173173
return push_and_pr_results
174174

175175

@@ -181,18 +181,20 @@ def get_pr_description(work_item_id):
181181
:return: A formatted string containing the PR checklist and work item.
182182
"""
183183
checklist = (
184+
"# Testing\n"
185+
"- [x] Built pyrex container\n"
184186
"- [x] bitbake packagefeed-ni-core\n"
185187
"- [x] bitbake packagegroup-ni-desirable\n"
186188
"- [x] bitbake package-index && bitbake nilrt-base-system-image\n"
187189
"- [x] Installed BSI on a VM and verified it boots successfully"
188190
)
189191
work_item_line = (
190-
f"\n\nAB#{work_item_id}\n"
192+
f"\n# Justification\nAB#{work_item_id}\n"
191193
if work_item_id is not None else ""
192194
)
193195
return (
194196
f"Merge latest from upstream. No conflicts."
195-
f"{work_item_line}\n\n{checklist}"
197+
f"{work_item_line}\n\n{checklist}\n@ni/rtos"
196198
)
197199

198200

@@ -293,19 +295,18 @@ def main():
293295
else:
294296
build_and_test_details = build_and_test(
295297
clean_build=skip_merge,
296-
rt_target_IP=json_config_obj.rt_target_IP,
298+
ssh_connection=json_config_obj.ssh_connection,
297299
build_args=json_config_obj.build_args,
298300
)
299301

300302
if build_and_test_details[0] == 0 and not args.skip_push_and_pr:
301303
push_and_pr_results = push_submodules_and_create_PRs(
302304
merge_report,
303305
json_config_obj.merge_branch_name,
304-
"Automated Merge PR",
305306
get_pr_description(json_config_obj.work_item_id),
306307
json_config_obj.username,
307308
)
308-
merge_report["Push and pr"] = push_and_pr_results
309+
merge_report["Push and PR"] = push_and_pr_results
309310

310311
merge_report["Build and Test"] = build_and_test_details
311312

scripts/dev/upstream_merge/utils/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def clean_feeds_and_images(args=""):
7676
"""
7777
print("\nCleaning build feeds and images...\n")
7878
return execute_and_stream_cmd_output(
79-
"bash scripts/pipelines/clean_build.core-feeds_and_core-images.sh "
79+
"bash scripts/pipelines/clean.core-feeds_and_core-images.sh "
8080
f"{args}"
8181
)
8282

0 commit comments

Comments
 (0)