Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hackathon] PSRule on PR #2094

Closed
wants to merge 104 commits into from
Closed
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
173e72c
linter
eriqua Sep 19, 2022
9db67f6
Merge branch 'hack/topic6' into hack/topic6-erikag/test-psrule
eriqua Sep 19, 2022
dc031fc
exclude parameters
eriqua Sep 19, 2022
d16203b
merge main
eriqua Sep 19, 2022
9a0a600
pathIgnore
eriqua Sep 19, 2022
893bd8f
Merge branch 'hack/topic6' into hack/topic6-erikag/test-psrule
eriqua Sep 20, 2022
855f161
clean up token replacement
eriqua Sep 20, 2022
81b5a9f
clean up token replacement further
eriqua Sep 20, 2022
7aa8000
resize token replacement
eriqua Sep 20, 2022
15ceeaa
typo
eriqua Sep 20, 2022
5dc4099
Merge branch 'hack/topic6' into hack/topic6-erikag/test-psrule
eriqua Sep 20, 2022
153fad8
modulePath
eriqua Sep 20, 2022
c0ed856
job name
eriqua Sep 20, 2022
dea25f8
no psrule
eriqua Sep 20, 2022
d2a89d8
no psrule step
eriqua Sep 20, 2022
19cfe71
fix inputpath
eriqua Sep 20, 2022
20e405b
comment out continue on error option
eriqua Sep 20, 2022
4a07c2a
Align KV
eriqua Sep 20, 2022
589d704
kv no psrule
eriqua Sep 20, 2022
0b6c7ad
replace
eriqua Sep 20, 2022
393bfb5
no replace
eriqua Sep 20, 2022
16fab36
replace 1
eriqua Sep 20, 2022
75f8b6c
indent
eriqua Sep 20, 2022
5c417db
align vnet
eriqua Sep 20, 2022
09a730f
align vnet and enable deployment
eriqua Sep 20, 2022
5253723
notProcessedWarning
eriqua Sep 20, 2022
f7e7ae6
conflicts
eriqua Sep 20, 2022
3a260c9
suppressedRuleWarning
eriqua Sep 20, 2022
0b237e6
Merge branch 'hack/topic6' into hack/topic6-erikag/test-psrule-linter
eriqua Sep 20, 2022
00e2515
enable deployment
eriqua Sep 20, 2022
3793b44
Merge branch 'hack/topic6' into hack/topic6-erikag/test-psrule-linter
eriqua Sep 21, 2022
01b4772
Merge branch 'hack/topic6' into hack/topic6-erikag/test-psrule-linter
eriqua Sep 21, 2022
0dda740
linter csv
eriqua Sep 21, 2022
5917a86
path to ignore
eriqua Sep 21, 2022
729a9c6
execution
eriqua Sep 21, 2022
c19be04
disable rg deployment
eriqua Sep 21, 2022
8e26711
2 jobs
eriqua Sep 21, 2022
0d6d1d1
inputpath
eriqua Sep 21, 2022
d922050
add init
eriqua Sep 21, 2022
289e5a1
variables
eriqua Sep 21, 2022
18b729a
env variables
eriqua Sep 21, 2022
c2c1961
call function
eriqua Sep 21, 2022
0f7848d
md detail summary
eriqua Sep 21, 2022
393c348
new lines
eriqua Sep 21, 2022
6cf317b
details pass and fail
eriqua Sep 21, 2022
d930a7a
moduleTestFiles
eriqua Sep 21, 2022
bc45398
moduleTest
eriqua Sep 21, 2022
ddd803f
join path
eriqua Sep 21, 2022
6a87be4
modulesFolderPath
eriqua Sep 21, 2022
72d7987
modulesFolderPath collection
eriqua Sep 21, 2022
f674dcc
modulesFolderPath no filter
eriqua Sep 21, 2022
a84b424
modulesFolderPath no file
eriqua Sep 21, 2022
057a4c2
force
eriqua Sep 21, 2022
a60f695
cleanup
eriqua Sep 21, 2022
a62af96
root
eriqua Sep 21, 2022
3baec7b
noroot
eriqua Sep 21, 2022
de1233e
convert verbose
eriqua Sep 21, 2022
21e5a32
no pipe
eriqua Sep 21, 2022
8dff446
merge dev
eriqua Sep 22, 2022
40c8484
merge dev
eriqua Sep 29, 2022
89f3a24
yay
eriqua Sep 29, 2022
e3324dd
token secret
eriqua Sep 29, 2022
084b06a
skip passed
eriqua Sep 29, 2022
a53defe
rocket
eriqua Sep 29, 2022
658b2c4
noFailuresContent
eriqua Sep 29, 2022
de2c95b
yay Content
eriqua Sep 29, 2022
a3c9628
yay Content if the case
eriqua Sep 29, 2022
6dd8b88
double rocket
eriqua Sep 29, 2022
cadcdb1
cleanup
eriqua Sep 29, 2022
085750d
header content
eriqua Sep 29, 2022
5bbc4e2
header
eriqua Sep 29, 2022
f463007
cleanup
eriqua Sep 29, 2022
e341836
cleanerup
eriqua Sep 29, 2022
86aa6b9
tbd
eriqua Sep 29, 2022
29b3f2e
Merge branch 'hack/topic6' into hack/topic6-erikag/test-psrule-linter
eriqua Oct 3, 2022
d07aae6
test on kv only
eriqua Oct 4, 2022
4121f34
test on kv only change
eriqua Oct 4, 2022
950c542
test on kv only change path
eriqua Oct 4, 2022
d204934
library
eriqua Oct 4, 2022
361905e
comment
eriqua Oct 4, 2022
e07bf7b
Merge branch 'hack/topic6' into hack/topic6-erikag/test-psrule-linter
eriqua Oct 4, 2022
c4c2f8d
Merge branch 'hack/topic6' into hack/topic6-erikag/test-psrule-linter
eriqua Oct 10, 2022
ffb3363
suppress ms rg
eriqua Oct 10, 2022
6bca85c
suppress privatelink
eriqua Oct 10, 2022
6b5241c
Merge branch 'hack/topic6' into hack/topic6-erikag/test-psrule-linter
eriqua Oct 12, 2022
4fabf3a
reduce scope
eriqua Oct 12, 2022
9d874c0
reduce scope csv
eriqua Oct 12, 2022
8105f81
reduce scope csv kv
eriqua Oct 12, 2022
f9b826f
242
eriqua Oct 12, 2022
69fa379
remove require
eriqua Oct 12, 2022
c60eb48
250
eriqua Oct 12, 2022
ac2a193
250 linter
eriqua Oct 12, 2022
4126873
240 linter
eriqua Oct 12, 2022
fba2d2c
requires 240 linter
eriqua Oct 12, 2022
3bbee13
include 240
eriqua Oct 12, 2022
dd834df
Merge branch 'hack/topic6' into hack/topic6-erikag/test-psrule-linter
eriqua Oct 14, 2022
953c8ad
Merge branch 'hack/topic6' into hack/topic6-erikag/test-psrule-linter
eriqua Oct 18, 2022
a56cd66
EoF
eriqua Oct 18, 2022
cc6968e
update inputpath to all modules
eriqua Oct 18, 2022
d8e8b13
Merge branch 'hack/topic6' into hack/topic6-erikag/test-psrule-linter
eriqua Nov 8, 2022
585febb
Merge branch 'hack/topic6' into hack/topic6-erikag/test-psrule-linter
eriqua Dec 9, 2022
baef68b
Merge branch 'hack/topic6' into hack/topic6-erikag/test-psrule-linter
eriqua Dec 13, 2022
e444749
clean psrule settings
eriqua Dec 13, 2022
23f1be1
pipeline trigger
eriqua Dec 13, 2022
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
108 changes: 108 additions & 0 deletions .github/workflows/platform.linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ on:
pull_request:
branches:
- main
- hack/topic6

