Skip to content

Commit

Permalink
Added outcome filtering parameter #171 (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
BernieWhite authored Oct 17, 2022
1 parent 22484ee commit 8af9d5c
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 106 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
with:
inputType: repository
modules: PSRule.Rules.MSFT.OSS
outcome: Problem

- name: Unregister repository
shell: pwsh
Expand Down
130 changes: 65 additions & 65 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
{
"default": true,
"header-increment": true,
"first-header-h1": {
"level": 1
},
"header-style": {
"style": "atx"
},
"ul-style": {
"style": "dash"
},
"list-indent": true,
"ul-start-left": true,
"ul-indent": {
"indent": 2
},
"no-trailing-spaces": true,
"no-hard-tabs": true,
"no-reversed-links": true,
"no-multiple-blanks": true,
"line-length": {
"line_length": 100,
"code_blocks": false,
"tables": false,
"headers": true
},
"commands-show-output": true,
"no-missing-space-atx": true,
"no-multiple-space-atx": true,
"no-missing-space-closed-atx": true,
"no-multiple-space-closed-atx": true,
"blanks-around-headers": true,
"header-start-left": true,
"no-duplicate-header": true,
"single-h1": true,
"no-trailing-punctuation": {
"punctuation": ".,;:!"
},
"no-multiple-space-blockquote": true,
"no-blanks-blockquote": true,
"ol-prefix": {
"style": "one_or_ordered"
},
"list-marker-space": true,
"blanks-around-fences": true,
"blanks-around-lists": true,
"no-bare-urls": true,
"hr-style": {
"style": "---"
},
"no-emphasis-as-header": true,
"no-space-in-emphasis": true,
"no-space-in-code": true,
"no-space-in-links": true,
"fenced-code-language": false,
"first-line-h1": false,
"no-empty-links": true,
"proper-names": {
"names": [
"PowerShell",
"JavaScript"
],
"code_blocks": false
},
"no-alt-text": true
"default": true,
"header-increment": true,
"first-header-h1": {
"level": 1
},
"header-style": {
"style": "atx"
},
"ul-style": {
"style": "dash"
},
"list-indent": true,
"ul-start-left": true,
"ul-indent": {
"indent": 2
},
"no-trailing-spaces": true,
"no-hard-tabs": true,
"no-reversed-links": true,
"no-multiple-blanks": true,
"line-length": {
"line_length": 100,
"code_blocks": false,
"tables": false,
"headers": true
},
"commands-show-output": true,
"no-missing-space-atx": true,
"no-multiple-space-atx": true,
"no-missing-space-closed-atx": true,
"no-multiple-space-closed-atx": true,
"blanks-around-headers": true,
"header-start-left": true,
"no-duplicate-header": true,
"single-h1": true,
"no-trailing-punctuation": {
"punctuation": ".,;:!"
},
"no-multiple-space-blockquote": true,
"no-blanks-blockquote": true,
"ol-prefix": {
"style": "one_or_ordered"
},
"list-marker-space": true,
"blanks-around-fences": true,
"blanks-around-lists": true,
"no-bare-urls": true,
"hr-style": {
"style": "---"
},
"no-emphasis-as-header": true,
"no-space-in-emphasis": true,
"no-space-in-code": true,
"no-space-in-links": true,
"fenced-code-language": false,
"first-line-h1": false,
"no-empty-links": true,
"proper-names": {
"names": [
"PowerShell",
"JavaScript"
],
"code_blocks": false
},
"no-alt-text": true
}
14 changes: 7 additions & 7 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"recommendations": [
"github.vscode-pull-request-github",
"ms-vscode.powershell",
"davidanson.vscode-markdownlint",
"redhat.vscode-yaml",
"streetsidesoftware.code-spell-checker"
]
"recommendations": [
"github.vscode-pull-request-github",
"ms-vscode.powershell",
"davidanson.vscode-markdownlint",
"redhat.vscode-yaml",
"streetsidesoftware.code-spell-checker"
]
}
48 changes: 29 additions & 19 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
{
"files.exclude": {
"reports/": true,
"out/": true,
".vs/": true
},
"search.exclude": {
"out/": true
},
"editor.insertSpaces": true,
"editor.tabSize": 4,
"[yaml]": {
"editor.tabSize": 2
},
"[markdown]": {
"editor.tabSize": 2
},
"cSpell.words": [
"SARIF"
]
"files.exclude": {
"reports/": true,
"out/": true,
".vs/": true
},
"search.exclude": {
"out/": true
},
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"editor.tabSize": 4,
"editor.formatOnSave": true,
"files.insertFinalNewline": true,
"yaml.format.singleQuote": true,
"[yaml]": {
"editor.tabSize": 2
},
"[markdown]": {
"editor.tabSize": 2
},
"[json]": {
"editor.tabSize": 2
},
"[jsonc]": {
"editor.tabSize": 2
},
"cSpell.words": [
"SARIF"
]
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This project welcomes contributions and suggestions. Most contributions require you to
agree to a Contributor License Agreement (CLA) declaring that you have the right to,
and actually do, grant us the rights to use your contribution. For details, visit
https://cla.microsoft.com.
<https://cla.microsoft.com>.

When you submit a pull request, a CLA-bot will automatically determine whether you need
to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ For a list of changes please see the [change log][2].
baseline: string # Optional. The name of a PSRule baseline to use.
conventions: string # Optional. A comma separated list of conventions to use.
option: string # Optional. The path to an options file.
outcome: Fail, Pass, Error, Processed, Problem, All # Optional. Filters output to include results with the specified outcome.
outputFormat: None, Yaml, Json, NUnit3, Csv, Markdown, Sarif # Optional. The format to use when writing results to disk.
outputPath: string # Optional. The file path to write results to.
path: string # Optional. The working directory PSRule is run from.
Expand Down Expand Up @@ -122,6 +123,12 @@ The path to an options file.
By default, `ps-rule.yaml` will be used if it exists.
Configure this parameter to use a different file.

### `outcome`

Filters output to include results with the specified outcome.
Supported outcomes are `Fail`, `Pass`, `Error`, `Processed`, `Problem`, `All`.
Defaults to `Processed`.

### `outputFormat`

The output format to write result to disk.
Expand Down Expand Up @@ -222,7 +229,7 @@ Rule 'GitHub.Community' -Type 'PSRule.Data.RepositoryInfo' {
This project welcomes contributions and suggestions. Most contributions require you to
agree to a Contributor License Agreement (CLA) declaring that you have the right to,
and actually do, grant us the rights to use your contribution. For details, visit
https://cla.microsoft.com.
<https://cla.microsoft.com>.

When you submit a pull request, a CLA-bot will automatically determine whether you need
to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the
Expand Down
16 changes: 10 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ branding:
icon: 'check-circle'
color: 'green'
inputs:

inputType:
description: 'Determines the type of input to use for PSRule.'
default: 'repository'
Expand Down Expand Up @@ -44,6 +43,11 @@ inputs:
default: ''
required: false

outcome:
description: 'Filters output to include results with the specified outcome.'
default: ''
required: false

outputFormat:
description: 'The format to use when writing results to disk. When set to None results are not written to disk.'
default: 'None'
Expand Down Expand Up @@ -77,8 +81,8 @@ inputs:
runs:
using: 'composite'
steps:
- name: 'Analysis'
shell: pwsh
working-directory: ${{ github.workspace }}
run: |-
${{ github.action_path }}/powershell.ps1 -InputType '${{ inputs.inputType }}' -InputPath '${{ inputs.inputPath }}' -Modules '${{ inputs.modules }}' -Source '${{ inputs.source }}' -Baseline '${{ inputs.baseline }}' -Conventions '${{ inputs.conventions }}' -Option '${{ inputs.option }}' -OutputFormat '${{ inputs.outputFormat }}' -OutputPath '${{ inputs.outputPath }}' -Path '${{ inputs.path }}' -PreRelease '${{ inputs.prerelease }}' -Repository '${{ inputs.repository }}' -Version '${{ inputs.version }}'
- name: 'Analysis'
shell: pwsh
working-directory: ${{ github.workspace }}
run: |-
${{ github.action_path }}/powershell.ps1 -InputType '${{ inputs.inputType }}' -InputPath '${{ inputs.inputPath }}' -Modules '${{ inputs.modules }}' -Source '${{ inputs.source }}' -Baseline '${{ inputs.baseline }}' -Conventions '${{ inputs.conventions }}' -Option '${{ inputs.option }}' -Outcome '${{ inputs.outcome }}' -OutputFormat '${{ inputs.outputFormat }}' -OutputPath '${{ inputs.outputPath }}' -Path '${{ inputs.path }}' -PreRelease '${{ inputs.prerelease }}' -Repository '${{ inputs.repository }}' -Version '${{ inputs.version }}'
3 changes: 3 additions & 0 deletions docs/CHANGELOG-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ See [upgrade notes][upgrade-notes] for helpful information when upgrading from p

What's changed since v2.4.2:

- General improvements:
- Added outcome filtering parameter by @BernieWhite.
[#171](https://github.com/microsoft/ps-rule/issues/171)
- Engineering:
- Bump PSRule to v2.5.0.
[#194](https://github.com/microsoft/ps-rule/pull/194)
Expand Down
8 changes: 8 additions & 0 deletions powershell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ param (
[Parameter(Mandatory = $False)]
[String]$Option = $Env:INPUT_OPTION,

# Filters output to include results with the specified outcome.
[Parameter(Mandatory = $False)]
[String]$Outcome = $Env:INPUT_OUTCOME,

# The output format
[Parameter(Mandatory = $False)]
[ValidateSet('None', 'Yaml', 'Json', 'NUnit3', 'Csv', 'Markdown', 'Sarif')]
Expand Down Expand Up @@ -251,6 +255,10 @@ try {
$invokeParams['Option'] = $Option;
WriteDebug ([String]::Concat('-Option ', $Option));
}
if (![String]::IsNullOrEmpty($Outcome)) {
$invokeParams['Outcome'] = $Outcome;
WriteDebug ([String]::Concat('-Outcome ', $Outcome));
}
if (![String]::IsNullOrEmpty($OutputFormat) -and ![String]::IsNullOrEmpty($OutputPath) -and $OutputFormat -ne 'None') {
$invokeParams['OutputFormat'] = $OutputFormat;
$invokeParams['OutputPath'] = $OutputPath;
Expand Down
1 change: 0 additions & 1 deletion ps-project.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

info:
name: PSRule
description: Validate infrastructure as code (IaC) and DevOps repositories using GitHub Actions.
Expand Down
10 changes: 5 additions & 5 deletions ps-rule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
# https://microsoft.github.io/PSRule/

requires:
PSRule: '@pre >=1.11.0'
PSRule: "@pre >=1.11.0"

output:
culture:
- en-US
- en-US

input:
pathIgnore:
- '*.md'
- '*.json'
- '.vscode/'
- "*.md"
- "*.json"
- ".vscode/"
2 changes: 1 addition & 1 deletion scripts/dependencies.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function Update-Dependencies {
$devDependencies = CheckVersion $modules.devDependencies -Repository $Repository -Dev;

$modules = [Ordered]@{
dependencies = $dependencies
dependencies = $dependencies
devDependencies = $devDependencies
}
$modules | ConvertTo-Json -Depth 10 | Set-Content -Path $Path;
Expand Down

0 comments on commit 8af9d5c

Please sign in to comment.