mirror of
https://github.com/dkhamsing/open-source-ios-apps.git
synced 2024-12-23 14:57:59 +01:00
[script] validate
This commit is contained in:
parent
6e14335dfd
commit
4908b2a77a
34
.github/validate_categories.rb
vendored
Normal file
34
.github/validate_categories.rb
vendored
Normal 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 ✅'
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user