/
ContinuousIntegration-Rules.yml
124 lines (100 loc) · 4.97 KB
/
ContinuousIntegration-Rules.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
trigger: none
pool:
vmimage: 'windows-latest'
stages:
- stage: Build
jobs:
- job: Build_Datasets
steps:
- checkout: self
path: 'self'
- task: PowerShell@2
displayName: 'Download Tabular Editor and Default Rules'
inputs:
targetType: inline
script: |
$path = "$(Build.SourcesDirectory)"
$tempPath = "$path\_temp"
$toolPath = "$path\_tools\TE"
New-Item -ItemType Directory -Path $tempPath -ErrorAction SilentlyContinue | Out-Null
Write-Host "##[debug]Downloading Tabular Editor binaries"
$downloadUrl = "https://github.com/TabularEditor/TabularEditor/releases/latest/download/TabularEditor.Portable.zip"
$zipFile = "$tempPath\TabularEditor.zip"
Invoke-WebRequest -Uri $downloadUrl -OutFile $zipFile
Expand-Archive -Path $zipFile -DestinationPath $toolPath -Force
Write-Host "##[debug]Downloading Dataset default rules"
$downloadUrl = "https://raw.githubusercontent.com/microsoft/Analysis-Services/master/BestPracticeRules/BPARules.json"
Invoke-WebRequest -Uri $downloadUrl -OutFile "$tempPath\Rules-Dataset.json"
- task: PowerShell@2
displayName: 'Run Dataset Rules'
inputs:
targetType: inline
script: |
$path = "$(Build.SourcesDirectory)"
$tempPath = "$path\_temp"
$toolPath = "$path\_Tools\TE\TabularEditor.exe"
$rulesPath = "$path\Rules-Dataset.json"
if (!(Test-Path $rulesPath))
{
Write-Host "Running downloaded rules"
$rulesPath = "$tempPath\Rules-Dataset.json"
}
$itemsFolders = Get-ChildItem -Path $path -recurse -include ("*.pbidataset", "*.pbism")
foreach($itemFolder in $itemsFolders)
{
$itemPath = "$($itemFolder.Directory.FullName)\definition"
if (!(Test-Path $itemPath))
{
$itemPath = "$($itemFolder.Directory.FullName)\model.bim"
if (!(Test-Path $itemPath))
{
throw "Cannot find semantic model definition."
}
}
Write-Host "##[group]Running rules for: '$itemPath'"
Start-Process -FilePath "$toolPath" -ArgumentList """$itemPath"" -A ""$rulesPath"" -V" -NoNewWindow -Wait
Write-Host "##[endgroup]"
}
- job: Build_Reports
steps:
- checkout: self
path: 'self'
- task: PowerShell@2
displayName: 'Download PBIXInspector'
inputs:
targetType: inline
script: |
$path = "$(Build.SourcesDirectory)"
$tempPath = "$path\_temp"
$toolPath = "$path\_Tools\PBIInspector"
New-Item -ItemType Directory -Path $tempPath -ErrorAction SilentlyContinue | Out-Null
Write-Host "##[debug]Downloading PBI Inspector"
$downloadUrl = "https://github.com/NatVanG/PBI-Inspector/releases/latest/download/win-x64-CLI.zip"
$zipFile = "$tempPath\PBIXInspector.zip"
Invoke-WebRequest -Uri $downloadUrl -OutFile $zipFile
Expand-Archive -Path $zipFile -DestinationPath $toolPath -Force
Write-Host "##[debug]Downloading Report default rules"
$downloadUrl = "https://raw.githubusercontent.com/NatVanG/PBI-Inspector/main/Rules/Base-rules.json"
Invoke-WebRequest -Uri $downloadUrl -OutFile "$tempPath\Rules-Report.json"
- task: PowerShell@2
displayName: 'Run Report Rules'
inputs:
targetType: inline
script: |
$path = "$(Build.SourcesDirectory)"
$tempPath = "$path\_temp"
$toolPath = "$path\_Tools\PBIInspector\win-x64\CLI\PBIXInspectorCLI.exe"
$rulesPath = "$path\Rules-Report.json"
if (!(Test-Path $rulesPath))
{
Write-Host "Running default downloaded rules"
$rulesPath = "$tempPath\Rules-Report.json"
}
$itemsFolders = Get-ChildItem -Path $path -recurse -include *.pbir
foreach($itemFolder in $itemsFolders)
{
$itemPath = $itemFolder.Directory.FullName
Write-Host "##[group]Running rules for: '$itemPath'"
Start-Process -FilePath "$toolPath" -ArgumentList "-pbipreport ""$itemPath"" -rules ""$rulesPath"" -formats ""ADO""" -NoNewWindow -Wait
Write-Host "##[endgroup]"
}