This commit is contained in:
Bernie White 2022-01-06 09:49:36 +10:00 коммит произвёл GitHub
Родитель e4788547e5
Коммит 5a907c0fea
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
11 изменённых файлов: 95 добавлений и 97 удалений

Просмотреть файл

@ -5,9 +5,9 @@ variables:
version: '0.3.0'
buildConfiguration: 'Release'
disable.coverage.autogenerate: 'true'
imageName: 'ubuntu-18.04'
imageName: 'ubuntu-20.04'
# Use build number format, i.e. 0.3.0-B2005001
# Use build number format, i.e. 0.3.0-B2205001
name: $(version)-B$(date:yyMM)$(rev:rrr)
trigger:
@ -67,11 +67,13 @@ stages:
displayName: Analysis
dependsOn: []
jobs:
- job: Secret_Scan
pool: 'Hosted VS2017'
displayName: Secret scan
- job: Secret_Scan
pool:
vmImage: 'windows-2019'
displayName: Secret scan
steps:
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2
displayName: 'Scan for secrets'
inputs:
@ -95,45 +97,48 @@ stages:
- template: jobs/test.yaml
parameters:
name: ubuntu_18_04_coverage
imageName: 'ubuntu-18.04'
name: ubuntu_20_04_coverage
imageName: 'ubuntu-20.04'
displayName: 'PowerShell coverage'
coverage: 'true'
platform: linux
publishResults: 'false'
- template: jobs/test.yaml
parameters:
name: macOS_10_15
displayName: 'PowerShell 6.2.4 - macOS-10.15'
displayName: 'PowerShell 7.1 - macOS-10.15'
imageName: 'macOS-10.15'
platform: macos
- template: jobs/test.yaml
parameters:
name: windows
displayName: 'PowerShell 5.1 - win2016'
imageName: 'vs2017-win2016'
name: ps_5_1_windows_2019
displayName: 'PowerShell 5.1 - Windows 2019'
imageName: 'windows-2019'
platform: windows
pwsh: 'false'
# Currently can't use alpine because addtional tools for Azure DevOps are required
# - template: jobs/testContainer.yaml
# parameters:
# name: alpine_3_10
# displayName: 'PowerShell 7.0 - alpine-3.10'
# imageName: mcr.microsoft.com/powershell
# imageTag: 7.0.0-alpine-3.10
- template: jobs/test.yaml
parameters:
name: ps_7_2_windows_2019
displayName: 'PowerShell 7.2 - Windows 2019'
imageName: 'windows-2019'
platform: windows
- template: jobs/testContainer.yaml
parameters:
name: ps_7_ubuntu_18_04
displayName: 'PowerShell 7.0 - ubuntu-18.04'
name: ps_7_2_ubuntu_18_04
displayName: 'PowerShell 7.2 - ubuntu-18.04'
imageName: mcr.microsoft.com/powershell
imageTag: 7.0.0-ubuntu-18.04
imageTag: 7.2.0-ubuntu-18.04
- template: jobs/testContainer.yaml
parameters:
name: ps_6_ubuntu_18_04
displayName: 'PowerShell 6.2.4 - ubuntu-18.04'
name: ps_7_2_ubuntu_20_04
displayName: 'PowerShell 7.2 - ubuntu-20.04'
imageName: mcr.microsoft.com/powershell
imageTag: 6.2.4-ubuntu-18.04
imageTag: 7.2.0-ubuntu-20.04
# Release pipeline
- stage: Release

Просмотреть файл

@ -8,6 +8,7 @@ parameters:
imageName: ''
coverage: 'false'
publishResults: 'true'
platform: 'linux'
jobs:
- job: ${{ parameters.name }}
@ -35,6 +36,7 @@ jobs:
- powershell: Invoke-Build TestModule -Configuration ${{ parameters.buildConfiguration }} -Build $(Build.BuildNumber)
env:
COVERAGE: ${{ parameters.coverage }}
RUN_BICEP_INTEGRATION: ${{ parameters.bicepIntegration }}
displayName: 'Test module'
# Pester test results

