-
Couldn't load subscription status.
- Fork 402
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| --- | ||
| name: precommit | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v2 | ||
| with: | ||
| python-version: '3.x' | ||
| - name: Install module from PSGallery | ||
| shell: pwsh | ||
| run: | | ||
| Set-PSRepository PSGallery -InstallationPolicy Trusted | ||
| Install-Module PSScriptAnalyzer -ErrorAction Stop | ||
| - uses: pre-commit/[email protected] | ||
| with: | ||
| extra_args: --all-files --show-diff-on-failure |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| repos: | ||
| #- repo: https://github.com/PowerShell/PSScriptAnalyzer | ||
| - repo: https://github.com/juju4/PSScriptAnalyzer | ||
| rev: 3e3b2d7b7548fc5513b367cb3a80860d5bfd24db | ||
| hooks: | ||
| - id: powershell_scriptanalyzer | ||
| # Note that client and server path may be different. | ||
| # 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this just be removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| #- repo: local | ||
| # hooks: | ||
| # - id: pwsh | ||
| # name: pwsh | ||
| # entry: Invoke-ScriptAnalyzer.ps1 -Settings PSGallery -Recurse -EnableExit -Severity Warning -Path . | ||
| # language: script | ||
| # always_run: true | ||
| # pass_filenames: false | ||
| # verbose: true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| - id: powershell_scriptanalyzer | ||
| name: Powershell lint with PSScriptAnalyzer | ||
| description: This runs PSScriptAnalyzer on your powershell files | ||
| entry: pre-commit powershell_scriptanalyzer | ||
| language: script | ||
| files: ^.*\.ps1$ | ||
| types: [text] | ||
| entry: pwsh -Command "Invoke-ScriptAnalyzer -Settings PSGallery -Recurse -ReportSummary -EnableExit -Path ." | ||
| require_serial: false | ||
| additional_dependencies: [] | ||
| minimum_pre_commit_version: '0' | ||
| pass_filenames: false | ||
| verbose: true |
Uh oh!
There was an error while loading. Please reload this page.