env:
variablesPath: 'settings.yml'
modulesPath: 'modules'
TOKEN_NAMEPREFIX: '${{ secrets.TOKEN_NAMEPREFIX }}'

jobs:
build:
Expand All @@ -31,3 +37,105 @@ jobs:
DEFAULT_BRANCH: ${{ github.base_ref }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILTER_REGEX_EXCLUDE: '[module.tests.ps1|Get\-ModulesAsMarkdownTable.ps1|.*yml]'

# Discuss if running on PR to the whole repo (current implementation) or only on files changed
psrule:
name: PSRule
runs-on: ubuntu-latest
steps:
# Analyze repository with PSRule
- name: Checkout
uses: actions/checkout@v3
- name: Set environment variables
uses: ./.github/actions/templates/setEnvironmentVariables
with:
variablesPath: ${{ env.variablesPath }}
- name: 'Replace tokens in template file'
uses: azure/powershell@v1
with:
azPSVersion: 'latest'
inlineScript: |
# Grouping task logs
Write-Output '::group::Replace tokens in template file'

# Load used functions
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'tokensReplacement' 'Convert-TokensInFileList.ps1')

# Populate tokens
$Tokens = @{
resourceGroupName = '${{ env.resourceGroupName }}'
subscriptionId = '${{ secrets.ARM_SUBSCRIPTION_ID }}'
managementGroupId = '${{ secrets.ARM_MGMTGROUP_ID }}'
tenantId = '${{ env.ARM_TENANT_ID }}'
}

