1
0
mirror of https://github.com/dkhamsing/open-source-ios-apps.git synced 2024-12-23 23:00:45 +01:00

[script] validate

This commit is contained in:
Travis CI 2016-05-16 10:22:27 -07:00
parent 6e14335dfd
commit 4908b2a77a
2 changed files with 35 additions and 0 deletions

34
.github/validate_categories.rb vendored Normal file
View File

@ -0,0 +1,34 @@
require 'json'
j = JSON.parse(File.read 'contents.json')
c = j['categories']
a = j['projects']
def failed(cat, app)
puts "‼️ #{cat} is not a valid category for #{app}"
exit 1
end
def verify(cat, allowed, app)
failed(cat, app) unless allowed.include? cat
end
allowed_categories = c.sort_by { |h| h['title']}.map { |x| x['id']}
a.each do |a|
cat = a['category']
if cat.nil?
# failed(cat, a)
puts "missing category for #{a}"
exit 1
end
if cat.class == String
verify(cat, allowed_categories, a)
elsif cat.class == Array
cat.each { |c| verify(c, allowed_categories, a) }
end
end
puts 'categories validated ✅'

View File

@ -8,6 +8,7 @@ test:
override:
- awesome_bot contents.json --white-list developer.apple
- json validate --schema-file=.github/schema.json --document-file=contents.json
- ruby .github/validate_categories.rb
general:
artifacts:
- "ab-results.json"