Skip to content

Commit 3d21f5b

Browse files
authored
Add in the ability to have arbitrary arguments. (#7)
That is, add the ability to have arbitrary colcon arguments. Hidden in this refactor is a change in the default arguments used for packages. That is, if packages are specified, the default is now to use --packages-above-and-dependencies for builds and --packages-above for tests. If --only-fixes-test is specified (a new flag), the old behavior of using --packages-up-to for build and --packages-select for test is used. Arguably this reflects our current best practice in ROS 2, where we want to make sure all packages that depend on this change are tested as well. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
1 parent 41144da commit 3d21f5b

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

ros_github_scripts/ci_for_pr.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,15 @@ def parse_args():
307307
parser.add_argument(
308308
'-c', '--comment', action='store_true',
309309
help='Automatically post a comment on the PRs being built, containing relevant content.')
310+
parser.add_argument(
311+
'--only-fixes-test', action='store_true',
312+
help='The fix being tested only fixes a test, which causes CI to be shorter')
313+
parser.add_argument(
314+
'--colcon-build-args', type=str, default='',
315+
help='Arbitrary colcon arguments to specify to build; must be specified with -b')
316+
parser.add_argument(
317+
'--colcon-test-args', type=str, default='',
318+
help='Arbitrary colcon arguments to specify to test; must be specified with -b')
310319
return parser.parse_args()
311320

312321

@@ -328,12 +337,19 @@ def main():
328337
gist = create_ci_gist(github_instance, chosen_pulls, parsed.target)
329338
gist_url = gist.files['ros2.repos'].raw_url
330339

331-
extra_build_args = ''
332-
extra_test_args = ''
340+
if not parsed.build and (parsed.colcon_build_args or parsed.colcon_test_args):
341+
panic('colcon build or test args can only be specified when doing a build')
342+
343+
extra_build_args = parsed.colcon_build_args
344+
extra_test_args = parsed.colcon_test_args
333345
if parsed.packages:
334346
packages_changed = ' '.join(parsed.packages)
335-
extra_build_args = f'--packages-up-to {packages_changed}'
336-
extra_test_args = f'--packages-select {packages_changed}'
347+
if parsed.only_fixes_test:
348+
extra_build_args += f' --packages-up-to {packages_changed}'
349+
extra_test_args += f' --packages-select {packages_changed}'
350+
else:
351+
extra_build_args += f' --packages-above-and-dependencies {packages_changed}'
352+
extra_test_args += f' --packages-above {packages_changed}'
337353

338354
comment_texts = []
339355
comment_texts.append(

0 commit comments

Comments
 (0)