Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(CI): Support validation of all archived manifests #168

Merged
merged 6 commits into from
Jun 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(CI): Support validation of all archived manifests
  • Loading branch information
Ash258 committed Jun 10, 2021
commit cf0d117b4d553e81ead544f069d2aa5123ddc9df
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [0.6.5](https://github.com/Ash258/Scoop-Core/milestone/5)

- **CI**: Support validation of all archived manifests
- **scoop-cat**: Add `-f`, `--format` options
- Adopt new resolve function for parameter passing
- **scoop-home**
Expand Down
27 changes: 13 additions & 14 deletions test/Scoop-Manifest.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,22 @@ Describe -Tag 'Manifests' 'manifest-validation' {
$commit = if ($env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT) { $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT } else { $env:APPVEYOR_REPO_COMMIT }
$changed_manifests = (Get-GitChangedFile -Include '*.json' -Commit $commit)
}
$manifest_files = Get-ChildItem $bucketdir *.json
# TODO: YAMl
$manifest_files = Get-ChildItem $bucketdir '*.json' -Recurse
$validator = New-Object Scoop.Validator($schema, $true)
}

$quota_exceeded = $false

$manifest_files | ForEach-Object {
$skip_manifest = ($changed_manifests -inotcontains $_.FullName)
if ($env:CI -ne $true -or $changed_manifests -imatch 'schema.json') {
$skip_manifest = $false
}
It "$_" -Skip:$skip_manifest {
$file = $_ # exception handling may overwrite $_
foreach ($file in $manifest_files) {
$skip_manifest = ($changed_manifests -inotcontains $file.FullName)
if ($env:CI -ne $true -or $changed_manifests -imatch 'schema.json') { $skip_manifest = $false }

if (!($quota_exceeded)) {
It "$file" -Skip:$skip_manifest {
# Skip yml for now for schema validation
if (!($quota_exceeded) -or ($file.Extension -match '\.ya?ml')) {
try {
$validator.Validate($file.fullname)
$validator.Validate($file.FullName)

if ($validator.Errors.Count -gt 0) {
Write-Host -f red " [-] $_ has $($validator.Errors.Count) Error$(If($validator.Errors.Count -gt 1) { 's' })!"
Expand All @@ -87,12 +86,12 @@ Describe -Tag 'Manifests' 'manifest-validation' {
}
}

$manifest = parse_json $file.fullname
$manifest = ConvertFrom-Manifest -LiteralPath $file.FullName
$url = arch_specific 'url' $manifest '32bit'
$url64 = arch_specific 'url' $manifest '64bit'
if (!$url) {
$url = $url64
}

if (!$url) { $url = $url64 }

$url | Should -Not -BeNullOrEmpty
}
}
Expand Down