Skip to content

Fix bug in git sync and added credentials file to gitignore #6

Fix bug in git sync and added credentials file to gitignore

Fix bug in git sync and added credentials file to gitignore #6

Workflow file for this run

# PR Validation Pipeline - Best Practice Analyzer for Semantic Models
# Triggers on pull requests targeting the main branch
name: PR - BPA Validation
on:
pull_request:
branches:
- main
jobs:
validate-semantic-models:
name: Run Best Practice Analyzer
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Tabular Editor
shell: pwsh
run: |
$toolPath = "${{ github.workspace }}\_tools\TabularEditor"
New-Item -ItemType Directory -Path $toolPath -Force | Out-Null
Write-Host "Downloading Tabular Editor binaries..."
$downloadUrl = "https://github.com/TabularEditor/TabularEditor/releases/latest/download/TabularEditor.Portable.zip"
$zipFile = "$toolPath\TabularEditor.zip"
Invoke-WebRequest -Uri $downloadUrl -OutFile $zipFile
Expand-Archive -Path $zipFile -DestinationPath $toolPath -Force
Write-Host "Tabular Editor downloaded successfully"
- name: Run BPA on Semantic Models
shell: pwsh
run: |
$toolPath = "${{ github.workspace }}\_tools\TabularEditor\TabularEditor.exe"
$rulesPath = "${{ github.workspace }}\automation\resources\BPARules.json"
$modelsPath = "${{ github.workspace }}\solution\model"
Write-Host "Searching for semantic models in: $modelsPath"
# Get all first-level folders in solution/model
$modelFolders = Get-ChildItem -Path $modelsPath -Directory
if ($modelFolders.Count -eq 0) {
Write-Warning "No model folders found"
exit 0
}
Write-Host "Found $($modelFolders.Count) folder(s) to check"
$hasErrors = $false
$modelsProcessed = 0
foreach ($folder in $modelFolders) {
$folderPath = $folder.FullName
$definitionPath = $null
# Check if folder contains a definition subfolder (TMDL format)
$definitionFolder = Join-Path $folderPath "definition"
if (Test-Path $definitionFolder) {
$definitionPath = $definitionFolder
}
# Check for database.json (TMDL folder format)
elseif (Test-Path (Join-Path $folderPath "database.json")) {
$definitionPath = $folderPath
}
# Check for *.bim file (BIM format)
else {
$bimFile = Get-ChildItem -Path $folderPath -Filter "*.bim" -File | Select-Object -First 1
if ($bimFile) {
$definitionPath = $bimFile.FullName
}
}
# Skip if no valid model definition found
if (!$definitionPath) {
Write-Host "Skipping folder (no model found): $($folder.Name)"
continue
}
# Extract model name
if ($folder.Name -match '^(.+)\.SemanticModel$') {
$modelName = $matches[1]
} else {
$modelName = $folder.Name
}
$modelsProcessed++
Write-Host "::group::Analyzing: $modelName"
Write-Host "Path: $definitionPath"
# Run Tabular Editor BPA
# -A: Analyze with rules file, -V: Verbose output
$process = Start-Process -FilePath $toolPath `
-ArgumentList """$definitionPath"" -A ""$rulesPath"" -G" `
-NoNewWindow -Wait -PassThru
if ($process.ExitCode -ne 0) {
Write-Host "::error::BPA found errors in: $modelName"
$hasErrors = $true
}
Write-Host "::endgroup::"
}
Write-Host "Processed $modelsProcessed semantic model(s)"
if ($hasErrors) {
Write-Host "::error::Best Practice Analyzer found errors"
exit 1
}
Write-Host "All semantic models passed BPA validation"