Просмотреть файл

@ -5,7 +5,7 @@ parameters:
name: ''
displayName: ''
buildConfiguration: 'Release'
vmImage: 'ubuntu-16.04'
vmImage: 'ubuntu-20.04'
imageName: ''
imageTag: ''
coverage: 'false'

3
.github/workflows/analyze.yaml поставляемый
Просмотреть файл

@ -15,3 +15,6 @@ jobs:
- name: Run PSRule analysis
uses: Microsoft/ps-rule@main
with:
modules: 'PSRule.Rules.MSFT.OSS'
prerelease: true

Просмотреть файл

@ -1,22 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Synopsis: Check for recommended community files
Rule 'OpenSource.Community' -Type 'PSRule.Data.RepositoryInfo' {
$Assert.FilePath($TargetObject, 'FullName', @('CHANGELOG.md'));
$Assert.FilePath($TargetObject, 'FullName', @('LICENSE'));
$Assert.FilePath($TargetObject, 'FullName', @('CODE_OF_CONDUCT.md'));
$Assert.FilePath($TargetObject, 'FullName', @('CONTRIBUTING.md'));
$Assert.FilePath($TargetObject, 'FullName', @('SECURITY.md'));
$Assert.FilePath($TargetObject, 'FullName', @('README.md'));
$Assert.FilePath($TargetObject, 'FullName', @('.github/CODEOWNERS'));
$Assert.FilePath($TargetObject, 'FullName', @('.github/PULL_REQUEST_TEMPLATE.md'));
}
# Synopsis: Check for license in code files
Rule 'OpenSource.License' -Type '.cs', '.ps1', '.psd1', '.psm1' {
$Assert.FileHeader($TargetObject, 'FullName', @(
'Copyright (c) Microsoft Corporation.'
'Licensed under the MIT License.'
));
}

2
.vscode/tasks.json поставляемый
Просмотреть файл

