Skip to content

Commit

Permalink
Initial PSRule without parameter files #206 (#207)
Browse files Browse the repository at this point in the history
* Initial PSRule without parameter files #206

* Update triggers and reference extension

* Separate job to ignore build bicep code

* Update PSRule options to include Bicep samples
  • Loading branch information
BernieWhite authored Apr 25, 2022
1 parent 7f35807 commit 8f4089d
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/bicep-build-to-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ on:
pull_request:
branches:
- main

# TODO: Branch for integration testing, to be removed before integration into main.
- ps-rule
paths:
- "**.bicep"
- "ps-rule.yaml"
- ".ps-rule/*"
workflow_dispatch: {}

jobs:
Expand Down Expand Up @@ -34,3 +39,22 @@ jobs:
echo $output
}
}
azure_waf:
name: Test Azure Well-Architected Framework
runs-on: ubuntu-latest

steps:

- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0

# Add pipeline tests for Azure Well-Architected Framework
- name: Run PSRule analysis
uses: Microsoft/ps-rule@v2.0.0
with:
modules: PSRule.Rules.Azure
baseline: Azure.GA_2022_03
continue-on-error: true
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"ms-azuretools.vscode-bicep",
"bewhite.psrule-vscode"
]
}
16 changes: 16 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "PSRule",
"problemMatcher": [
"$PSRule"
],
"label": "PSRule: Run analysis",
"presentation": {
"panel": "dedicated",
"clear": true
}
}
]
}
1 change: 1 addition & 0 deletions docs/wiki/Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ The following tooling/extensions are recommended to assist you developing for th
- [CodeTour extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=vsls-contrib.codetour)
- [ARM Tools extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=msazurermtools.azurerm-vscode-tools)
- [ARM Template Viewer extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=bencoleman.armview)
- [PSRule extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=bewhite.psrule-vscode)
- For visibility of Bracket Pairs:
- Use an Extension: [Bracket Pair Colorizer 2 extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer-2)
- Use Native capability:
Expand Down
59 changes: 59 additions & 0 deletions ps-rule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#
# PSRule for Azure configuration
#

# Please see the documentation for all configuration options:
# https://aka.ms/ps-rule-azure

# Use rules from the following modules/
include:
module:
- 'PSRule.Rules.Azure'

# Require a minimum version of modules that include referenced baseline.
requires:
PSRule.Rules.Azure: '@pre >=1.14.2'

# Reference the repository in output.
repository:
url: https://github.com/Azure/ALZ-Bicep

execution:
# Ignore warnings for resources and objects that don't have any rules.
notProcessedWarning: false

configuration:
# Enable expansion for Bicep source files.
AZURE_BICEP_FILE_EXPANSION: true

# Expand Bicep module from Azure parameter files.
AZURE_PARAMETER_FILE_EXPANSION: true

# Set timeout for expanding Bicep source files.
AZURE_BICEP_FILE_EXPANSION_TIMEOUT: 15

input:
pathIgnore:
# Ignore common files that don't need analysis.
- '**/bicepconfig.json'
- '*.md'
- '*.png'
- '.github/'

# Exclude Bicep docs files
- docs/scripts/callModuleFromACR.example.bicep

# Exclude Bicep module files
- 'infra-as-code/bicep/modules/**/*.bicep'
- 'infra-as-code/bicep/CRML/**/*.bicep'

# Include samples/ test files from modules
- '!infra-as-code/bicep/modules/**/samples/*.bicep'

rule:
exclude:
# Ignore these recommendations for this repo.
- Azure.Resource.UseTags
- Azure.ACR.MinSku
- Azure.ACR.ContentTrust
- Azure.Policy.AssignmentAssignedBy

0 comments on commit 8f4089d

Please sign in to comment.