Upgrade `json_schemer` to 2.3.0
What does this MR do and why?
This MR upgrades the json_schemer
gem from 0.2.18 to 2.3.0, which is the latest version.
The version we've been on is a prerelease version that doesn't have all the features we need to migrate CI config validation to a JSON schema. It's also difficult to use because the documentation for it no longer exists.
Related to #467375 (closed)
Benchmarking (values in milliseconds)
gem version | user | system | total | real |
---|---|---|---|---|
json_schemer-2.3.0 | 23.575 | 1.481 | 25.056 | (24.896) |
json_schemer-0.2.18 (currently in Gemfile) | 4.575 | 0.688 | 5.263 | (5.133) |
voxpupuli/json-schema-4.3.1 (using #fully_validate) | 41.373 | 5.279 | 46.652 | (46.690) |
Code used for benchmarking
# json_schemer
require 'benchmark'
ActiveRecord::Base.logger = nil
n = 5
schema_path = Rails.root.join('app/assets/javascripts/editor/schema/ci.json')
value = YAML.load_file('tmp-gitlab-ci.yml')
Benchmark.bm do |benchmark|
benchmark.report("v0.2.18") do
Gitlab::SafeRequestStore.ensure_request_store do
n.times do
validator = JSONSchemer.schema(Pathname.new(schema_path))
validator.validate(value).to_a
end
end
end
end
# json-schema
require 'benchmark'
require 'json-schema'
ActiveRecord::Base.logger = nil
n = 5
schema = Gitlab::Json.parse(File.read(Rails.root.join('app/assets/javascripts/editor/schema/ci.json')))
value = YAML.load_file('tmp-gitlab-ci.yml')
Benchmark.bm do |benchmark|
benchmark.report("json-schema-4.3.1") do
Gitlab::SafeRequestStore.ensure_request_store do
n.times do
JSON::Validator.fully_validate(schema, value)
end
end
end
end
Edited by Avielle Wolfe