Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 117 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
cache-all-crates: "true"
key: ${{ matrix.os }}

- run: cargo test --no-fail-fast --all-features --workspace --exclude jsonschema-py
- run: cargo test --no-fail-fast --all-features --workspace --exclude jsonschema-py --exclude jsonschema-rb

test-wasm:
strategy:
Expand Down Expand Up @@ -176,6 +176,7 @@ jobs:
run: |
cargo llvm-cov --no-report --all-features --workspace \
--exclude jsonschema-py \
--exclude jsonschema-rb \
--exclude benchmark \
--exclude benchmark-suite \
--exclude jsonschema-testsuite \
Expand Down Expand Up @@ -301,6 +302,121 @@ jobs:
uv pip install crates/jsonschema-py/dist/*.whl
uv run --with pytest --with hypothesis pytest crates/jsonschema-py/tests-py

test-ruby:
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-15]
ruby-version: ['3.2', '3.4', '4.0']

name: Test Ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
with:
submodules: true

- uses: dtolnay/rust-toolchain@stable

- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
working-directory: crates/jsonschema-rb

- run: bundle exec rake compile
working-directory: crates/jsonschema-rb

- run: bundle exec rspec
working-directory: crates/jsonschema-rb

test-ruby-gem-install:
name: Ruby Gem Install ${{ matrix.ruby-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-15]
ruby-version: ['3.2', '3.4', '4.0']

steps:
- uses: actions/checkout@v6
with:
submodules: true

- uses: dtolnay/rust-toolchain@stable

- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: false

- name: Build gem
run: gem build jsonschema.gemspec
working-directory: crates/jsonschema-rb

- name: Install rb_sys
run: gem install rb_sys -v '~> 0.9' --no-document

- name: Install gem
run: |
GEM_FILE=$(ls jsonschema-*.gem | head -1)
gem install "./$GEM_FILE" --local --no-document
working-directory: crates/jsonschema-rb
shell: bash

- name: Smoke test
run: |
ruby -e "
require 'jsonschema'
raise 'valid? failed' unless JSONSchema.valid?({'type' => 'string'}, 'hello')
raise 'valid? false positive' if JSONSchema.valid?({'type' => 'string'}, 42)
puts 'Gem installation OK'
"

test-ruby-gem-install-musl:
name: Ruby Gem Install (Alpine/musl)
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v6
with:
submodules: true

- name: Test gem install on Alpine/musl
run: |
docker run --rm \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
public.ecr.aws/docker/library/ruby:3.4-alpine3.21 \
sh -c '
set -e
apk add --no-cache alpine-sdk curl gcompat clang clang-dev llvm-dev
curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. ~/.cargo/env
gem update --system
cd crates/jsonschema-rb
gem install rb_sys -v "~> 0.9" --no-document
gem build jsonschema.gemspec
gem install jsonschema-*.gem --local --no-document
ruby -e "require \"jsonschema\"; raise unless JSONSchema.valid?({\"type\" => \"string\"}, \"hello\"); puts \"musl OK\""
'

lint-ruby:
name: Lint Ruby
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6

- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4'
bundler-cache: true
working-directory: crates/jsonschema-rb

- run: bundle exec rubocop
working-directory: crates/jsonschema-rb

lint-fmt:
name: Lint formatting
runs-on: ubuntu-24.04
Expand Down
125 changes: 125 additions & 0 deletions .github/workflows/ruby-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: Ruby Release

on:
push:
tags:
- ruby-v*
workflow_dispatch:

defaults:
run:
shell: bash

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
ci-data:
runs-on: ubuntu-24.04
outputs:
supported-ruby-platforms: ${{ steps.parse.outputs.supported-ruby-platforms }}
stable-ruby-versions: ${{ steps.parse.outputs.stable-ruby-versions }}
steps:
- id: fetch
uses: oxidize-rb/actions/fetch-ci-data@v1
with:
supported-ruby-platforms: |
exclude:
- arm-linux
- x64-mingw32
- aarch64-mingw-ucrt
stable-ruby-versions: |
exclude:
- head
- id: parse
run: |
echo "supported-ruby-platforms=$(echo '${{ steps.fetch.outputs.result }}' | jq -c '."supported-ruby-platforms"')" >> "$GITHUB_OUTPUT"
echo "stable-ruby-versions=$(echo '${{ steps.fetch.outputs.result }}' | jq -r '."stable-ruby-versions" | join(",")')" >> "$GITHUB_OUTPUT"
build:
name: Build (${{ matrix.platform }})
runs-on: ubuntu-24.04
needs: ci-data
strategy:
fail-fast: false
matrix:
platform: ${{ fromJSON(needs.ci-data.outputs.supported-ruby-platforms) }}
steps:
- uses: actions/checkout@v6
with:
submodules: true

- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"

- uses: oxidize-rb/actions/cross-gem@v1
id: cross-gem
with:
platform: ${{ matrix.platform }}
ruby-versions: ${{ needs.ci-data.outputs.stable-ruby-versions }}
working-directory: crates/jsonschema-rb

- name: Smoke test (x86_64-linux only)
if: matrix.platform == 'x86_64-linux'
run: |
gem install pkg/*.gem --local
ruby -e "require 'jsonschema'; raise 'validation failed' unless JSONSchema.valid?({'type'=>'string'}, 'hello'); puts 'smoke test OK'"
working-directory: crates/jsonschema-rb

- uses: actions/upload-artifact@v6
with:
name: gem-${{ matrix.platform }}
path: crates/jsonschema-rb/pkg/*.gem
if-no-files-found: error

release:
name: Release
runs-on: ubuntu-24.04
needs: build
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
submodules: true

- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"

- uses: actions/download-artifact@v7
with:
path: artifacts
pattern: gem-*

- name: Build source gem
run: gem build jsonschema.gemspec
working-directory: crates/jsonschema-rb

- name: Collect all gems
run: |
mkdir -p pkg
mv artifacts/**/*.gem pkg/
mv crates/jsonschema-rb/jsonschema-*.gem pkg/
- name: Push to RubyGems
env:
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
run: |
mkdir -p ~/.gem
echo "---" > ~/.gem/credentials
echo ":rubygems_api_key: ${RUBYGEMS_API_KEY}" >> ~/.gem/credentials
chmod 0600 ~/.gem/credentials
for gem in pkg/*.gem; do
echo "Pushing ${gem}..."
gem push "${gem}"
done
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: pkg/*.gem
generate_release_notes: true
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ rest_pat_in_fully_bound_structs = "warn"
files.extend-exclude = ["*.json"]
default.extend-ignore-re = ["propert"]

[patch.crates-io]
# Keep workspace crates (including language bindings) on the local core crate
# while still using a versioned dependency declaration in sub-crates.
jsonschema = { path = "crates/jsonschema" }

[profile.release]
lto = "fat"
codegen-units = 1
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-2025 Dmitry Dygalo
Copyright (c) 2020-2026 Dmitry Dygalo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ See more usage examples in the [documentation](https://docs.rs/jsonschema).
- 🌐 Blocking & non-blocking remote reference fetching (network/file)
- 🎨 Structured Output v1 reports (flag/list/hierarchical)
- ✨ Meta-schema validation for schema documents, including custom metaschemas
- 🔗 Bindings for [Python](https://github.com/Stranger6667/jsonschema/tree/master/crates/jsonschema-py)
- 🔗 Bindings for [Python](https://github.com/Stranger6667/jsonschema/tree/master/crates/jsonschema-py) and [Ruby](https://github.com/Stranger6667/jsonschema/tree/master/crates/jsonschema-rb)
- 🚀 WebAssembly support
- 💻 Command Line Interface

Expand Down
4 changes: 4 additions & 0 deletions crates/jsonschema-rb/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tmp/
vendor/
*.so
*.bundle
3 changes: 3 additions & 0 deletions crates/jsonschema-rb/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--require spec_helper
--format documentation
--color
40 changes: 40 additions & 0 deletions crates/jsonschema-rb/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
inherit_mode:
merge:
- Exclude

AllCops:
TargetRubyVersion: 3.2
NewCops: enable
SuggestExtensions: false
Exclude:
- "vendor/**/*"

# Keep line length relaxed for developer ergonomics and error-message expectations.
Layout/LineLength:
Max: 180
AllowURI: true
Exclude:
- "spec/**/*"

Layout/CaseIndentation:
EnforcedStyle: case

Layout/HashAlignment:
EnforcedHashRocketStyle: key
EnforcedColonStyle: key
EnforcedLastArgumentHashStyle: always_inspect

Gemspec/DeprecatedAttributeAssignment:
Enabled: true

Style/Documentation:
Enabled: false

Style/StringLiterals:
EnforcedStyle: double_quotes

Metrics/BlockLength:
Enabled: false

Metrics/ParameterLists:
Enabled: false
Loading
Loading