Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Luni-4 committed Jan 12, 2021
0 parents commit b83d74e
Show file tree
Hide file tree
Showing 20 changed files with 1,877 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/actions-rs/grcov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ignore-not-existing: true
ignore:
- "/*"
- "../*"
132 changes: 132 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: deploy

on:
push:
tags:
- 'v*.*.*'

jobs:

windows-binaries:

runs-on: windows-latest

steps:
- uses: actions/checkout@v2

- name: Install stable
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Build json-diff
run: |
cargo build --release --workspace
- name: Create zip
run: |
cd target/release
7z a ../../json-structural-diff-windows-msvc.zip `
"json-structural-diff-cli.exe"
- name: Upload binaries
uses: actions/upload-artifact@v2
with:
name: json-diff-windows-msvc-binaries
path: json-structural-diff-windows-msvc.zip

linux-binaries:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install musl-tools
run: |
sudo apt-get install musl-tools
- name: Install Rust stable and musl target
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: x86_64-unknown-linux-musl
override: true

- name: Build json-diff
run: |
cargo build --workspace --release --target x86_64-unknown-linux-musl
- name: Create zip
run: |
cd target/x86_64-unknown-linux-musl/release
strip json-structural-diff-cli
tar -czvf $GITHUB_WORKSPACE/json-structural-diff-linux.tar.gz \
json-structural-diff-cli
- name: Upload binaries
uses: actions/upload-artifact@v2
with:
name: json-diff-linux-binaries
path: json-structural-diff-linux.tar.gz

macos-binaries:

runs-on: macos-latest

steps:
- uses: actions/checkout@v2

- name: Install stable
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Build json-diff
run: |
cargo build --workspace --release
- name: Create zip
run: |
cd target/release
strip json-structural-diff-cli
zip $GITHUB_WORKSPACE/json-structural-diff-macos.zip \
json-structural-diff-cli
- name: Upload binaries
uses: actions/upload-artifact@v2
with:
name: json-diff-macos-binaries
path: json-structural-diff-macos.zip

deploy:

needs: [windows-binaries, linux-binaries, macos-binaries]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Download zip files
uses: actions/download-artifact@v2

- name: Create Cargo.lock
run: |
cargo update
- name: Create a release
uses: softprops/action-gh-release@v1
with:
files: |
Cargo.lock
json-diff-linux-binaries/json-structural-diff-linux.tar.gz
json-diff-macos-binaries/json-structural-diff-macos.zip
json-diff-windows-msvc-binaries/json-structural-diff-windows-msvc.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105 changes: 105 additions & 0 deletions .github/workflows/json-structural-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: json-structural-diff

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
clippy-rustfmt:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install stable
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: clippy, rustfmt

- name: Run rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check --verbose

- name: Run cargo clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features -- -D warnings

code-coverage:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true

- uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --no-fail-fast
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: >
-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code
-Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests
RUSTDOCFLAGS: >
-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code
-Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests
- id: coverage
uses: actions-rs/grcov@v0.1

- name: Coveralls upload
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ${{ steps.coverage.outputs.report }}

tests:

strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v2

- name: Install stable
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Build
run: |
cargo build --workspace --all-features
- name: Run no-default-features tests
run: |
cargo test --no-default-features
- name: Run all-features tests
run: |
cargo test --all-features
- name: Generate docs
run: |
cargo doc --all-features --no-deps
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
25 changes: 25 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "json-structural-diff"
version = "0.1.0"
authors = ["Luni-4 <luni-4@hotmail.it>"]
description = "A Rust JSON structural diff library"
repository = "https://github.com/Luni-4/json-structural-diff"
keywords = ["json-structural-diff", "json-diff"]
license = "MIT"
edition = "2018"

[features]
colorize = ["console"]

[dependencies]
difflib = "^0.4"
regex = "^1"
serde_json = "^1.0"

[dependencies.console]
version = "^0.13"
default-features = true
optional = true

[workspace]
members = ["json-structural-diff-cli"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Luni-4

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# A Rust JSON structural diff

[![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Actions Status](https://github.com/Luni-4/json-structural-diff/workflows/json-structural-diff/badge.svg)](https://github.com/Luni-4/json-structural-diff/actions)
[![Coverage Status](https://coveralls.io/repos/github/Luni-4/json-structural-diff/badge.svg?branch=master)](https://coveralls.io/github/Luni-4/json-structural-diff?branch=master)

A pure-Rust JSON structural diff based on [this](https://github.com/andreyvit/json-diff)
implementation.

This project has been developed with the aim of testing parallelism.

## Building library

```bash
cargo build
```

To build with the `colorize` feature:

```bash
cargo build --all-features
```

If you want to build the lib in release mode, add the `--release` optio
to the commands above.

## License

Released under the [MIT License](LICENSE).
23 changes: 23 additions & 0 deletions data/a.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"foo": 42,
"bar": 100,
"boz": [
1,
2,
3,
4,
5,
6
],
"fubar": {
"kaboom": {
"note": "We're running dangerously low on metasyntatic variables here",
"afoo": {
"abar": "raba",
"aboz": "zoba",
"afubar": "rabufa"
},
"akaboom": 200
}
}
}
23 changes: 23 additions & 0 deletions data/b.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"foo": 42,
"bar": 100,
"boz": [
0,
1,
4,
5,
6,
7
],
"fubar": {
"kaboom": {
"note": "We're running dangerously low on metasyntatic variables here",
"afoo": {
"abar": "raba",
"aboz": "zozoba",
"afubar": "rabufa"
},
"akaboom": 200
}
}
}
20 changes: 20 additions & 0 deletions data/result.jsdiff
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
boz: [
+ 0
1
- 2
- 3
4
5
6
+ 7
]
fubar: {
kaboom: {
afoo: {
- aboz: "zoba"
+ aboz: "zozoba"
}
}
}
}
Loading

0 comments on commit b83d74e

Please sign in to comment.