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

Lint includes #17193

Merged
merged 5 commits into from
Mar 20, 2024
Merged

Lint includes #17193

merged 5 commits into from
Mar 20, 2024

Conversation

dotnwat
Copy link
Member

@dotnwat dotnwat commented Mar 19, 2024

Checks that new-style modules meet requirements, and that the rest of
the tree doesn't violate public/private divide.

  • has <module>/include/<module>/* public headers
  • tests in a module can include anything in the module
  • includes outside a new-style module must only be public includes

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v23.3.x
  • v23.2.x

Release Notes

  • none

Copy link
Contributor

Choose a reason for hiding this comment

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

will there be a way of executing this via task in vtools, like task lint:includes or something?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to moving this to tools/lint or something. That's where I had started adding some ast grep for these sorts of checks.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed. move it to tools as a separate linter.

@vbotbuildovich
Copy link
Collaborator

vbotbuildovich commented Mar 20, 2024

new failures in https://buildkite.com/redpanda/redpanda/builds/46471#018e5933-6e7a-4faf-a092-dae8b5b1dd09:

"rptest.tests.recovery_mode_test.DisablingPartitionsTest.test_disable"

new failures in https://buildkite.com/redpanda/redpanda/builds/46471#018e5943-be7e-49a0-be51-a89a727aa9c0:

"rptest.tests.raft_availability_test.RaftAvailabilityTest.test_two_nodes_down"

.github/workflows/scripts/lint-includes.py Outdated Show resolved Hide resolved
if len(include_path.parents) <= 1:
continue

include_module = include_path.parents[-2]
Copy link
Contributor

@rockwotj rockwotj Mar 20, 2024

Choose a reason for hiding this comment

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

This doesn't account for nested modules, you need something like [:-2]?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeh, i didn't realize we had nested modules.

Copy link
Member Author

@dotnwat dotnwat Mar 20, 2024

Choose a reason for hiding this comment

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

handling this case now

Found module wasm/parser: src/v/wasm/parser
Validating module wasm/parser
Module root src/v/wasm/parser
Include root src/v/wasm/parser/include
Include path src/v/wasm/parser/include/wasm/parser
Found 1 exports: sample ['src/v/wasm/parser/include/wasm/parser/parser.h', '...']
Found 7 internal sample ['src/v/wasm/parser/CMakeLists.txt', 'src/v/wasm/parser/leb128.h', 'src/v/wasm/parser/tests/CMakeLists.txt', '...']

Found module random: src/v/random
...

.github/workflows/scripts/lint-includes.py Outdated Show resolved Hide resolved
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Tooling like the includes linter assumes that test directories are named
as plural 'tests' which fits with naming convention of a large majority
of existing modules in the tree. Renaming the paths to avoid more
special casing in tooling.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
rockwotj
rockwotj previously approved these changes Mar 20, 2024
Copy link
Contributor

@rockwotj rockwotj left a comment

Choose a reason for hiding this comment

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

🔥

@@ -0,0 +1,167 @@
#!/usr/bin/env python3
# Copyright 2020 Redpanda Data, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

😄 Insert bad joke about getting used to writing the new year

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeh. Git knows the real date

Checks that new-style modules meet requirements, and that the rest of
the tree doesn't violate public/private divide.

- has <module>/include/<module>/* public headers
- tests in a module can include anything in the module
- includes outside a new-style module must only be public includes

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
@dotnwat
Copy link
Member Author

dotnwat commented Mar 20, 2024

Force pushed to fix python formatting! Sorry about the hassle there

@dotnwat dotnwat requested a review from rockwotj March 20, 2024 20:28
@dotnwat dotnwat merged commit fb9d3e7 into redpanda-data:dev Mar 20, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants