Skip to content

Fix gating code formatter & linter jobs - #22

Merged
LittleHuba merged 2 commits into
eclipse-score:mainfrom
yolani:cvlf/share_vscode_ruff_config
Oct 2, 2026
Merged

LittleHuba merged 2 commits into
eclipse-score:mainfrom
yolani:cvlf/share_vscode_ruff_config

Conversation

@yolani

@yolani yolani commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • 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.

@yolani
yolani force-pushed the cvlf/share_vscode_ruff_config branch 4 times, most recently from 48873f1 to fd83ef0 Compare September 29, 2026 13:06
@github-advanced-security

Copy link
Copy Markdown

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:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@yolani
yolani force-pushed the cvlf/share_vscode_ruff_config branch 3 times, most recently from ef0e181 to 5a80550 Compare September 29, 2026 13:42
Comment thread score/ecu_model/BUILD Fixed
@yolani
yolani force-pushed the cvlf/share_vscode_ruff_config branch 2 times, most recently from 677febd to 7b4660d Compare September 29, 2026 13:54
@yolani
yolani force-pushed the cvlf/share_vscode_ruff_config branch 3 times, most recently from ad5cb59 to 5fd4552 Compare September 29, 2026 14:42
@yolani yolani changed the title Cvlf/share vscode ruff config Fix gating code formatter & linter jobs Sep 30, 2026
@yolani
yolani force-pushed the cvlf/share_vscode_ruff_config branch 3 times, most recently from 490d3fc to 87f13b0 Compare September 30, 2026 08:21
Comment thread .github/actions/merge_sarif_reports/action.yml
Comment thread .github/workflows/linter.yaml
Comment thread tools/buildifier
Comment thread .bazelrc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@yolani
yolani force-pushed the cvlf/share_vscode_ruff_config branch from 87f13b0 to 0f2fc5f Compare September 30, 2026 11:36
@yolani
yolani force-pushed the cvlf/share_vscode_ruff_config branch 2 times, most recently from cebf2cb to c670ac6 Compare September 30, 2026 12:15
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.
@yolani
yolani force-pushed the cvlf/share_vscode_ruff_config branch from c670ac6 to 418a7d6 Compare September 30, 2026 12:34
Signed-off-by: Christian von Lani-Fischer <christian.vonlani-fischer@bmw.de>

@LittleHuba LittleHuba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@LittleHuba
LittleHuba added this pull request to the merge queue Oct 2, 2026
Merged via the queue into eclipse-score:main with commit 8180deb Oct 2, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants