Skip to content

ci: dwyu test implementation #38646

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

ci: dwyu test implementation #38646

wants to merge 5 commits into from

Conversation

nbaws
Copy link
Contributor

@nbaws nbaws commented Mar 5, 2025

See conversation in #26797

Example run against some of my code. In this scenario I've mapped dependencies of @envoy_api//envoy/extensions/common/aws/v3:pkg_cc_proto but not @envoy_api//envoy/config/core/v3:pkg_cc_proto which is why it is being flagged as unused.

$ bazel build --aspects=//bazel:envoy_dwyu.bzl%dwyu --output_groups=dwyu '//source/extensions/common/aws:credentials_provider_interface'

DEBUG: /build/.cache/bazel/_bazel_vscode/2d35de14639eaad1ac7060a4dd7e3351/external/com_google_protobuf/protobuf.bzl:654:10: The py_proto_library macro is deprecated and will be removed in the 30.x release. switch to the rule defined by rules_python or the one in bazel/py_proto_library.bzl.
INFO: Analyzed target //source/extensions/common/aws:credentials_provider_interface (312 packages loaded, 18837 targets configured).
ERROR: /workspaces/envoy/source/extensions/common/aws/BUILD:107:17: Analyze dependencies of @//source/extensions/common/aws:credentials_provider_interface failed: (Exit 1): analyze_includes failed: error executing DwyuAnalyzeIncludes command (from target //source/extensions/common/aws:credentials_provider_interface) bazel-out/k8-opt-exec-ST-a828a81199fe/bin/external/depend_on_what_you_use/src/analyze_includes/analyze_includes --report ... (remaining 12 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/com_google_absl/absl/base/policy_checks.h:99 error: "Abseil assumes CHAR_BIT == 8."
external/com_google_absl/absl/base/policy_checks.h:110 error: "Abseil assumes that int is at least 4 bytes. "
external/com_google_absl/absl/base/config.h:492 error: "absl endian detection needs to be set up for your compiler"
external/com_google_absl/absl/base/policy_checks.h:99 error: "Abseil assumes CHAR_BIT == 8."
external/com_google_absl/absl/base/policy_checks.h:110 error: "Abseil assumes that int is at least 4 bytes. "
external/com_google_absl/absl/base/config.h:492 error: "absl endian detection needs to be set up for your compiler"
external/com_google_absl/absl/base/internal/endian.h:90 error: "Unsupported byte order: Either ABSL_IS_BIG_ENDIAN or "        "ABSL_IS_LITTLE_ENDIAN must be defined"
external/com_google_absl/absl/numeric/int128.h:244 error: "Unsupported byte order: must be little-endian or big-endian."
external/com_google_absl/absl/numeric/int128.h:485 error: "Unsupported byte order: must be little-endian or big-endian."
external/com_google_absl/absl/numeric/int128.h:714 error: "Unsupported byte order: must be little-endian or big-endian."
external/com_google_absl/absl/numeric/int128_no_intrinsic.inc:65 error: "Unsupported byte order: must be little-endian or big-endian."
bazel-out/k8-fastbuild/bin/external/com_google_protobuf/src/google/protobuf/stubs/_virtual_includes/lite/google/protobuf/stubs/port.h:65 error: "Protobuf requires at least C++11."
================================================================================
DWYU analyzing: '@//source/extensions/common/aws:credentials_provider_interface'

Result: FAILURE

Includes which are not available from the direct dependencies:
  File='source/extensions/common/aws/credentials_provider_impl.h', include='source/common/common/logger.h'
  File='source/extensions/common/aws/credentials_provider_impl.h', include='envoy/common/optref.h'
  File='source/extensions/common/aws/credentials_provider_impl.h', include='envoy/http/message.h'
  File='source/extensions/common/aws/credentials_provider_impl.h', include='envoy/event/timer.h'
  File='source/extensions/common/aws/credentials_provider.h', include='envoy/common/pure.h'
  File='source/extensions/common/aws/credentials_provider_impl.h', include='source/common/init/target_impl.h'
  File='source/extensions/common/aws/credentials_provider_impl.h', include='envoy/server/factory_context.h'
  File='source/extensions/common/aws/credentials_provider_impl.h', include='source/extensions/common/aws/aws_cluster_manager.h'
  File='source/extensions/common/aws/credentials_provider_impl.h', include='source/common/common/lock_guard.h'
  File='source/extensions/common/aws/credentials_provider.h', include='source/common/common/logger.h'
  File='source/extensions/common/aws/credentials_provider_impl.h', include='source/extensions/common/aws/metadata_fetcher.h'
  File='source/extensions/common/aws/credentials_provider.h', include='source/common/common/thread.h'
  File='source/extensions/common/aws/credentials_provider_impl.h', include='envoy/api/api.h'
  File='source/extensions/common/aws/credentials_provider_impl.h', include='source/common/common/thread.h'
  File='source/extensions/common/aws/credentials_provider.h', include='source/common/common/cleanup.h'
  File='source/extensions/common/aws/credentials_provider_impl.h', include='source/common/protobuf/message_validator_impl.h'
  File='source/extensions/common/aws/credentials_provider_impl.h', include='source/common/config/datasource.h'
  File='source/extensions/common/aws/credentials_provider_impl.h', include='source/common/protobuf/utility.h'
Unused dependencies in 'deps' (none of their headers are referenced):
  Dependency='@envoy_api//envoy/config/core/v3:pkg_cc_proto'

DWYU Report: bazel-out/k8-fastbuild/bin/source/extensions/common/aws/credentials_provider_interface_dwyu_report.json
================================================================================
Aspect //bazel:envoy_dwyu.bzl%dwyu of //source/extensions/common/aws:credentials_provider_interface failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 102.490s, Critical Path: 100.97s
INFO: 2 processes: 2 internal.
ERROR: Build did NOT complete successfully

This is currently hardwired to expand protobufs defined in bazel/dwyu/BUILD so we will need some smarts to expand that out.

I am not clear that the #error parsing is actually a problem, or just noise. It doesn't appear to affect the function of the tool.

I also added a small patch to work around a bug in protobuf rule parsing I found, this is raised upstream for their fix.

Commit Message:
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

nbaws added 2 commits March 5, 2025 02:34
Signed-off-by: Nigel Brittain <[email protected]>
Signed-off-by: Nigel Brittain <[email protected]>
@repokitteh-read-only repokitteh-read-only bot added the deps Approval required for changes to Envoy's external dependencies label Mar 5, 2025
Copy link

CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).
envoyproxy/dependency-shepherds assignee is @moderation

🐱

Caused by: #38646 was opened by nbaws.

see: more, trace.

@nbaws nbaws marked this pull request as draft March 5, 2025 03:59
Signed-off-by: Nigel Brittain <[email protected]>
@nbaws
Copy link
Contributor Author

nbaws commented Mar 14, 2025

@ggreenway @phlax

nbaws added 2 commits March 18, 2025 00:19
Signed-off-by: Nigel Brittain <[email protected]>
@ggreenway
Copy link
Member

@nbaws sorry this got lost in my queue; I'll take a look next week hopefully

@ggreenway ggreenway self-assigned this Mar 28, 2025
Copy link

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label Apr 27, 2025
@phlax phlax removed the stale stalebot believes this issue/PR has not been touched recently label Apr 27, 2025
@ggreenway
Copy link
Member

I'm still wanting to look into using this at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deps Approval required for changes to Envoy's external dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants