Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionally exclude test dependencies #649

Merged
merged 6 commits into from
Oct 28, 2021
Merged

Conversation

cottsay
Copy link
Member

@cottsay cottsay commented Aug 24, 2021

In the debian generator, we can decorate the BuildDepends to omit them if the nocheck flag is set.

For RPMs, there isn't a standard mechanism for skipping tests but we actually created a build flag for skipping tests, so the only work here was to wire that custom flag into the dependency enumeration.

I still need to do some testing on the debian side. In particular, I'm not sure if nocheck automatically sets ENABLE_TESTING=OFF in the cmake builds. Either way, I think we'll need to update it to set CATKIN_ENABLE_TESTING appropriately in the catkin template.

In the debian generator, we can decorate the BuildDepends to omit them
if the `nocheck` flag is set.

For RPMs, there isn't a standard mechanism for skipping tests but we
actually created a build flag for skipping tests, so the only work here
was to wire that custom flag into the dependency enumeration.
@cottsay cottsay self-assigned this Aug 24, 2021
Copy link
Contributor

@nuclearsandwich nuclearsandwich left a comment

Choose a reason for hiding this comment

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

What's here looks good so far. I can schedule some exploratory testing of the debian behavior with nocheck and propose changes to the debian templates if needed.

@cottsay cottsay marked this pull request as ready for review October 18, 2021 15:31
Copy link
Contributor

@j-rivero j-rivero left a comment

Choose a reason for hiding this comment

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

In the debian generator, we can decorate the BuildDepends to omit them if the nocheck flag is set.

The <!nocheck> in Debian is called a Build-Profile and it's being used in the control file to specify which packages are excluded for testing when the user ask for this kind of "profile". In order to use that profile, we need to set it in DEB_BUILD_OPTIONS and that variable need to arrive to dpkg-buildpackage. At least, two ways for that I can think of:

  • Set DEB_BUILD_OPTIONS=nocheck in the rules file via empy templates
  • Pass DEB_BUILD_OPTIONS=nocheck when invoking the build command (not sure if this repo is using debbuild or dpkg-buildpackage calls directly).

I still need to do some testing on the debian side. In particular, I'm not sure if nocheck automatically sets ENABLE_TESTING=OFF in the cmake builds.

I don't think that Debian handles the ENABLE_TESTING variable in anyway and did not find any reference in code to nocheck build profile particularly. I found some packages implementing that option, is not particularly difficult, just check for nocheck in DEB_BUILD_OPTIONS and do the magic in the configure step. See https://sources.debian.org/src/foonathan-memory/0.7.1-4/debian/rules/?hl=43#L43

bloom/generators/debian/generator.py Show resolved Hide resolved
@cottsay
Copy link
Member Author

cottsay commented Oct 25, 2021

Pass DEB_BUILD_OPTIONS=nocheck when invoking the build command (not sure if this repo is using debbuild or dpkg-buildpackage calls directly).

This was attempted in ros-infrastructure/ros_buildfarm#903 already.

...just check for nocheck in DEB_BUILD_OPTIONS and do the magic in the configure step.

Ah, thanks for the confirmation. I'll add that snippet to this PR then.

@cottsay
Copy link
Member Author

cottsay commented Oct 25, 2021

Finally got around to doing some testing on this, and it looks like ros_buildfarm will need to be updated to handle the annotated debian deps.

@j-rivero
Copy link
Contributor

j-rivero commented Oct 25, 2021

Finally got around to doing some testing on this, and it looks like ros_buildfarm will need to be updated to handle the annotated debian deps.

If it helps you, the build profile document provides information on which pieces in the Debian software ecosystem needs to be in place to handle this https://wiki.debian.org/BuildProfileSpec#Document_status

Of course that does not mean that our code can work with them but at least we need these set of base packages available to make it work.

@cottsay
Copy link
Member Author

cottsay commented Oct 25, 2021

Alright I got this working locally, but I need to resolve these issues:

  1. As was already pointed out, I need to update this PR to selectively disable BUILD_TESTING based on nocheck. Yet to be determined is whether to use DEB_BUILD_OPTIONS or DEB_BUILD_PROFILES.
  2. We're manually parsing Build-Depends out of the dsc in ros_buildfarm, and that code needs to be updated to support the profile exclusions. I'll open a PR.
  3. It turns out that there are some problems in the build chain regarding nocheck. dpkg-checkbuilddeps is ignoring DEB_BUILD_OPTIONS and instead looks for DEB_BUILD_PROFILES=nocheck, but dh_auto_test is looking for DEB_BUILD_OPTIONS and ignores DEB_BUILD_PROFILES. I'm inclined to add the -DBUILD_TESTING=OFF flag to rules.em based on DEB_BUILD_OPTIONS purely based on proximity to dh_auto_test, but no matter what, it seems that I'll need to update ros_buildfarm to set them both to please dpkg-checkbuilddeps.

I'm wading through mailing lists trying to figure out if this is expected behavior or if I'm missing something.

@j-rivero
Copy link
Contributor

1. As was already pointed out, I need to update this PR to selectively disable `BUILD_TESTING` based on `nocheck`. Yet to be determined is whether to use `DEB_BUILD_OPTIONS` or `DEB_BUILD_PROFILES`.

Good point. The document seems to recommend do it on both:

No test suite should be run, and build dependencies used only for that purpose should be ignored. Builds that set this profile must also add nocheck to DEB_BUILD_OPTIONS

