feat: configure pre-commit hooks via CLI args, add no-banner-comment-check#39
feat: configure pre-commit hooks via CLI args, add no-banner-comment-check#39alexmohr wants to merge 1 commit into
Conversation
45520ab to
5eeef2c
Compare
db7edaf to
ede8cd8
Compare
|
Fyi @lh-sag this makes the cicd usage much closer to standard uv and makes usage in core feasible. #38 documents what core has and what is still missing here. |
With the recent supply-chain attacks e.g. trivy, is there a way to run scripts locally and w/o internet access? |
To run it locally you would need to point the uv config, as shown on the PR description, to a local file instead. But this isn't really practical for the CI. Are you mainly concerned about supply chain attacks? (Imho we're almost good to go here) Or do you need offline support? |
6b3e296 to
51576e9
Compare
477c064 to
9b1134e
Compare
alexmohr
left a comment
There was a problem hiding this comment.
After this PR merges to main, update line 43 of .pre-commit-config.yaml from rev: feat/pre-commit-hook-args-config to rev: main (or pin to the merge commit SHA for reproducibility). The branch name is used here because the SHA is not reachable from main until the PR merges.
9f42326 to
4449195
Compare
I am not comfortable that my local pre-commit runs scripts from a remote repository every time I invoke it. This would also require internet connectivity even if you develop fully locally. Cant we have a local one? |
I'll look into how these things can be cached when I really want to have the repos in sync because, so we can share common things like the markdown lint you added in core but no one else had enabled. If I don't find a way to fully achieve offline support I can agree on scrapping this. But I'm not ready to give this up just yet :) |
|
What I like in s-core is that they have another layer between CI and repository - bazel. For us this does not need to be bazel but we could offload e.g. build environment and certain configuration to a devcontainer. This can be re-used by developers and CI. I am happy that we have CI but github actions is quite annoying and if we can streamline CI w/o touching too much of the actions I would be more than happy. So the general question is how we want out CI/CD architecture to be? github actions + devcontainer + common entries, which allows for customization. There are more alternatives but I feel the s-core way is having benefit especially with our fragmented project setup. |
I personally prefer not having to use a devcontainer with a lot of things baked in because compiling it locally without any containers is just a bit easier imho.
The configuration should work fully offline now. I do need more testing though. As said above I'm all for seeking out benefits in getting closer to S-Core but we have to maintain an option to build "only" open SOVD. We probably should discuss next week what we can adopt from score right away, so we don't reinvent the wheel whole making integration also easier. I'm adding quite a few things here because these are mostly findings I kept commenting repeatedly on PRs |
fdb5145 to
489ddbd
Compare
489ddbd to
671b24a
Compare
|
Marking this as ready to review. Once this is merged, we can start using this in CDA eclipse-opensovd/classic-diagnostic-adapter#328 over the next 2-3 weeks. If we don't find any issues during this I would create pull requests to update the remaining repos. |
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| style_edition = "2024" |
There was a problem hiding this comment.
Summary
reuse-annotate-hook.py,no-unicode-check.py) now accept configuration as CLI args (--copyright,--license,--template,--ignore-paths,--allowed-chars) instead of env vars / patched constants.pre-commit-config.ymlunder each hook'sargs:block — no runtime patching neededrun_checks.pyno longer patches configs or hook scripts at runtime;patch_configandpatch_hook_scriptare removed along with all the flags they servedaction.ymldrops 6 flags from therun_checks.pyinvocation and setsSKIP=reuse-annotatedirectly in the step envpr-commit.pyadded as a zero-argument local entry point:uv run pr-commit.pyno-unicode-checkhook is now a static entry in.pre-commit-config.yml(previously injected at runtime), covering.py,.yml,.toml,.jinja2no-banner-comment-check.pyadded as a new hook to flag banner-style commentsLint strictness escalated in
shared-lints.toml:pedanticchanged fromwarntodeny(priority -1) — all pedantic lint violations will now hard-fail CI instead of warningclone_on_ref_ptrchanged fromwarntodeny— cloning reference-counted pointers via.clone()instead ofArc::clone()/Rc::clone()is now a CI failureConsumer repos with existing pedantic lint violations or
.clone()onArc/Rcwill see CI failures after upgrading. Remediation: fix the violations or temporarily override in the repo'sCargo.tomlwith[lints.clippy] pedantic = { level = "warn", priority = -1 }.Consumer migration
Consumer repos using a custom
.pre-commit-config.yml(viapre-commit-config-path) should configure the opensovd hooks aslocalentries pointing to pinned raw URLs:Each hook is configured entirely through its
args:block. Thefiles:pattern controls which extensions are checked.Checklist
Related
Closes #34, #36, #37 (features integrated into this branch and draft PRs closed)
See also: #40 (reusable conventional-commits and release workflows, split from this PR)
Notes for Reviewers
The
no-unicode-checkhook was previously injected into the config at runtime bypatch_config()— it is now a static hook entry in.pre-commit-config.yml. Consumers who relied onno-unicode-extensionsbeing empty (disabled) should remove theno-unicode-checkhook from their custom config.The
conventional-commits.ymlandrelease.ymlworkflows have been moved to a separate PR (#40) to keep this PR focused.Alexander Mohr alexander.m.mohr@mercedes-benz.com, Mercedes-Benz Tech Innovation GmbH
Provider Information