Merge branch 'validate'

This commit is contained in:
Travis CI 2016-05-16 20:42:32 -07:00
commit fb940c9ae8
6 changed files with 83 additions and 48 deletions

View File

@ -1,8 +1,6 @@
require 'json'
c = File.read 'contents.json'
j = JSON.parse c
require_relative 'osia_helper'
j = get_json
c = j['categories']
c.sort_by { |h| h['title']}

View File

@ -1,45 +1,11 @@
require_relative 'osia_helper'
require 'date'
require 'json'
README = 'README.md'
ARCHIVE = 'ARCHIVE.md'
ARCHIVE_TAG = 'archive'
def output_stars(number)
case number
when 100...200
'🔥'
when 200...500
'🔥🔥'
when 500...1000
'🔥🔥🔥'
when 1000...2000
'🔥🔥🔥🔥'
when 2000...100000
'🔥🔥🔥🔥🔥'
else
''
end
end
def output_flag(lang)
case lang
when 'jpn'
'🇯🇵'
when 'ltz'
'🇱🇺'
when 'por'
'🇧🇷'
when 'spa'
'🇪🇸'
when 'zho'
'🇨🇳'
else
''
end
end
def apps_archived(apps)
a = apps.select {|a| a['tags'] != nil }.select {|b| b['tags'].include?ARCHIVE_TAG}
a.sort_by { |k, v| k['title'] }
@ -103,6 +69,40 @@ def output_apps(apps)
o
end
def output_flag(lang)
case lang
when 'jpn'
'🇯🇵'
when 'ltz'
'🇱🇺'
when 'por'
'🇧🇷'
when 'spa'
'🇪🇸'
when 'zho'
'🇨🇳'
else
''
end
end
def output_stars(number)
case number
when 100...200
'🔥'
when 200...500
'🔥🔥'
when 500...1000
'🔥🔥🔥'
when 1000...2000
'🔥🔥🔥🔥'
when 2000...100000
'🔥🔥🔥🔥🔥'
else
''
end
end
def write_readme(j)
t = j['title']
desc = j['description']
@ -178,8 +178,7 @@ def write_archive(j)
puts "wrote #{file}"
end
c = File.read 'contents.json'
j = JSON.parse c
j = get_json
write_readme(j)
write_archive(j)

7
.github/osia_helper.rb vendored Normal file
View File

@ -0,0 +1,7 @@
require 'json'
FILE = 'contents.json'
def get_json
JSON.parse(File.read FILE)
end

View File

@ -1,15 +1,11 @@
require 'json'
require_relative 'osia_helper'
require 'octokit'
require 'netrc'
FILE = 'contents.json'
c = File.read FILE
j = JSON.parse c
client = Octokit::Client.new(:netrc => true)
j = get_json
apps = j['projects']
updated = []

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

@ -0,0 +1,34 @@
require_relative 'osia_helper'
j = get_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/osia_validate_categories.rb
general:
artifacts:
- "ab-results.json"
@ -15,5 +16,5 @@ deployment:
master:
branch: master
commands:
- ruby .github/convert.rb
- ruby .github/osia_convert.rb
- ./.github/deploy.sh