cgrindel / rules_swiftformat

Bazel rules that format Swift source files using nicklockwood/SwiftFormat.
Apache License 2.0
8 stars 0 forks source link

Migrate formatting check to be a validation action? #102

Closed cgrindel closed 1 year ago

cgrindel commented 1 year ago

Bazel doc

cgrindel commented 1 year ago

Interesting posts

Interesting quotes

As above, if you have a separate validation target, then it's tricky to actually trigger the validation target. Validation actions were basically intended to be put inside the target that creates the artifact to be validated. But the aspect approach below should work.

https://groups.google.com/g/bazel-discuss/c/euTqZeYR8hs/m/3x91KbQFAQAJ

cgrindel commented 1 year ago

Given that the goal is not to integrate linting/formatting into the swift_xxx rules, I am not sure that validation groups is helpful. However, it may be useful to use an aspect to find Swift source files and add actions. This would obsolete the need for swift_tidy_pkg/swiftformat_pkg.

cgrindel commented 1 year ago

With an aspect, I understand how I can generate the formatted file. However, I am not sure how I could define test targets for diff_test. I think that the Gazelle plugin may be the best path forward, for now.