aspect-build / aspect-build/rules_lint

[Bug]: Custom yamlfmt does not get used

Open
#451 4 comments 0 reactions 0 assignees View on GitHub
bug documentation help wanted
Dominant language
Starlark
Stars
154
Forks
125
Avg merge
3d 21h
Merged PRs (30d)
20

Description

### What happened?

I created a custom yamlfmt executable target, and used that in the `yaml` attribute in `format_test`.
See the example branch at https://github.com/menny/rules_lint/tree/yaml-with-native-binary

### Version

Development (host) and target OS/architectures:
mac arm

Output of `bazel --version`:
Bazelisk version: 1.20.0
Aspect CLI version: 2024.39.54-f22225e33
Build label: 7.1.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Thu Mar 21 18:08:59 2024 (1711044539)
Build timestamp: 1711044539
Build timestamp as int: 1711044539

Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file:
It's at `HEAD`. I assume it is very close to 1.0.7

Language(s) and/or frameworks involved:
yaml

### How to reproduce

Check out the branch at https://github.com/menny/rules_lint/tree/yaml-with-native-binary.
Under the `example` folder:
* I created a runnable target `yamlfmt_runner` using `native_binary` rule.
* I create a custom yaml-config file with ident-3 requirement
* I created a yaml file `violations.yml` with ident-2
* I created a `format_test` target `format_custom_yaml` that takes the custom runnable+config+violations

Running the test: `bazel test //:format_custom_yaml` passes:

```shell
➜ example git:(yaml-with-native-binary) ✗ bazel test //:format_custom_yaml
INFO: Analyzed target //:format_custom_yaml_YAML_with_yamlfmt (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
Target //:format_custom_yaml_YAML_with_yamlfmt up-to-date:
bazel-bin/format_custom_yaml_YAML_with_yamlfmt
INFO: Elapsed time: 0.338s, Critical Path: 0.24s
INFO: 2 processes: 2 darwin-sandbox.
INFO: Build completed successfully, 2 total actions
//:format_custom_yaml_YAML_with_yamlfmt PASSED in 0.2s
```

Running the binary `yamlfmt_runner` using bazel and passing the args shows the errors:

```
➜ example git:(yaml-with-native-binary) bazel run //:yamlfmt_runner -- -lint $PWD/violations.yml
INFO: Analyzed target //:yamlfmt_runner (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //:yamlfmt_runner up-to-date:
bazel-bin/yamlfmt_runner.exe
INFO: Elapsed time: 0.098s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/yamlfmt_runner.exe -conf ./custom_yamlfmt.yml -output_format default -quiet -lint /Users/mennyevendanan/dev/menny/rules_lint/example/violations.yml
The following files had formatting differences:

/Users/mennyevendanan/dev/menny/rules_lint/example/violations.yml
```

### Any other information?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the example/format_test target format_custom_yaml and the yamlfmt_runner target described in the reproduction. Run bazel test //:format_custom_yaml and compare it with the direct yamlfmt_runner invocation using custom_yamlfmt.yml and violations.yml. Done means the test uses the custom executable and detects the ident-2 violation under the ident-3 configuration.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.