diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d769f1..084ecc5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,10 +13,15 @@ jobs: env: CC: clang CXX: clang++ + BUNDLE_GEMFILE: ${{ github.workspace }}/implementations/json_schemer/Gemfile steps: - uses: actions/checkout@v4 - name: Install uv run: pipx install uv + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2.5' + bundler-cache: true - run: make - run: cat dist/report.csv diff --git a/Makefile b/Makefile index 86b778f..33308fc 100644 --- a/Makefile +++ b/Makefile @@ -61,3 +61,13 @@ dist/results/boon/%: \ | dist/results/boon cargo run --manifest-path implementations/boon/Cargo.toml --release $(dir $(word 3,$^)) > $@ +# JSON_SCHEMER + +dist/results/json_schemer/%: \ + implementations/json_schemer/main.rb \ + implementations/json_schemer/Gemfile.lock \ + schemas/%/schema.json \ + schemas/%/instances.jsonl \ + | dist/results/json_schemer + bundle exec --gemfile implementations/json_schemer/Gemfile ruby implementations/json_schemer/main.rb schemas/example $(dir $(word 3,$^)) > $@ + diff --git a/implementations/json_schemer/Gemfile b/implementations/json_schemer/Gemfile new file mode 100644 index 0000000..f696c62 --- /dev/null +++ b/implementations/json_schemer/Gemfile @@ -0,0 +1,4 @@ +source "https://rubygems.org" + +gem 'json_schemer' +gem 'json' diff --git a/implementations/json_schemer/Gemfile.lock b/implementations/json_schemer/Gemfile.lock new file mode 100644 index 0000000..cc48f78 --- /dev/null +++ b/implementations/json_schemer/Gemfile.lock @@ -0,0 +1,23 @@ +GEM + remote: https://rubygems.org/ + specs: + bigdecimal (3.1.8) + hana (1.3.7) + json (2.7.2) + json_schemer (2.3.0) + bigdecimal + hana (~> 1.3) + regexp_parser (~> 2.0) + simpleidn (~> 0.2) + regexp_parser (2.9.2) + simpleidn (0.2.3) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + json + json_schemer + +BUNDLED WITH + 2.4.19 diff --git a/implementations/json_schemer/main.rb b/implementations/json_schemer/main.rb new file mode 100644 index 0000000..7e82e81 --- /dev/null +++ b/implementations/json_schemer/main.rb @@ -0,0 +1,22 @@ +require 'json_schemer' +require 'json' + +path = ARGV[0] + +# Load the schema and build a validator +schema = JSON.parse(File.read(File.join(path, "schema.json"))) +schemer = JSONSchemer.schema(schema) + +# Read all instances into an array +instances = File.open(File.join(path, "instances.jsonl")).map do |line| + JSON.parse(line) +end + +# Run the validation +start_time = Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond) +instances.each do |instance| + if !schemer.valid?(instance) then exit! end +end +end_time = Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond) + +puts end_time - start_time diff --git a/implementations/json_schemer/version.sh b/implementations/json_schemer/version.sh new file mode 100755 index 0000000..3e49f99 --- /dev/null +++ b/implementations/json_schemer/version.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +set -o errexit +set -o nounset + +# Extract the version of the package (json_schemer) from Gemfile.lock +json_schemer_version=$(grep -Po '(?<=json_schemer \().*(?=\))' implementations/json_schemer/Gemfile.lock) + +# Output the version +echo "$json_schemer_version"