Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitlab/build/bazel/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bazel:run-buildifier-test:
bazel:run-gazelle:
extends: [ .bazel:lint, .bazel:runner:linux-amd64 ]
script:
- bazel run //:gazelle -- -mode=diff -strict
- bazel run //:gazelle -- -mode=diff
variables:
FIX_COMMAND: "bazel run //:gazelle"

Expand Down
15 changes: 5 additions & 10 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,6 @@ ALL_BUILD_TAGS = [
# gazelle:exclude pkg/util/workqueue
# gazelle:exclude pkg/util/xc
# gazelle:exclude pkg/windowsdriver
# TODO(agent-build): This exclusion is ready for removal, blocked by issues caused by the interaction of
# Bazel with directories named `build` created by the CMake builds. We can remove this once we remove CMake
# support or we upgrade to a Bazel version containing a fix: https://github.com/bazelbuild/bazel/pull/26842
# In the meantime, temporarily remove this exclusion locally if regeneration of BUILD files is required
# gazelle:exclude rtloader
# gazelle:exclude tasks
# gazelle:exclude test
# gazelle:exclude tools/NamedPipeCmd
Expand All @@ -505,16 +500,16 @@ ALL_BUILD_TAGS = [
# gazelle:exclude tools/host-profiler
# gazelle:exclude tools/retry_file_dump
# gazelle:exclude tools/windows
# gazelle:exclude .gitlab
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems like it is worth keeping because we should never have code in .gitlab.

Copy link
Copy Markdown
Contributor Author

@rdesgroppes rdesgroppes Mar 27, 2026

Choose a reason for hiding this comment

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

Good news: gazelle honors both the good old .bazelignore and the more recent ignore_directories in REPO.bazel (Bazel 8.0), see:

func newIgnoreFilter(repoRoot string) *ignoreFilter {
	bazelignorePaths, err := loadBazelIgnore(repoRoot)
	if err != nil {
		log.Printf("error loading .bazelignore: %v", err)
	}

	repoDirectoryIgnores, err := loadRepoDirectoryIgnore(repoRoot)

I'll therefore file a PR to extend the 2nd as a preferred point of maintenance (supports globs):

ignore_directories([
"**/build", # avoid BUILD/build mess: https://github.com/docker/desktop-feedback/issues/251
".cache", # in-workspace cache: GitLab jobs, GitHub actions
"bazel-*", # bazel convenience symlinks: suddenly caused issues inside arm64 Linux containers
"target", # cargo build creates it where Cargo.toml lives
])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

# gazelle:prefix github.com/DataDog/datadog-agent
gazelle(
name = "gazelle",
args = [
build_tags = ALL_BUILD_TAGS,
external = "static", # don't use the network: https://github.com/bazel-contrib/bazel-gazelle/issues/1385
extra_args = [
"-build_file_name=BUILD.bazel", # avoid BUILD/build mess: https://github.com/docker/desktop-feedback/issues/251
"-external=static", # don't use the network: https://github.com/bazel-contrib/bazel-gazelle/issues/1385
"-strict", # don't swallow syntax errors or unknown directives
],
build_tags = ALL_BUILD_TAGS,
gazelle = ":gazelle_binary",
prefix = "github.com/DataDog/datadog-agent",
)

gazelle_binary(
Expand Down
Loading