Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ What's changed since pre-release v1.48.0-B0228:
[#2159](https://github.com/Azure/PSRule.Rules.Azure/issues/2159)
- Added support for the Bicep `distinct` and `like` functions by @oWretch.
[#3905](https://github.com/Azure/PSRule.Rules.Azure/issues/3905)
- Added documentation for limiting analysis to changed files with `input.ignoreUnchangedPath` by @MaxonT.
[#716](https://github.com/Azure/PSRule.Rules.Azure/issues/716)
- Updated rules:
- App Service:
- Fixed `Azure.AppService.PlanInstanceCount` to exclude Flex Consumption plans.
Expand Down
29 changes: 29 additions & 0 deletions docs/creating-your-pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,35 @@ You can use the `inputPath` parameter to limit the analysis to a specific file o
Assert-PSRule -InputPath 'azure/modules/' -Module $modules -Format File -ErrorAction Stop;
```

### Limiting input to changed files

By default, PSRule will scan all files within the input path.
For a pull request, you may only be interested in the files that have changed.
Set the `input.ignoreUnchangedPath` option to `true` to ignore files that have not changed.

```yaml title="ps-rule.yaml"
input:
ignoreUnchangedPath: true
```

PSRule uses git to compare the current commit with the base branch of the pull request.
By default, the base branch is detected from variables set by the build system.
If no base branch is detected, PSRule compares with the previous commit.
Use the `repository.baseRef` option to set a different base branch.
If git is not available or the comparison fails, PSRule processes all files.
A shallow checkout may not include the base branch, so fetch enough history for the comparison to work.
For example, set `fetch-depth: 0` on `actions/checkout`.

!!! Tip
Ignoring unchanged files is useful when new rules have been introduced.
Existing files in the repository that were not modified by the pull request are not analyzed,
so they are not reported as failing the new rules.

For more information, see the [`Input.IgnoreUnchangedPath`][12] and [`Repository.BaseRef`][13] options.

[12]: https://microsoft.github.io/PSRule/v2/concepts/PSRule/en-US/about_PSRule_Options/#inputignoreunchangedpath
[13]: https://microsoft.github.io/PSRule/v2/concepts/PSRule/en-US/about_PSRule_Options/#repositorybaseref

### Configuring a baseline

You can set the `baseline` parameter to specify the name of a baseline to use.
Expand Down