Skip to content

Commit f4267c6

Browse files
committed
Add test showing that golangci-lint lint targets created by golangci_lint_aspect() fail to pull in dependencies.
Demonstrates aspect-build#129. Run "./lint.sh src:hello2_go" in example/ and you should see something like this: INFO: Invocation ID: ac22e950-5606-4161-8987-0e288bd0d046 INFO: Analyzed target //src:hello2_go (1 packages loaded, 4 targets configured). INFO: From golangcilint src/golangcilint.hello2_go.aspect_rules_lint.report: level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package : could not load export data: no export data for \"github.com/aspect-build/rules_lint/example/src/hello_helper\"" level=error msg="Running error: 1 error occurred:\n\t* can't run linter goanalysis_metalinter: buildir: failed to load package : could not load export data: no export data for \"github.com/aspect-build/rules_lint/example/src/hello_helper\"\n\n" INFO: Found 1 target... Aspect //tools:lint.bzl%golangci_lint of //src:hello2_go up-to-date: bazel-bin/src/golangcilint.hello2_go.aspect_rules_lint.report INFO: Elapsed time: 2.526s, Critical Path: 2.24s INFO: 2 processes: 1 internal, 1 linux-sandbox. INFO: Build completed successfully, 2 total actions INFO: Build Event Protocol files produced successfully.
1 parent e1d6a2d commit f4267c6

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

example/src/BUILD.bazel

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
2-
load("@io_bazel_rules_go//go:def.bzl", "go_binary")
2+
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
33

44
package(default_visibility = ["//visibility:public"])
55

@@ -39,6 +39,18 @@ go_binary(
3939
srcs = ["hello.go"],
4040
)
4141

42+
go_binary(
43+
name = "hello2_go",
44+
srcs = ["hello2.go"],
45+
deps = [":hello_go_helper"],
46+
)
47+
48+
go_library(
49+
name = "hello_go_helper",
50+
srcs = ["hello_helper.go"],
51+
importpath = "github.com/aspect-build/rules_lint/example/src/hello_helper",
52+
)
53+
4254
cc_binary(
4355
name = "hello_cc",
4456
srcs = ["hello.cpp"],

example/src/hello2.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package main
2+
3+
import "github.com/aspect-build/rules_lint/example/src/hello_helper"
4+
5+
func main() {
6+
hello_helper.Doathing()
7+
}

example/src/hello_helper.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package hello_helper
2+
3+
// Simple function that returns an error
4+
func Doathing() (string, error) {
5+
return "Hello from helper", nil
6+
}

0 commit comments

Comments
 (0)