Skip to content

Commit 3ecb4f9

Browse files
Merge pull request #65 from nventive/dev/arde/calculate-dev-score-validation
chore: add pana max score validation task
2 parents e8f51b3 + 9b0e66e commit 3ecb4f9

3 files changed

Lines changed: 58 additions & 4 deletions

File tree

src/cli/.azuredevops/stage-calculate-pubdev-score.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ parameters:
99
jobs:
1010
- job: OnWindows_CalculatePubDev_Score
1111
pool:
12-
vmImage : $(windowsHostedAgentImage)
12+
vmImage : $(ubuntuHostedAgentImage)
1313
steps:
1414
- template: ../../../build/templates/flutter-install.yml
1515
parameters:

src/cli/.azuredevops/templates/calculate-devscore.yml

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ steps:
1010
- powershell: Set-Location ${{ parameters.pathToSrc }}
1111
displayName: 'Set Location to CLI Folder'
1212

13+
- powershell: Move-Item -Path $(Build.SourcesDirectory)\README.md -Destination ${{ parameters.pathToSrc }}\README.md
14+
displayName: Move README into CLI Folder
15+
1316
- task: PowerShell@2
1417
displayName: 'Execute Build Runner'
1518
inputs:
@@ -19,14 +22,64 @@ steps:
1922
dart run build_runner build --delete-conflicting-outputs
2023
2124
- script: |
25+
export PATH="$PATH:$HOME/.pub-cache/bin"
2226
dart pub global activate pana
2327
cd ${{ parameters.pathToSrc }}
24-
%LOCALAPPDATA%\Pub\Cache\bin\pana > $(Build.SourcesDirectory)/pana-analysis.md
28+
pana --no-warning . > $(Build.SourcesDirectory)/pana-analysis.md
2529
displayName: 'Run Pana Analysis'
26-
30+
2731
- task: PublishBuildArtifacts@1
2832
displayName: 'Publish Pana Analysis'
2933
inputs:
3034
pathToPublish: '$(Build.SourcesDirectory)/pana-analysis.md'
3135
artifactName: '${{ parameters.artifactName }}_PanaAnalysis'
32-
condition: and(succeeded(), ne('${{ parameters.artifactName }}', ''))
36+
condition: and(succeeded(), ne('${{ parameters.artifactName }}', ''))
37+
38+
- task: PowerShell@2
39+
displayName: 'Validate Pana Score and Display Details'
40+
inputs:
41+
targetType: 'inline'
42+
script: |
43+
$panaFile = "$(Build.SourcesDirectory)/pana-analysis.md"
44+
if (Test-Path $panaFile) {
45+
$content = Get-Content $panaFile
46+
47+
# Extract the total score
48+
$scoreLine = $content | Select-String -Pattern "Points: (\d+)/160"
49+
if ($scoreLine -match "Points: (\d+)/160") {
50+
$score = [int]$Matches[1]
51+
Write-Host ""
52+
Write-Host "Current Pana Score: $score/160"
53+
Write-Host ""
54+
55+
# Check if the score is below the threshold
56+
if ($score -lt 160) {
57+
Write-Host "The score is below the threshold of 160."
58+
Write-Host ""
59+
60+
# Extract sections with less than full points
61+
$lowScores = $content | Select-String -Pattern "### \[x\] \d+/\d+ points: .*"
62+
if ($lowScores) {
63+
Write-Host "Areas with reduced scores:"
64+
foreach ($line in $lowScores) {
65+
Write-Host $line.Line
66+
}
67+
Write-Host ""
68+
} else {
69+
Write-Host "No specific areas with reduced scores were found."
70+
Write-Host ""
71+
}
72+
73+
exit 1
74+
} else {
75+
Write-Host "The score meets the threshold. Build passed."
76+
Write-Host ""
77+
}
78+
} else {
79+
Write-Error "Unable to find a valid score in the pana-analysis.md file."
80+
exit 1
81+
}
82+
} else {
83+
Write-Error "pana-analysis.md file not found."
84+
exit 1
85+
}

src/cli/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Prefix your items with `(Template)` if the change is about the template and not
77

88
## 0.25.3
99
- Add local pub.dev score report.
10+
- Add built-time validation requiring a pub.dev score threshold of 160.
1011

1112
## 0.25.2
1213
- Update iOS & Android minimum version targets.

0 commit comments

Comments
 (0)