Skip to content

Commit 564bc84

Browse files
authored
Update metadata to align to recommended labels #14 #4 (#15)
1 parent e380669 commit 564bc84

17 files changed

Lines changed: 383 additions & 206 deletions

File tree

.azure-pipelines/azure-pipelines.yaml

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,28 @@ stages:
3131
strategy:
3232
matrix:
3333
Linux:
34+
displayName: 'Linux'
3435
imageName: 'ubuntu-16.04'
3536
MacOS:
37+
displayName: 'MacOS'
3638
imageName: 'macos-10.13'
3739
Windows:
40+
displayName: 'Windows'
3841
imageName: 'vs2017-win2016'
39-
publishModule: 'true'
42+
publish: 'true'
4043
analysis: 'true'
4144
coverage: 'true'
4245
pool:
4346
vmImage: $(imageName)
47+
displayName: 'PowerShell'
4448
steps:
4549

46-
# Install pipeline dependencies and build module
47-
- powershell: ./scripts/pipeline-build.ps1 -File ./pipeline.build.ps1 -Configuration $(buildConfiguration) -ModuleVersion $(Build.BuildNumber) -ReleaseVersion "$(Release.Version)"
50+
# Install pipeline dependencies
51+
- powershell: ./.azure-pipelines/pipeline-deps.ps1
52+
displayName: 'Install dependencies'
53+
54+
# Build module
55+
- powershell: Invoke-Build -Configuration $(buildConfiguration) -Build $(Build.BuildNumber)
4856
displayName: 'Build module'
4957

5058
# Pester test results
@@ -73,12 +81,24 @@ stages:
7381
# publishRunAttachments: true
7482
# condition: succeededOrFailed()
7583

76-
# Publish Code Coverage Results
84+
# Generate Code Coverage report
85+
- task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4
86+
displayName: 'Code coverage report generator'
87+
inputs:
88+
reports: 'reports\pester-coverage.xml'
89+
targetdir: 'reports\coverage'
90+
sourcedirs: 'src\PSRule.Rules.Kubernetes'
91+
reporttypes: 'HtmlInline_AzurePipelines;Cobertura;Badges'
92+
tag: $(Build.BuildNumber)
93+
condition: eq(variables['coverage'], 'true')
94+
95+
# Publish Code Coverage report
7796
- task: PublishCodeCoverageResults@1
7897
displayName: 'Publish Pester code coverage'
7998
inputs:
80-
codeCoverageTool: 'JaCoCo'
81-
summaryFileLocation: 'reports/pester-coverage.xml'
99+
codeCoverageTool: 'Cobertura'
100+
summaryFileLocation: 'reports/coverage/Cobertura.xml'
101+
reportDirectory: 'reports/coverage'
82102
condition: eq(variables['coverage'], 'true')
83103

84104
# Generate artifacts
@@ -87,24 +107,47 @@ stages:
87107
inputs:
88108
artifactName: PSRule.Rules.Kubernetes
89109
targetPath: out/modules/PSRule.Rules.Kubernetes
90-
condition: and(succeeded(), eq(variables['publishModule'], 'true'))
110+
condition: and(succeeded(), eq(variables['publish'], 'true'))
91111

