Skip to content

When including ebpf-verifier as a submodule, default to tests off#751

Merged
elazarg merged 1 commit into
vbpf:mainfrom
Alan-Jowett:default_tests_off_as_submodule
Oct 22, 2024
Merged

When including ebpf-verifier as a submodule, default to tests off#751
elazarg merged 1 commit into
vbpf:mainfrom
Alan-Jowett:default_tests_off_as_submodule

Conversation

@Alan-Jowett

@Alan-Jowett Alan-Jowett commented Oct 21, 2024

Copy link
Copy Markdown
Contributor

When using ebpf-verifier as a submodule, default to not building the tests collateral. This makes using this as a submodule simpler as it reduced the list of dependencies that need to be pre-installed.

Summary by CodeRabbit

  • Chores
    • Introduced conditional logic for enabling/disabling tests based on the presence of a .git directory.
    • Retained installation of Git pre-commit hooks within the new conditional structure.
    • Adjusted configuration for the Catch2 testing framework to align with the test enablement option.

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
@coderabbitai

coderabbitai Bot commented Oct 21, 2024

Copy link
Copy Markdown

Walkthrough

The changes in this pull request modify the CMakeLists.txt file to implement conditional logic for the VERIFIER_ENABLE_TESTS option based on the existence of a .git directory in the project source. If the directory is present, tests are enabled; if not, they are disabled. The installation of Git pre-commit hooks remains, but is now included within this new conditional structure. The configuration for the Catch2 testing framework is also dependent on the VERIFIER_ENABLE_TESTS option.

Changes

File Change Summary
CMakeLists.txt Introduced conditional logic for VERIFIER_ENABLE_TESTS based on the presence of a .git directory. Retained Git pre-commit hooks installation within the new structure. Conditional fetching of Catch2 testing framework based on test option.

Possibly related PRs

  • Option to build tests #727: The changes in this PR also modify the CMakeLists.txt file to introduce the VERIFIER_ENABLE_TESTS option, which is directly related to the conditional logic for enabling or disabling tests based on the presence of a .git directory in the main PR.

Suggested reviewers

  • elazarg

Poem

🐰 In the garden where code does grow,
A .git directory makes tests flow.
With hooks in place, we now can see,
How tests can thrive, oh joy, oh glee!
Conditional checks, a clever feat,
In our build, everything's neat! 🌱


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range comments (2)
CMakeLists.txt (2)

Line range hint 95-96: LGTM: Consistent application of test enabling condition.

The VERIFIER_ENABLE_TESTS condition is correctly applied to all test-related build components, ensuring they are only built when tests are enabled. This is a thorough implementation of the PR objective.

For consistency, consider wrapping the add_subdirectory("external/bpf_conformance/src") call on line 181 in an if(VERIFIER_ENABLE_TESTS) block as well, if this directory is specifically for test-related code.

Also applies to: 104-108, 150-153, 159-173, 180-181, 191-196


Test-Related Targets Not Conditioned on VERIFIER_ENABLE_TESTS

Several test-related targets and configurations are defined outside the VERIFIER_ENABLE_TESTS condition. This may lead to tests being built even when the project is used as a submodule.

  • Lines 104-109: Definition of test source files.
  • Lines 129-132: Addition of test executables (check, tests, conformance_check).
  • Lines 138-154: Setting target properties and dependencies for test executables.
  • Lines 191-199: Configuration of compile options and link libraries for the tests target.

Please ensure these sections are properly conditioned on VERIFIER_ENABLE_TESTS to prevent unintended test builds when the project is integrated as a submodule.

🔗 Analysis chain

Line range hint 1-196: Summary: PR objective successfully implemented.

The changes effectively implement the goal of defaulting to tests off when the ebpf-verifier is used as a submodule, while maintaining the existing functionality when used as a standalone project. The implementation is consistent and well-structured.

To ensure completeness:

Please run the following command to check if there are any remaining references to test-related targets or variables that are not conditioned on VERIFIER_ENABLE_TESTS:

If this command returns any results, please review them to determine if they also need to be conditioned on VERIFIER_ENABLE_TESTS.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for test-related keywords that are not within VERIFIER_ENABLE_TESTS blocks
rg -n '(test|check|conformance)' CMakeLists.txt | rg -v 'VERIFIER_ENABLE_TESTS'

Length of output: 1851

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 4832643 and dcf5d47.

📒 Files selected for processing (1)
  • CMakeLists.txt (1 hunks)
🧰 Additional context used
🔇 Additional comments (2)
CMakeLists.txt (2)

8-15: LGTM: Conditional test enabling based on project structure.

This change effectively implements the PR objective. It enables tests and installs Git hooks only when the .git directory is present (indicating it's not a submodule), and disables tests otherwise. This approach simplifies usage as a submodule by reducing dependencies.


17-17: Good addition: Informative build message.

This message clearly communicates whether tests are being built, which is helpful for users and aligns well with the changes made to the test enabling logic.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 90.38%. remained the same
when pulling dcf5d47 on Alan-Jowett:default_tests_off_as_submodule
into 4832643 on vbpf:main.

@elazarg elazarg merged commit e6ceb8f into vbpf:main Oct 22, 2024
@Alan-Jowett Alan-Jowett deleted the default_tests_off_as_submodule branch October 22, 2024 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants