Comments (10)
@jayconrod Does this still apply? I'm currently attempting to rewrite the AST of many jsonnet manifests using a mix of tooling from go-jsonnet and now-defunct k8s.
The tests break when combined into one and it's impossible to construct proper tests using a single jsonnet file. I'm seeing this:
gazelle: /home/dc/work/src/github.com/zenreach/service-manifests/tools/refactor/query/BUILD.bazel: unknown directive: gazelle:skiprule
PS: if you have any tips on mass-refactoring jsonnet code that is are miserable, please include them in your response.
from bazel-gazelle.
This directive hasn't been implemented. Is this a go_test
that ends up broken or something else?
Sorry I don't know enough about jsonnet to advise. Good luck though.
from bazel-gazelle.
Consider yourself lucky. Perhaps cel-spec could make a fine replacement? Will that be supported in rules_go?
from bazel-gazelle.
rules_go just supports Go and proto. I avoid adding support for too many other tools, since it adds dependencies for users.
I'm sure CEL rules could be written for Bazel, but I'm not sure if anyone is already planning to do so.
from bazel-gazelle.
@jayconrod did anything like this ever land? This would be SUPER useful in go_repository rules. I have a number of third party deps whose tests "fan out" into problematic deps; if I could write things like:
build_directives = ["gazelle:exclude testing", "gazelle:skiprule go_default_test"],
I could prune a bunch of things out of our build tree.
from bazel-gazelle.
^^ btw I have a working patch for this if there is interest!
from bazel-gazelle.
@dragonsinth No this is still open. Feel free to send a patch. I changed the directive name in the first comment from skiprule
to skip
.
For the example you gave, # gazelle:skip
would only skip generating a particular target, not all targets with a matching name. So I wonder if this might work better:
build_directives = ["gazelle:exclude **_test.go"],
#37 is a related issue: probably would be good to disable generation of all test targets in go_repository
.
from bazel-gazelle.
@dragonsinth No this is still open. Feel free to send a patch. I changed the directive name in the first comment from
skiprule
toskip
.For the example you gave,
# gazelle:skip
would only skip generating a particular target, not all targets with a matching name. So I wonder if this might work better:build_directives = ["gazelle:exclude **_test.go"],
Ah, that actually works just fine! Or rather in our particular case:
build_directives = ["gazelle:exclude testing", "gazelle:exclude **/**_test.go"],
I didn't realize exclude would work on the file level!
So this solves my problem, and would allow me to unfork our skiprule
implementation. But if you want a skip
feature, happy to push you a PR. (It doesn't have test coverage, tho.)
from bazel-gazelle.
Actually the patch I used is pretty small... just gonna drop it here:
diff --git a/language/go/config.go b/language/go/config.go
index 98126b141c..ee425a39be 100644
--- a/language/go/config.go
+++ b/language/go/config.go
@@ -115,6 +115,9 @@ type goConfig struct {
// attribute.
repoNamingConvention map[string]namingConvention
+ // A list of rule names to skip generating rules for.
+ skipRule map[string]bool
+
// submodules is a list of modules which have the current module's path
// as a prefix of their own path. This affects visibility attributes
// in internal packages.
@@ -335,6 +338,7 @@ func (*goLang) KnownDirectives() []string {
"go_visibility",
"importmap_prefix",
"prefix",
+ "skiprule",
}
}
@@ -570,6 +574,13 @@ Update io_bazel_rules_go to a newer version in your WORKSPACE file.`
case "prefix":
setPrefix(d.Value)
+
+ case "skiprule":
+ list := splitValue(d.Value)
+ gc.skipRule = map[string]bool{}
+ for _, e := range list {
+ gc.skipRule[e] = true
+ }
}
}
diff --git a/language/go/generate.go b/language/go/generate.go
index 2892948d38..7812878230 100644
--- a/language/go/generate.go
+++ b/language/go/generate.go
@@ -278,7 +278,11 @@ func (gl *goLang) GenerateRules(args language.GenerateArgs) language.GenerateRes
g.generateTest(pkg, libName))
}
+ gc := getGoConfig(c)
for _, r := range rules {
+ if gc.skipRule[r.Name()] {
+ continue
+ }
if r.IsEmpty(goKinds[r.Kind()]) {
res.Empty = append(res.Empty, r)
} else {
from bazel-gazelle.
Is there a directive that we can use to skip a whole directory?
from bazel-gazelle.
Related Issues (20)
- Gazelle fails on macOS when using `apple_support` and go version 1.22+ HOT 8
- Cyclical Indirect Dependencies & Go.work can cause divergence HOT 1
- Add support for generated files in gazelle HOT 1
- Gazelle should extract module mappings from imported foo.MODULE.bazel files
- Passing debug_mode via go_deps to go_repository is not supported HOT 2
- Latest gazelle breaks grpc/grpc HOT 5
- Gazelle crashes in repository with MODULE but no WORKSPACE HOT 2
- `go_repository_cache` repository rule doesn't handle MacOS arm64 platform HOT 2
- How to create go_proto_library automatically
- Optimize Gazelle's filesystem walk
- gazelle:resolve_regexp should support regex in label HOT 4
- Using the repo name rules_go removes proto embed from all go_library rules HOT 1
- Gazelle cannot parse new go.mod directives HOT 5
- `rules_go` should work with Go versions older than 1.20
- go.mod FilePath ReplaceDirective fails copying folder. HOT 5
- gazelle fails to fetch some repositories loaded with `go_deps.from_file(go_mod = "//:go.mod")` HOT 3
- request: option to not generate in all directories
- "No repository visible as '@rules_go'" when running gazelle managed by bzlmod HOT 11
- Issue understanding relative proto resolution
- Feature Request: Record Service and Message names in Proto's fileInfo
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bazel-gazelle.