mirror of
https://github.com/dkhamsing/open-source-ios-apps.git
synced 2025-01-11 07:44:03 +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:
|
override:
|
||||||
- awesome_bot contents.json --white-list developer.apple
|
- awesome_bot contents.json --white-list developer.apple
|
||||||
- json validate --schema-file=.github/schema.json --document-file=contents.json
|
- json validate --schema-file=.github/schema.json --document-file=contents.json
|
||||||
|
- ruby .github/validate_categories.rb
|
||||||
general:
|
general:
|
||||||
artifacts:
|
artifacts:
|
||||||
- "ab-results.json"
|
- "ab-results.json"
|
||||||
|
Loading…
Reference in New Issue
Block a user