-
Notifications
You must be signed in to change notification settings - Fork 42
62 lines (54 loc) · 2.54 KB
/
arm-template-lint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: ARM Templates
on:
pull_request:
paths:
- "deploy/azure/*.json"
push:
branches:
- main
paths:
- "deploy/azure/*.json"
jobs:
lint-arm-ttk:
name: Lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
template: [ "ARM-for-organization-account.json", "ARM-for-single-account.json" ]
steps:
- uses: actions/checkout@v2
# The only way to skip lint checks is by deleting files
# https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/test-toolkit#customize-tests
# - name: remove unwanted rules
# run: ls ./arm-ttk/arm-ttk/
# # Copy files to its own folder because it's what the official ARM-TTK action expects
# # Docs https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/test-toolkit#test-parameters
# - name: copy file
# working-directory: ./deploy/azure
# run: |
# mkdir ${{ matrix.template }}
# cp ${{ matrix.template }}.json ${{ matrix.template }}/azuredeploy.json
# Based on https://github.com/microsoft/action-armttk/blob/main/action.yml#L56
#
# Not used the official MS ARM TTK Action because we need to ignore some rules
# which must be done by deleting `.ps1` files https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/test-toolkit#customize-tests
# The ARM TTK Action didn't give us such flexibility
- name: Run ARM-TTK ${{ matrix.template }}
working-directory: ./deploy/azure
shell: pwsh
run: |
Install-Module -Name Pester -RequiredVersion 4.10.1 -Force
Import-Module -Name Pester -RequiredVersion 4.10.1 -Force
Invoke-WebRequest -Uri 'aka.ms/arm-ttk-latest' -OutFile arm-template-toolkit.zip
Expand-Archive -LiteralPath arm-template-toolkit.zip -DestinationPath arm-ttk
# Delete Unwanted rules
Remove-Item ./arm-ttk/arm-ttk/testcases/deploymentTemplate/ManagedIdentityExtension-must-not-be-used.test.ps1
Import-Module ./arm-ttk/arm-ttk/arm-ttk.psd1
echo "Test-AzTemplate -TemplatePath ${{ matrix.template }} -Pester -Skip Secure-Params-In-Nested-Deployments" | Out-File -FilePath ./armttk.ps1
Invoke-Pester -Script ./armttk.ps1 -EnableExit -OutputFormat NUnitXml -OutputFile ./armttk.xml
# - uses: microsoft/action-armttk@v1
# name: lint ${{ matrix.template }}
# with:
# github_token: ${{ secrets.github_token }}
# workdir: "./deploy/azure/${{ matrix.template }}"