@ -6,7 +6,7 @@
{
"label": "test",
"type": "shell",
"command": "Invoke-Build Test -AssertStyle Client",
"command": "Invoke-Build Test -AssertStyle Detect",
"group": {
"kind": "test",
"isDefault": true

Просмотреть файл

@ -16,7 +16,6 @@ If you have any problems with the [PSRule][project] engine, please check the pro
## Getting the modules
This project requires the `PSRule` PowerShell module.
You can download and install these modules from the PowerShell Gallery.
Module | Description | Downloads / instructions

17
SUPPORT.md Normal file
Просмотреть файл

@ -0,0 +1,17 @@
# Support
## How to file issues and get help
This project uses GitHub Issues to track bugs and feature requests.
Please search the existing issues before filing new issues to avoid duplicates.
- For new issues, file your bug or feature request as a new [issue].
- For help, discussion, and support questions about using this project, join or start a [discussion].
## Microsoft Support Policy
Support for this project/ product is limited to the resources listed above.
[issue]: https://github.com/microsoft/PSRule.Rules.Kubernetes/issues
[discussion]: https://github.com/microsoft/PSRule.Rules.Kubernetes/discussions

Просмотреть файл

@ -85,44 +85,6 @@ function CopyModuleFiles {
}
}
function Get-RepoRuleData {
[CmdletBinding()]
param (
[Parameter(Position = 0, Mandatory = $False)]
[String]$Path = $PWD
)
process {
GetPathInfo -Path $Path -Verbose:$VerbosePreference;
}
}
function GetPathInfo {
[CmdletBinding()]
param (
[Parameter(Mandatory = $True)]
[String]$Path
)
begin {
$items = New-Object -TypeName System.Collections.ArrayList;
}
process {
$Null = $items.Add((Get-Item -Path $Path));
$files = @(Get-ChildItem -Path $Path -File -Recurse -Include *.ps1,*.psm1,*.psd1,*.cs | Where-Object {
!($_.FullName -like "*.Designer.cs") -and
!($_.FullName -like "*/bin/*") -and
!($_.FullName -like "*/obj/*") -and
!($_.FullName -like "*\obj\*") -and
!($_.FullName -like "*\bin\*") -and
!($_.FullName -like "*\out\*") -and
!($_.FullName -like "*/out/*")
});
$Null = $items.AddRange($files);
}
end {
$items;
}
}
task VersionModule ModuleDependencies, {
$modulePath = Join-Path -Path $ArtifactPath -ChildPath PSRule.Rules.Kubernetes;
$manifestPath = Join-Path -Path $modulePath -ChildPath PSRule.Rules.Kubernetes.psd1;
@ -182,7 +144,7 @@ task Pester NuGet, {
if ($Null -eq (Get-InstalledModule -Name Pester -RequiredVersion 4.10.1 -ErrorAction Ignore)) {
Install-Module -Name Pester -RequiredVersion 4.10.1 -Scope CurrentUser -Force -SkipPublisherCheck;
}
Import-Module -Name Pester -Verbose:$False;
Import-Module -Name Pester -RequiredVersion 4.10.1 -Verbose:$False;
}
# Synopsis: Install PSScriptAnalyzer module
@ -203,8 +165,8 @@ task PSRule NuGet, {
# Synopsis: Install PSDocs
task PSDocs NuGet, {
if ($Null -eq (Get-InstalledModule -Name PSDocs -MinimumVersion 0.6.3 -ErrorAction Ignore)) {
Install-Module -Name PSDocs -MinimumVersion 0.6.3 -AllowPrerelease -Scope CurrentUser -Force;
if ($Null -eq (Get-InstalledModule -Name PSDocs -MinimumVersion 0.9.0 -ErrorAction Ignore)) {
Install-Module -Name PSDocs -MinimumVersion 0.9.0 -AllowPrerelease -Scope CurrentUser -Force;
}
Import-Module -Name PSDocs -Verbose:$False;
}
@ -256,12 +218,13 @@ task Rules PSRule, {
$assertParams = @{
Path = './.ps-rule/'
Style = $AssertStyle
OutputFormat = 'NUnit3';
OutputFormat = 'NUnit3'
ErrorAction = 'Stop'
As = 'Summary'
}
Import-Module (Join-Path -Path $PWD -ChildPath out/modules/PSRule.Rules.Kubernetes) -Force;
Get-RepoRuleData -Path $PWD |
Assert-PSRule @assertParams -OutputPath reports/ps-rule-file.xml;
Assert-PSRule @assertParams -InputPath $PWD -Module PSRule.Rules.MSFT.OSS -Format File -OutputPath reports/ps-rule-file.xml;
Import-Module (Join-Path -Path $PWD -ChildPath out/modules/PSRule.Rules.Kubernetes) -Force;
$rules = Get-PSRule -Module PSRule.Rules.Kubernetes;
$rules | Assert-PSRule @assertParams -OutputPath reports/ps-rule-file2.xml;
}
@ -310,4 +273,4 @@ task Test Build, Rules, TestModule
task Release ReleaseModule, TagBuild
task . Build, Test
task . Build, Rules

Просмотреть файл

@ -1,4 +1,23 @@
# PSRule options for QA
#
# PSRule configuration
#
# Please see the documentation for all configuration options:
# https://microsoft.github.io/PSRule/
input:
pathIgnore:
- '.vscode/'
- '*.md'
- '*.Designer.cs'
- '*.resx'
- '*.sln'
- '*.txt'
- '*.html'
- '*.ico'
include:
path: []
binding:
targetName:
@ -8,3 +27,8 @@ binding:
output:
culture:
- en-US
configuration:
# Authoring rules
RULE_AUTHORING_ONLINE_HELP: 'https://github.com/microsoft/PSRule.Rules.Kubernetes/blob/main/docs/rules/en/'
RULE_AUTHORING_PREFIX: 'Kubernetes'

Просмотреть файл

@ -1,3 +1,10 @@
binding:
targetName:
- metadata.name
targetType:
- kind
useQualifiedName: true
execution:
notProcessedWarning: false
notProcessedWarning: true