92112
# Release pipeline
93113
- stage: Release
94114
displayName: Release
95115
dependsOn: Build
96-
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v0.')
116+
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v0.'))
97117
jobs:
98118
- job:
99119
displayName: Live
100120
pool:
101121
vmImage: 'ubuntu-16.04'
122+
variables:
123+
isPreRelease: $[contains(variables['Build.SourceBranchName'], '-B')]
102124
steps:
125+
126+
# Download module from build
103127
- task: DownloadPipelineArtifact@1
104128
displayName: 'Download module'
105129
inputs:
106130
artifactName: PSRule.Rules.Kubernetes
107131
downloadPath: $(Build.SourcesDirectory)/out/modules/PSRule.Rules.Kubernetes
108-
# Install pipeline dependencies and build module
109-
- powershell: ./scripts/pipeline-build.ps1 -File ./pipeline.build.ps1 -Task Release -NuGetApiKey $(apiKey)
132+
133+
# Install pipeline dependencies
134+
- powershell: ./.azure-pipelines/pipeline-deps.ps1
135+
displayName: 'Install dependencies'
136+
137+
# Install pipeline dependencies and build module
138+
- powershell: Invoke-Build Release -ApiKey $(apiKey)
110139
displayName: 'Publish module'
140+
141+
# Update GitHub release
142+
- task: GitHubRelease@0
143+
displayName: 'GitHub release'
144+
inputs:
145+
gitHubConnection: 'AzureDevOps-PSRule.Rules.Kubernetes'
146+
repositoryName: '$(Build.Repository.Name)'
147+
action: edit
148+
tag: '$(Build.SourceBranchName)'
149+
releaseNotesSource: input
150+
releaseNotes: 'See [change log](https://github.com/BernieWhite/PSRule.Rules.Kubernetes/blob/master/CHANGELOG.md)'
151+
assetUploadMode: replace
152+
addChangeLog: false
153+
isPreRelease: $(isPreRelease)

.azure-pipelines/pipeline-deps.ps1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Install dependencies for integration with Azure DevOps
3+
#
4+
5+
if ($Env:SYSTEM_DEBUG -eq 'true') {
6+
$VerbosePreference = 'Continue';
7+
}
8+
9+
if ($Null -eq (Get-PackageProvider -Name NuGet -ErrorAction Ignore)) {
10+
Install-PackageProvider -Name NuGet -Force -Scope CurrentUser;
11+
}
12+
13+
if ($Null -eq (Get-InstalledModule -Name PowerShellGet -MinimumVersion 2.1.4 -ErrorAction Ignore)) {
14+
Install-Module PowerShellGet -MinimumVersion 2.1.4 -Scope CurrentUser -Force -AllowClobber;
15+
}
16+
17+
if ($Null -eq (Get-InstalledModule -Name InvokeBuild -MinimumVersion 5.4.0 -ErrorAction Ignore)) {
18+
Install-Module InvokeBuild -MinimumVersion 5.4.0 -Scope CurrentUser -Force;
19+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Rule request
3+
about: Suggest the creation of a new or to update an existing rule
4+
---
5+
6+
# Rule request
7+
8+
## Suggested rule change
9+
10+
A clear and concise description of the what the rule should check and why.
11+
12+
## Applies to the following
13+
14+
The rule applies to the following:
15+
16+
- Resource kind: **[i.e. Deployment]**
17+
18+
## Sample data
19+
20+
Include a sample of passing/ failing resource YAML data.
21+
22+
> Only provide sanitized samples, replacing information such as metadata and names with examples (i.e. `name: deployment-A`).
23+
24+
A passing sample:
25+
26+
```yaml
27+
28+
```
29+
30+
A failing sample:
31+
32+
```yaml
33+
34+
```
35+
36+
## Additional context
37+
38+
Add any other context or references.

.vscode/settings.json

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,27 @@
77
"out/": true
88
},
99
"editor.insertSpaces": true,
10-
"editor.tabSize": 4
10+
"editor.tabSize": 4,
11+
"[yaml]": {
12+
"editor.tabSize": 2
13+
},
14+
"[markdown]": {
15+
"editor.tabSize": 2
16+
},
17+
"files.associations": {
18+
"**/.azure-pipelines/*.yaml": "azure-pipelines"
19+
},
20+
"cSpell.words": [
21+
"Kubernetes"
22+
],
23+
"cSpell.enabledLanguageIds": [
24+
"csharp",
25+
"git-commit",
26+
"markdown",
27+
"plaintext",
28+
"powershell",
29+
"text",
30+
"yaml",
31+
"yml"
32+
]
1133
}

