From 280bcb0b932bfd95a46dd8264a0d88a07b4168ee Mon Sep 17 00:00:00 2001 From: Ym <173550318+MaxonT@users.noreply.github.com> Date: Sat, 28 Nov 2026 23:12:59 -0600 Subject: [PATCH] Add docs for limiting input to changed files Signed-off-by: Ym <173550318+MaxonT@users.noreply.github.com> --- docs/changelog.md | 2 ++ docs/creating-your-pipeline.md | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 73d6d60f0ba..a8005b66e64 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -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. diff --git a/docs/creating-your-pipeline.md b/docs/creating-your-pipeline.md index 97db1857908..4c87c0c0ee5 100644 --- a/docs/creating-your-pipeline.md +++ b/docs/creating-your-pipeline.md @@ -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.