## Add local (source control) tokens
$tokenMap = @{}
foreach ($token in (Get-ChildItem env: | Where-Object -Property Name -Like "localToken_*")) {
$tokenMap += @{ $token.Name.Replace('localToken_','','OrdinalIgnoreCase') = $token.value }
}
Write-Verbose ('Using local tokens [{0}]' -f ($tokenMap.Keys -join ', ')) -Verbose
$Tokens += $tokenMap

## Swap 'namePrefix' token if empty and provided as a GitHub secret
if([String]::IsNullOrEmpty($Tokens['namePrefix'])){
Write-Verbose 'Using [namePrefix] token from GitHub' -Verbose
$Tokens['namePrefix'] = '${{ env.TOKEN_NAMEPREFIX }}'
}

# Get File Path List
$modulesFolderPath = Join-Path $env:GITHUB_WORKSPACE '${{ env.modulesPath }}'
$moduleTestFiles = [System.Collections.ArrayList]@()
# $moduleTestFiles += Get-ChildItem -Path $modulesFolderPath -Filter *.test.bicep -Recurse -Force -Name
# Get-ChildItem -Path $env:GITHUB_WORKSPACE -Filter *.test.bicep -Recurse -Force -Name | Join-Path $env:GITHUB_WORKSPACE '$._'
$moduleTestFiles += Get-ChildItem -Path $env:GITHUB_WORKSPACE -Filter *.test.bicep -Recurse -Force -Name
# | ForEach-Object {$_.root} | Join-Path -ChildPath "Subdir"

# Construct Token Function Input
$ConvertTokensInputs = @{
FilePathList = $moduleTestFiles
Tokens = $Tokens
TokenPrefix = '${{ env.tokenPrefix }}'
TokenSuffix = '${{ env.tokenSuffix }}'
}

Write-Verbose "Convert Tokens Input:`n $($ConvertTokensInputs | ConvertTo-Json -Depth 10)" -Verbose

# Invoke Token Replacement Functionality [For Module]
# $null =
Convert-TokensInFileList @ConvertTokensInputs -verbose

Write-Output '::endgroup::'
- name: Run PSRule analysis
uses: microsoft/[email protected]
continue-on-error: true # Setting this whilst PSRule gets bedded in, in this project
with:
modules: 'PSRule.Rules.Azure'
inputPath: '${{ env.modulesPath }}/'
outputFormat: Csv
outputPath: '${{ env.modulesPath }}/PSRule-output.csv'
- name: 'Parse CSV content'
uses: azure/powershell@v1
with:
azPSVersion: 'latest'
inlineScript: |
# Grouping task logs
Write-Output '::group::Parse CSV content'

# Load used functions
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'PSRuleValidation' 'Set-PSRuleOutput.ps1')

# Populate parameter input
$ParameterInput = @{
inputFilePath = '${{ env.modulesPath }}/PSRule-output.csv'
outputFilePath = '${{ env.modulesPath }}/PSRule-output.md'
skipPassedRulesReport = $true
}

# Invoke function
$null = Set-PSRuleOutput @ParameterInput

Write-Output '::endgroup::'
- name: Output to GitHub job summaries
if: always()
run: cat '${{ env.modulesPath }}/PSRule-output.md' >> $GITHUB_STEP_SUMMARY