Skip to content
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

[Bug]: Custom yamlfmt does not get used #451

Open
menny opened this issue Dec 20, 2024 · 1 comment
Open

[Bug]: Custom yamlfmt does not get used #451

menny opened this issue Dec 20, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@menny
Copy link

menny commented Dec 20, 2024

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:

➜  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

@menny menny added the bug Something isn't working label Dec 20, 2024
@menny
Copy link
Author

menny commented Dec 20, 2024

A confusing behavior I see is that changing the custom runner target (yamlfmt_runner, by adding or changing one of the args in the target), and then running the format_test that depends on it, results in the test passing with beingcached:

➜  example git:(yaml-with-native-binary) ✗ bazel test //:format_custom_yaml
INFO: Analyzed target //:format_custom_yaml_YAML_with_yamlfmt (0 packages loaded, 4 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.101s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
//:format_custom_yaml_YAML_with_yamlfmt                         (cached) PASSED in 0.2s

Executed 0 out of 1 test: 1 test passes.
There were tests whose specified size is too big. Use the --test_verbose_timeout_warnings command line option to see which ones these are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant