Repository navigation
Fix gating code formatter & linter jobs - #22
Conversation
48873f1 to
fd83ef0
Compare
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
ef0e181 to
5a80550
Compare
677febd to
7b4660d
Compare
ad5cb59 to
5fd4552
Compare
490d3fc to
87f13b0
Compare
There was a problem hiding this comment.
I would change the mode here. This script should be run through bazel.
Currently you loose hermeticity here. E.g. the script assumes that jq is available on host.
I would recommend, that you create an aspect for rules_lint that uses buildifier and generates the sarif report per call. Then you have the exact infrastructure that we have for all other linters.
There was a problem hiding this comment.
Unfortunatly i explicitly did this on purpose... The buildifier aspect only visits bzl_library targets by default, other BUILD or .*bzl files have to be explicitly put in filegroups with certain tags, see here. That means i would have to create one filegroup per bazel package (about 30 already just for this small repo) and also maintain them.
I would rather delete the sarif conversion. It's a comfort feature anyway, also without the report injected into code scanning the buildifier check itself will work.
What i can do is add an additional stap in the workflow to make sure the required commandline tools are there.
87f13b0 to
0f2fc5f
Compare
cebf2cb to
c670ac6
Compare
Make the ruff and buildifier setup reproducible across VS Code, the git hooks and CI, and surface findings as GitHub code scanning alerts. Editor: - Share the .vscode settings and extension recommendations: bundled ruff as Python formatter, Pylance search paths for the Bazel pip and protobuf repositories, and buildifier via tools/buildifier, a wrapper around the hermetic Bazel binary. Lint configuration: - Enable the ruff rules I, UP and SIM on top of the defaults and mark score as first-party so import sorting matches the Bazel lint aspect. - Fix all existing ruff and buildifier findings, including loading proto_library/ProtoInfo from @com_google_protobuf and adding the missing rules_shell dependency. Git hooks: - Add a pre-commit hook running ruff check/format and buildifier (formatting plus all lint warnings) with the repository config. Install it with `bazel run //:install_hooks`. - Drop the ruff.check/ruff.fix wrapper targets in favour of the hook. CI: - Run buildifier recursively in its own linter job and convert its findings to SARIF, pointing formatting findings at the changed lines. - Gate ruff with the aspect lint "hard" strategy, add the missing rule IDs to its SARIF and upload both reports to code scanning. - Fail the SARIF merge step with a clear error if the lint build did not produce a build event file.
c670ac6 to
418a7d6
Compare
Signed-off-by: Christian von Lani-Fischer <christian.vonlani-fischer@bmw.de>
LittleHuba
left a comment
There was a problem hiding this comment.
Accepting this with the known open conversation for buildifier not running through rules_lint.
There is currently no immediate better way. We agreed to look into a rules-lint native way in a follow-up.
Share lint tooling and enforce ruff and buildifier checks
Make the ruff and buildifier setup reproducible across VS Code, the git
hooks and CI, and surface findings as GitHub code scanning alerts.
Editor:
ruff as Python formatter, Pylance search paths for the Bazel pip and
protobuf repositories, and buildifier via tools/buildifier, a wrapper
around the hermetic Bazel binary.
Lint configuration:
score as first-party so import sorting matches the Bazel lint aspect.
proto_library/ProtoInfo from @com_google_protobuf and adding the
missing rules_shell dependency.
Git hooks:
(formatting plus all lint warnings) with the repository config.
Install it with
bazel run //:install_hooks.CI:
findings to SARIF, pointing formatting findings at the changed lines.
IDs to its SARIF and upload both reports to code scanning.
not produce a build event file.