Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add pre-commit-hooks+config to use with pre-commit.com#1879

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
juju4 wants to merge3 commits intoPowerShell:main
base:main
Choose a base branch
Loading
fromjuju4:devel-precommit3

Conversation

@juju4
Copy link

And self-apply in github workflows.

PR Summary

This allows easy integration withpre-commit that can be use to validate/lint code before commit (and also after/server side as per github workflow example).

  • .pre-commit-config.yaml is the pre-commit configuration that use a remote or local repo
  • .pre-commit-hooks.yaml is required for remote linter/validation repo
  • github precommit workflow to test server side. note that this use the PSGallery latest released version to validate current code.

Tested on Macos and Linux.
Note that current workflow fail is related to warnings as seen onhttps://github.com/juju4/PSScriptAnalyzer/actions/runs/3867323454/jobs/6592019858#step:5:3554
can change severity to errors if prefer.

Further improvement discussion inpre-commit/pre-commit#2645

PR Checklist

mkrakowiak-luminar reacted with thumbs up emojiguykisel reacted with rocket emoji
# Github image should be /usr/bin/pwsh
# Linux/Macos is usually /usr/local/bin/pwsh unless using a user scope
entry: /usr/bin/pwsh -Command "Invoke-ScriptAnalyzer -Settings PSGallery -Recurse -ReportSummary -EnableExit -Severity Warning -Path . "
# https://github.com/pre-commit/pre-commit/pull/2340#issuecomment-1098203344
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this just be removed?

Copy link
Author

Choose a reason for hiding this comment

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

If removed, should be somewhere in docs (where?) as user may need to adapt powershell path

Copy link
Collaborator

@bergmeisterbergmeister left a comment

Choose a reason for hiding this comment

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

I don't mind adding a CI enforcement check but against commit hooks using commit hooks because PSSA is a binary module and this would mean I'd need a separate shell for committing versus local testing.
Current CI setup seems to not be working anyway because when you run invoke-scriptanalyzer on repo like you do there ARE violations (which would need to be fixed first) , even when excluding theTests folder, which would be expected as well as running the default set of rules and not just the PSGallery ones.

@juju4
Copy link
Author

It's up to you if want CI with warning(continue-on-error) or not and if violation fixes should go into this PR too. if small or exclusions, certainly. if bigger, probably better separate.

Only warnings here but exit code is equivalent to error.
https://github.com/juju4/PSScriptAnalyzer/actions/runs/5984855087/job/16236411056#step:5:3575

@leandroscardua
Copy link

Hi There,

Do we have any news about it?
maybe we can review it again?

mloskot reacted with thumbs up emoji

@andyleejordan
Copy link
Member

Hi There,

Do we have any news about it? maybe we can review it again?

My question is: why do we have to host it in this repo? Can't people just write their own commit hooks? I don't want to sign onto maintaining a configuration for some random service 🤷

@juju4
Copy link
Author

My question is: why do we have to host it in this repo? Can't people just write their own commit hooks? I don't want to sign onto maintaining a configuration for some random service 🤷

imho, that's more a distribution channel than a configuration and pre-commit is probably not a random service, at least for developers.
Else, it opens a door to anyone doing in it with supply chain security issue.
And from what I can tell of most pre-commit integrations, they usually host the hook to allow easy integration to their repository. (examples:https://github.com/codespell-project/codespell,https://github.com/commitizen-tools/commitizen,https://github.com/Yelp/detect-secrets,https://github.com/aristanetworks/j2lint.git,https://github.com/ansible-community/ansible-lint.git...)
The config is more an example and used in the pre-commit github workflow.

@bergmeister
Copy link
Collaborator

Hi There,
Do we have any news about it? maybe we can review it again?

My question is: why do we have to host it in this repo? Can't people just write their own commit hooks? I don't want to sign onto maintaining a configuration for some random service 🤷

I am with you on that. I think we are open to improvements of our developer experience but ultimately the amount of external contributions is relatively low to not warrant this unless more people vote on wanting this, so far there is just one reaction on this PR.

andyleejordan reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@bergmeisterbergmeisterbergmeister requested changes

@andyleejordanandyleejordanAwaiting requested review from andyleejordan

+1 more reviewer

@JamesWTruherJamesWTruherJamesWTruher requested changes

Reviewers whose approvals may not affect merge requirements

Requested changes must be addressed to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@juju4@leandroscardua@andyleejordan@bergmeister@JamesWTruher

[8]ページ先頭

©2009-2025 Movatter.jp