.vscode/tasks.json

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@
1111
"kind": "test",
1212
"isDefault": true
1313
},
14+
"problemMatcher": [
15+
"$pester"
16+
],
17+
"presentation": {
18+
"clear": true,
19+
"panel": "dedicated"
20+
}
21+
},
22+
{
23+
"label": "coverage",
24+
"type": "shell",
25+
"command": "Invoke-Build Test -CodeCoverage",
1426
"problemMatcher": [ "$pester" ],
1527
"presentation": {
1628
"clear": true,
@@ -25,21 +37,39 @@
2537
"kind": "build",
2638
"isDefault": true
2739
},
28-
"problemMatcher": [ "$pester" ],
40+
"problemMatcher": [],
2941
"presentation": {
3042
"clear": true,
3143
"panel": "dedicated"
3244
}
3345
},
3446
{
35-
"label": "build-rule-docs",
47+
"label": "clean",
3648
"type": "shell",
37-
"command": "Invoke-Build BuildRuleDocs",
38-
"problemMatcher": [ ],
49+
"command": "Invoke-Build Clean",
50+
"problemMatcher": []
51+
},
52+
{
53+
"label": "script-analyzer",
54+
"type": "shell",
55+
"command": "Invoke-Build Analyze",
56+
"problemMatcher": [],
3957
"presentation": {
4058
"clear": true,
4159
"panel": "dedicated"
4260
}
61+
},
62+
{
63+
"label": "build-docs",
64+
"type": "shell",
65+
"command": "Invoke-Build BuildHelp",
66+
"problemMatcher": []
67+
},
68+
{
69+
"label": "scaffold-docs",
70+
"type": "shell",
71+
"command": "Invoke-Build ScaffoldHelp",
72+
"problemMatcher": []
4373
}
4474
]
4575
}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
## Unreleased
33

4+
- Update metadata rule to align to recommended labels. [#14](https://github.com/BernieWhite/PSRule.Rules.Kubernetes/issues/14)
5+
46
## v0.1.0-B190521 (pre-release)
57

68
- Initial pre-release

RuleHelp.Doc.ps1

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#
2+
# Generate rule help
3+
#
4+
5+
Document 'RuleHelp' {
6+
$tags = $InputObject.Tag;
7+
$rule = $InputObject.Info;
8+
Title $rule.Name
9+
10+
$annotations = [ordered]@{}
11+
if ($Null -ne $rule.Annotations) {
12+
$annotations += $rule.Annotations;
13+
}
14+
elseif ($Null -ne $tags) {
15+
$annotations += $tags.ToHashTable();
16+
}
17+
18+
if (!$annotations.Contains('online version')) {
19+
$annotations['online version'] = "https://github.com/BernieWhite/PSRule.Rules.Kubernetes/blob/master/docs/rules/en-US/$($rule.Name).md";
20+
}
21+
22+
Metadata $annotations;
23+
24+
Section 'SYNOPSIS' -Force {
25+
if ($Null -ne $rule.Synopsis) {
26+
$rule.Synopsis;
27+
}
28+
}
29+
30+
Section 'DESCRIPTION' -Force {
31+
if ($Null -ne $rule.Description) {
32+
$rule.Description;
33+
}
34+
elseif ($Null -ne $rule.Synopsis) {
35+
$rule.Synopsis;
36+
}
37+
}
38+
39+
Section 'RECOMMENDATION' -Force {
40+
if ($Null -ne $rule.Recommendation) {
41+
$rule.Recommendation;
42+
}
43+
elseif ($Null -ne $rule.Synopsis) {
44+
$rule.Synopsis;
45+
}
46+
}
47+
48+
Section 'NOTES' {
49+
$rule.Notes;
50+
}
51+
}

RuleToc.Doc.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
Document 'Kubernetes' {
3+
Title 'Kubernetes rules'
4+
5+
Get-PSRule -WarningAction SilentlyContinue | Table -Property @{ Name = 'RuleName'; Expression = {
6+
"[$($_.RuleName)]($($_.RuleName).md)"
7+
}}, Description
8+
}

RuleToc.Document.ps1

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)