Skip to content

Commit

Permalink
Implement JSON Schema for PGXN Meta Spec v1
Browse files Browse the repository at this point in the history
Based on the descriptions in `spec.md` and the validation in
pgxn/pgxn-meta-validator, write JSON Schema v2020 schemas to validate
PGXN Meta Spec `META.json` files. The implementation should be at least
as good as the old one, now portable for use in other languages.

In the process, correct a few issues and errors discovered in `spec.md`.

Add a test suite in Rust that uses the boon crate to verify that the
schemas, their IDs, and their examples are valid. This sets the stage
for writing a validation utility in Rust.

To keep things tidy and somewhat standardized, add a pre-commit
configuration to lint the JSON and Rust code.

Then setup a GitHub workflow to run the tests on macOS, Windows, and
Linux, and the pre-commit linting on Linux. Overkill for now, since
there is no Rust library, just tests for the JSON Schema, but likely to
be needed before long.
  • Loading branch information
theory committed Jun 28, 2024
1 parent aff1854 commit d61090c
Show file tree
Hide file tree
Showing 26 changed files with 1,229 additions and 13 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/test-and-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 🧪 Test and Lint
on:
push:
branches-ignore: [wip/**]
jobs:
test:
strategy:
matrix:
os: [[🐧, Ubuntu], [🍎, macOS], [🪟, Windows]]
toolchain: ["stable", "beta", "nightly"]
name: 🦀 ${{ matrix.toolchain }} on ${{ matrix.os[0] }} ${{ matrix.os[1] }}
runs-on: ${{ matrix.os[1] }}-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust Cache
uses: Swatinem/rust-cache@v2
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with: { toolchain: "${{ matrix.toolchain }}" }
- name: Test
run: make test

lint:
name: 🔎 Lint and Cover
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust Cache
uses: Swatinem/rust-cache@v2
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Run pre-commit
uses: pre-commit/action@v3.0.1
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/.vscode
.DS_Store
.idea/
/target
.vscode/
vendor/
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# auth-global hooks will be managed / updated across all auth repos.
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
name: Lint trailing whitespace
exclude_types: [image]
- id: end-of-file-fixer
name: Lint end-of-file newline
exclude_types: [image]
- id: check-added-large-files
name: Don't permit large files
exclude_types: [image]

- repo: https://github.com/backplane/pre-commit-rust-hooks
rev: v1.1.0
hooks:
- id: fmt
- id: check
- id: clippy
- id: test

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
name: JSON and YAML formatting
types_or: [json, yaml]
320 changes: 320 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d61090c

Please sign in to comment.