-
Notifications
You must be signed in to change notification settings - Fork 86
/
pull-request-check.yml
109 lines (85 loc) · 4.35 KB
/
pull-request-check.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# ----------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
#
# THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
# ----------------------------------------------------------------------------------
trigger: none
variables:
- template: ../config/variables/common.yml
pool:
vmImage: ubuntu-latest
stages:
- stage: PullRequestCheckStage
displayName: Pull Request Check
jobs:
- deployment: PullRequestCheckJob
displayName: Pull Request Check Job
environment: ${{ variables['Build.SourceBranchName'] }}
strategy:
runOnce:
deploy:
steps:
- checkout: self
- task: PowerShell@2
displayName: Run schema test cases
name: ParametersSchemaTestCases
enabled: true
inputs:
targetType: 'inline'
script: |
$SchemaFolder="schemas/latest/landingzones"
# Validate schema test cases
$SchemaTestsFolder="tests/schemas"
Write-Host "Validating schema test cases..."
Write-Host "Schema Test Folder: $SchemaTestsFolder"
Write-Host "Schema Folder: $SchemaFolder"
Get-ChildItem -Directory -Path $SchemaTestsFolder | Foreach-Object {
$archetypeName = $_.BaseName
Write-Host "Archetype: $archetypeName"
Get-ChildItem -Recurse -Filter '*.json' -Path "$SchemaTestsFolder/$archetypeName" | ForEach-Object {
Write-Host " Validating: $_ with $SchemaFolder/$archetypeName.json"
Get-Content -Raw $_ | Test-Json -SchemaFile "$SchemaFolder/$archetypeName.json"
}
}
workingDirectory: ${{ variables['Build.SourcesDirectory'] }}
- task: PowerShell@2
displayName: Validate exising subscription archetype parameter files
name: SubscriptionArchetypeParametersValidation
enabled: true
inputs:
targetType: 'inline'
script: |
$SchemaFolder="schemas/latest/landingzones"
# Validate exising subscription archetype parameter files
Write-Host "Validate exising subscription archetype parameter files..."
$GenericSubscriptionFileFilter="*generic-subscription*.json"
$GenericSubscriptionSchemaFile="${SchemaFolder}/lz-generic-subscription.json"
Get-ChildItem -Recurse -Filter $GenericSubscriptionFileFilter -Path "$(subscriptionsPathFromRoot)" | ForEach-Object {
Write-Host "Validating: $_ with $GenericSubscriptionSchemaFile"
Get-Content -Raw $_ | Test-Json -SchemaFile $GenericSubscriptionSchemaFile
}
$MachineLearningFileFilter="*machinelearning*.json"
$MachineLearningSchemaFile="${SchemaFolder}/lz-machinelearning.json"
Get-ChildItem -Recurse -Filter $MachineLearningFileFilter -Path "$(subscriptionsPathFromRoot)" | ForEach-Object {
Write-Host "Validating: $_ with $MachineLearningSchemaFile"
Get-Content -Raw $_ | Test-Json -SchemaFile $MachineLearningSchemaFile
}
$HealthcareFileFilter="*healthcare*.json"
$HealthcareSchemaFile="${SchemaFolder}/lz-healthcare.json"
Get-ChildItem -Recurse -Filter $HealthcareFileFilter -Path "$(subscriptionsPathFromRoot)" | ForEach-Object {
Write-Host "Validating: $_ with $HealthcareSchemaFile"
Get-Content -Raw $_ | Test-Json -SchemaFile $HealthcareSchemaFile
}
workingDirectory: ${{ variables['Build.SourcesDirectory'] }}
- task: Bash@3
displayName: Validate Bicep Templates
name: CompileBiceps
enabled: true
inputs:
targetType: 'inline'
script: |
find . -type f -name '*.bicep' | xargs -tn1 az bicep build -f
workingDirectory: ${{ variables['Build.SourcesDirectory'] }}