3\. It turns out that there are some problems in the build chain regarding `nocheck`. `dpkg-checkbuilddeps` is ignoring `DEB_BUILD_OPTIONS` and instead looks for `DEB_BUILD_PROFILES=nocheck`, but `dh_auto_test` is looking for `DEB_BUILD_OPTIONS` and ignores `DEB_BUILD_PROFILES`. I'm inclined to add the `-DBUILD_TESTING=OFF` flag to `rules.em` based on `DEB_BUILD_OPTIONS` purely based on proximity to `dh_auto_test`, but no matter what, it seems that I'll need to update `ros_buildfarm` to set them both to please `dpkg-checkbuilddeps`.

We probably need to set both of them. To handle -DBUILD_TESTING=OFF I see packages in Debian doing both :) so +1 to use DEB_BUILD_OPTIONS.

@cottsay
Copy link
Member Author

cottsay commented Oct 26, 2021

Okay, my latest commit in this PR when combined with ros-infrastructure/ros_buildfarm#918 and ros-infrastructure/ros_buildfarm#919 is working as expected. I manually tested ament_cmake and catkin packages from ROS 2 and ROS 1, and I didn't see anything strange happening.

I'm still a little bit unsure about setting the nocheck profile in multiple places, but it appears to work.

Copy link
Contributor

@j-rivero j-rivero left a comment

Choose a reason for hiding this comment

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

Good to go, with green CI

Copy link
Contributor

@nuclearsandwich nuclearsandwich left a comment

Choose a reason for hiding this comment

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

I think this change is significant enough that we should bump to the next minor (as bloom is <1.0) and make an announcement of this change (and the related changes in ros_buildfarm) on ROS Discourse.

The changes suggested are just that and completely discretionary.

bloom/generators/debian/generator.py Show resolved Hide resolved
Comment on lines +23 to +25
@[if TestDepends]@\n%if 0%{?with_tests}
@[for p in TestDepends]BuildRequires: @p@\n@[end for]@
%endif@\n@[end if]@
Copy link
Contributor

Choose a reason for hiding this comment

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

This is just preference and so take it or leave it but I find the embedded newlines less readable than plaintext newlines. This should generate the same result.

Suggested change
@[if TestDepends]@\n%if 0%{?with_tests}
@[for p in TestDepends]BuildRequires: @p@\n@[end for]@
%endif@\n@[end if]@
@[if TestDepends]@
%if 0%{?with_tests}
@[for p in TestDepends]@
BuildRequires: @p
@[end for]@
%endif
@[end if]@

Comment on lines +23 to +25
@[if TestDepends]@\n%if 0%{?with_tests}
@[for p in TestDepends]BuildRequires: @p@\n@[end for]@
%endif@\n@[end if]@
Copy link
Contributor

Choose a reason for hiding this comment

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

This is just preference and so take it or leave it but I find the embedded newlines less readable than plaintext newlines. This should generate the same result.

Suggested change
@[if TestDepends]@\n%if 0%{?with_tests}
@[for p in TestDepends]BuildRequires: @p@\n@[end for]@
%endif@\n@[end if]@
@[if TestDepends]@
%if 0%{?with_tests}
@[for p in TestDepends]@
BuildRequires: @p@
@[end for]@
%endif
@[end if]@

Comment on lines +23 to +25
@[if TestDepends]@\n%if 0%{?with_tests}
@[for p in TestDepends]BuildRequires: @p@\n@[end for]@
%endif@\n@[end if]@
Copy link
Contributor

Choose a reason for hiding this comment

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

This is just preference and so take it or leave it but I find the embedded newlines less readable than plaintext newlines. This should generate the same result.

Suggested change
@[if TestDepends]@\n%if 0%{?with_tests}
@[for p in TestDepends]BuildRequires: @p@\n@[end for]@
%endif@\n@[end if]@
@[if TestDepends]@
%if 0%{?with_tests}
@[for p in TestDepends]@
BuildRequires: @p
@[end for]@
%endif
@[end if]@

Comment on lines +23 to +25
@[if TestDepends]@\n%if 0%{?with_tests}
@[for p in TestDepends]BuildRequires: @p@\n@[end for]@
%endif@\n@[end if]@
Copy link
Contributor

Choose a reason for hiding this comment

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

This is just preference and so take it or leave it but I find the embedded newlines less readable than plaintext newlines. This should generate the same result.

Suggested change
@[if TestDepends]@\n%if 0%{?with_tests}
@[for p in TestDepends]BuildRequires: @p@\n@[end for]@
%endif@\n@[end if]@
@[if TestDepends]@
%if 0%{?with_tests}
@[for p in TestDepends]@
BuildRequires: @p
@[end for]@
%endif
@[end if]@

@cottsay cottsay merged commit 53beb52 into master Oct 28, 2021
@cottsay cottsay deleted the cottsay/no-check-deps branch October 28, 2021 23:34
v4hn added a commit to ros-o/ros_comm that referenced this pull request Oct 11, 2024
this is implicitly pulled-in through the test depends on rosunit,
but fails with ros-infrastructure/bloom#649
which disables test dependencies.
v4hn added a commit to ros-o/ros_comm that referenced this pull request Oct 11, 2024
this is implicitly pulled-in through the test depends on rosunit,
but fails with ros-infrastructure/bloom#649
which disables test dependencies.
v4hn added a commit to ros-o/ros_control that referenced this pull request Oct 12, 2024
This package is not very critical and it is unclear
what it should do at all when testing is disabled.
But as the CMakeLists.txt requires these packages during either build,
they are NOT just test dependencies.

Required to make use of added functions to exclude test depends in builds
ros-infrastructure/bloom#649
v4hn added a commit to ros-o/ros_comm that referenced this pull request Oct 14, 2024
this is implicitly pulled-in through the test depends on rosunit,
but fails with ros-infrastructure/bloom#649
which disables test dependencies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants