Skip to content

Commit b83d74e

Browse files
committed
Initial commit
0 parents  commit b83d74e

File tree

20 files changed

+1877
-0
lines changed

20 files changed

+1877
-0
lines changed

.github/actions-rs/grcov.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ignore-not-existing: true
2+
ignore:
3+
- "/*"
4+
- "../*"

.github/workflows/deploy.yml

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: deploy
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
jobs:
9+
10+
windows-binaries:
11+
12+
runs-on: windows-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- name: Install stable
18+
uses: actions-rs/toolchain@v1
19+
with:
20+
profile: minimal
21+
toolchain: stable
22+
override: true
23+
24+
- name: Build json-diff
25+
run: |
26+
cargo build --release --workspace
27+
28+
- name: Create zip
29+
run: |
30+
cd target/release
31+
7z a ../../json-structural-diff-windows-msvc.zip `
32+
"json-structural-diff-cli.exe"
33+
34+
- name: Upload binaries
35+
uses: actions/upload-artifact@v2
36+
with:
37+
name: json-diff-windows-msvc-binaries
38+
path: json-structural-diff-windows-msvc.zip
39+
40+
linux-binaries:
41+
42+
runs-on: ubuntu-latest
43+
44+
steps:
45+
- uses: actions/checkout@v2
46+
47+
- name: Install musl-tools
48+
run: |
49+
sudo apt-get install musl-tools
50+
51+
- name: Install Rust stable and musl target
52+
uses: actions-rs/toolchain@v1
53+
with:
54+
profile: minimal
55+
toolchain: stable
56+
target: x86_64-unknown-linux-musl
57+
override: true
58+
59+
- name: Build json-diff
60+
run: |
61+
cargo build --workspace --release --target x86_64-unknown-linux-musl
62+
63+
- name: Create zip
64+
run: |
65+
cd target/x86_64-unknown-linux-musl/release
66+
strip json-structural-diff-cli
67+
tar -czvf $GITHUB_WORKSPACE/json-structural-diff-linux.tar.gz \
68+
json-structural-diff-cli
69+
70+
- name: Upload binaries
71+
uses: actions/upload-artifact@v2
72+
with:
73+
name: json-diff-linux-binaries
74+
path: json-structural-diff-linux.tar.gz
75+
76+
macos-binaries:
77+
78+
runs-on: macos-latest
79+
80+
steps:
81+
- uses: actions/checkout@v2
82+
83+
- name: Install stable
84+
uses: actions-rs/toolchain@v1
85+
with:
86+
profile: minimal
87+
toolchain: stable
88+
override: true
89+
90+
- name: Build json-diff
91+
run: |
92+
cargo build --workspace --release
93+
94+
- name: Create zip
95+
run: |
96+
cd target/release
97+
strip json-structural-diff-cli
98+
zip $GITHUB_WORKSPACE/json-structural-diff-macos.zip \
99+
json-structural-diff-cli
100+
101+
- name: Upload binaries
102+
uses: actions/upload-artifact@v2
103+
with:
104+
name: json-diff-macos-binaries
105+
path: json-structural-diff-macos.zip
106+
107+
deploy:
108+
109+
needs: [windows-binaries, linux-binaries, macos-binaries]
110+
111+
runs-on: ubuntu-latest
112+
113+
steps:
114+
- uses: actions/checkout@v2
115+
116+
- name: Download zip files
117+
uses: actions/download-artifact@v2
118+
119+
- name: Create Cargo.lock
120+
run: |
121+
cargo update
122+
123+
- name: Create a release
124+
uses: softprops/action-gh-release@v1
125+
with:
126+
files: |
127+
Cargo.lock
128+
json-diff-linux-binaries/json-structural-diff-linux.tar.gz
129+
json-diff-macos-binaries/json-structural-diff-macos.zip
130+
json-diff-windows-msvc-binaries/json-structural-diff-windows-msvc.zip
131+
env:
132+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: json-structural-diff
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
clippy-rustfmt:
13+
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: Install stable
20+
uses: actions-rs/toolchain@v1
21+
with:
22+
profile: minimal
23+
toolchain: stable
24+
override: true
25+
components: clippy, rustfmt
26+
27+
- name: Run rustfmt
28+
uses: actions-rs/cargo@v1
29+
with:
30+
command: fmt
31+
args: -- --check --verbose
32+
33+
- name: Run cargo clippy
34+
uses: actions-rs/clippy-check@v1
35+
with:
36+
token: ${{ secrets.GITHUB_TOKEN }}
37+
args: --all-features -- -D warnings
38+
39+
code-coverage:
40+
41+
runs-on: ubuntu-latest
42+
43+
steps:
44+
- uses: actions/checkout@v2
45+
46+
- uses: actions-rs/toolchain@v1
47+
with:
48+
toolchain: nightly
49+
override: true
50+
51+
- uses: actions-rs/cargo@v1
52+
with:
53+
command: test
54+
args: --all-features --no-fail-fast
55+
env:
56+
CARGO_INCREMENTAL: '0'
57+
RUSTFLAGS: >
58+
-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code
59+
-Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests
60+
RUSTDOCFLAGS: >
61+
-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code
62+
-Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests
63+
64+
- id: coverage
65+
uses: actions-rs/[email protected]
66+
67+
- name: Coveralls upload
68+
uses: coverallsapp/github-action@master
69+
with:
70+
github-token: ${{ secrets.GITHUB_TOKEN }}
71+
path-to-lcov: ${{ steps.coverage.outputs.report }}
72+
73+
tests:
74+
75+
strategy:
76+
matrix:
77+
platform: [ubuntu-latest, macos-latest, windows-latest]
78+
79+
runs-on: ${{ matrix.platform }}
80+
81+
steps:
82+
- uses: actions/checkout@v2
83+
84+
- name: Install stable
85+
uses: actions-rs/toolchain@v1
86+
with:
87+
profile: minimal
88+
toolchain: stable
89+
override: true
90+
91+
- name: Build
92+
run: |
93+
cargo build --workspace --all-features
94+
95+
- name: Run no-default-features tests
96+
run: |
97+
cargo test --no-default-features
98+
99+
- name: Run all-features tests
100+
run: |
101+
cargo test --all-features
102+
103+
- name: Generate docs
104+
run: |
105+
cargo doc --all-features --no-deps

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

Cargo.toml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[package]
2+
name = "json-structural-diff"
3+
version = "0.1.0"
4+
authors = ["Luni-4 <[email protected]>"]
5+
description = "A Rust JSON structural diff library"
6+
repository = "https://github.com/Luni-4/json-structural-diff"
7+
keywords = ["json-structural-diff", "json-diff"]
8+
license = "MIT"
9+
edition = "2018"
10+
11+
[features]
12+
colorize = ["console"]
13+
14+
[dependencies]
15+
difflib = "^0.4"
16+
regex = "^1"
17+
serde_json = "^1.0"
18+
19+
[dependencies.console]
20+
version = "^0.13"
21+
default-features = true
22+
optional = true
23+
24+
[workspace]
25+
members = ["json-structural-diff-cli"]

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Luni-4
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# A Rust JSON structural diff
2+
3+
[![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
4+
[![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)
5+
[![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)
6+
7+
A pure-Rust JSON structural diff based on [this](https://github.com/andreyvit/json-diff)
8+
implementation.
9+
10+
This project has been developed with the aim of testing parallelism.
11+
12+
## Building library
13+
14+
```bash
15+
cargo build
16+
```
17+
18+
To build with the `colorize` feature:
19+
20+
```bash
21+
cargo build --all-features
22+
```
23+
24+
If you want to build the lib in release mode, add the `--release` optio
25+
to the commands above.
26+
27+
## License
28+
29+
Released under the [MIT License](LICENSE).

data/a.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"foo": 42,
3+
"bar": 100,
4+
"boz": [
5+
1,
6+
2,
7+
3,
8+
4,
9+
5,
10+
6
11+
],
12+
"fubar": {
13+
"kaboom": {
14+
"note": "We're running dangerously low on metasyntatic variables here",
15+
"afoo": {
16+
"abar": "raba",
17+
"aboz": "zoba",
18+
"afubar": "rabufa"
19+
},
20+
"akaboom": 200
21+
}
22+
}
23+
}

data/b.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"foo": 42,
3+
"bar": 100,
4+
"boz": [
5+
0,
6+
1,
7+
4,
8+
5,
9+
6,
10+
7
11+
],
12+
"fubar": {
13+
"kaboom": {
14+
"note": "We're running dangerously low on metasyntatic variables here",
15+
"afoo": {
16+
"abar": "raba",
17+
"aboz": "zozoba",
18+
"afubar": "rabufa"
19+
},
20+
"akaboom": 200
21+
}
22+
}
23+
}

data/result.jsdiff

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
boz: [
3+
+ 0
4+
1
5+
- 2
6+
- 3
7+
4
8+
5
9+
6
10+
+ 7
11+
]
12+
fubar: {
13+
kaboom: {
14+
afoo: {
15+
- aboz: "zoba"
16+
+ aboz: "zozoba"
17+
}
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)