Skip to content

Commit

Permalink
Merge branch 'main' into darksky/node-binding-impl
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit authored Aug 29, 2023
2 parents b74064b + c057797 commit ef16776
Show file tree
Hide file tree
Showing 27 changed files with 1,322 additions and 1,092 deletions.
3 changes: 0 additions & 3 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
[env]
CARGO_WORKSPACE_DIR = { value = "", relative = true }

[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "target-cpu=native"]
6 changes: 3 additions & 3 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ inputs:
components:
description: "Cargo components"
required: false
target:
targets:
description: "Cargo target"
required: true
required: false
toolchain:
description: "Rustup toolchain"
required: false
Expand All @@ -19,6 +19,6 @@ runs:
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ inputs.toolchain }}
targets: ${{ inputs.target }}
targets: ${{ inputs.targets }}
components: ${{ inputs.components }}
- uses: Swatinem/rust-cache@v2
26 changes: 14 additions & 12 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
with:
ref: main

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
toolchain: stable

Expand Down Expand Up @@ -66,6 +66,16 @@ jobs:
- benchmark

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
toolchain: stable

- name: Install critcmp
uses: taiki-e/install-action@v2
with:
Expand All @@ -80,11 +90,7 @@ jobs:
- name: Linux | Compare benchmark results
shell: bash
run: |
echo "## Benchmark Results" >> summary.md
echo "### Linux" >> summary.md
echo "\`\`\`" >> summary.md
critcmp main pr >> summary.md
echo "\`\`\`" >> summary.md
critcmp main pr | cargo run -p y-octo-utils --bin bench_result_render --features bench -- Linux >> summary.md
echo "" >> summary.md
- name: Linux | Cleanup benchmark results
Expand All @@ -99,11 +105,7 @@ jobs:
- name: Windows | Compare benchmark results
shell: bash
run: |
echo "### Windows" >> summary.md
echo "\`\`\`" >> summary.md
critcmp main pr >> summary.md
echo "\`\`\`" >> summary.md
echo "" >> summary.md
critcmp main pr | cargo run -p y-octo-utils --bin bench_result_render --features bench -- Windows >> summary.md
cat summary.md > $GITHUB_STEP_SUMMARY
- name: Find Comment
Expand Down
99 changes: 51 additions & 48 deletions .github/workflows/y-octo.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Y-Octo
name: Lint & Test & Fuzzing & Miri & Loom

on:
workflow_dispatch:
Expand All @@ -7,6 +7,9 @@ on:
pull_request:
branches: [main]

env:
nightly: nightly-2023-08-19

# Cancels all previous workflow runs for pull requests that have not completed.
# See https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
Expand Down Expand Up @@ -50,8 +53,8 @@ jobs:

- name: Build & Check
run: |
cargo vendor > .cargo/config
cargo clippy --all-features --message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
cargo vendor > .cargo/config.toml
cargo clippy --all-features --message-format=json -- -D warnings | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
RUSTDOCFLAGS="-D rustdoc::broken-intra-doc-links" cargo doc --workspace --all-features --no-deps
env:
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -88,53 +91,70 @@ jobs:
uses: taiki-e/install-action@cargo-llvm-cov

- name: Collect coverage data
run: cargo llvm-cov nextest --lcov --output-path lcov.info
run: cargo llvm-cov nextest --all-targets --lcov --output-path lcov.info
- name: Upload coverage data to codecov
uses: codecov/codecov-action@v3
with:
name: tests
files: lcov.info

memory_check:
name: memory check
loom:
name: loom thread test
runs-on: ubuntu-latest
continue-on-error: true
env:
RUSTFLAGS: -D warnings -Zsanitizer=address
ASAN_OPTIONS: detect_leaks=1
RUSTFLAGS: --cfg loom
RUST_BACKTRACE: full
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v3

- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
toolchain: nightly-2023-08-19
- name: Install latest nextest release
uses: taiki-e/install-action@nextest

- name: Memory Check
- name: Loom Thread Test
run: |
rustup component add rust-src --toolchain nightly-2023-08-19
cargo +nightly-2023-08-19 test -Zbuild-std --target x86_64-unknown-linux-gnu -p y-octo --lib
cargo nextest run -p y-octo --lib
loom:
name: loom thread test
fuzzing:
name: fuzzing
runs-on: ubuntu-latest
continue-on-error: true
env:
RUSTFLAGS: --cfg loom
RUST_BACKTRACE: full
RUSTFLAGS: -D warnings
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v3

- name: Setup Rust
uses: ./.github/actions/setup-rust
- name: Install latest nextest release
uses: taiki-e/install-action@nextest
with:
toolchain: ${{ env.nightly }}

- name: Loom Thread Test
- name: fuzzing
working-directory: ./y-octo
run: |
cargo nextest run -p y-octo --lib
cargo install cargo-fuzz
cargo +${{ env.nightly }} fuzz run apply_update -- -max_total_time=30
cargo +${{ env.nightly }} fuzz run codec_doc_any_struct -- -max_total_time=30
cargo +${{ env.nightly }} fuzz run codec_doc_any -- -max_total_time=30
cargo +${{ env.nightly }} fuzz run decode_bytes -- -max_total_time=30
cargo +${{ env.nightly }} fuzz run i32_decode -- -max_total_time=30
cargo +${{ env.nightly }} fuzz run i32_encode -- -max_total_time=30
cargo +${{ env.nightly }} fuzz run ins_del_text -- -max_total_time=30
cargo +${{ env.nightly }} fuzz run sync_message -- -max_total_time=30
cargo +${{ env.nightly }} fuzz run u64_decode -- -max_total_time=30
cargo +${{ env.nightly }} fuzz run u64_encode -- -max_total_time=30
cargo +${{ env.nightly }} fuzz run apply_update -- -max_total_time=30
- name: upload fuzz artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: fuzz-artifact
path: ./y-octo/fuzz/artifacts/**/*

miri:
name: miri code check
Expand All @@ -150,49 +170,32 @@ jobs:
- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
toolchain: nightly-2023-08-19
toolchain: ${{ env.nightly }}
components: miri
- name: Install latest nextest release
uses: taiki-e/install-action@nextest

- name: Miri Code Check
run: |
cargo +nightly-2023-08-19 miri nextest run -p y-octo -j2
cargo +${{ env.nightly }} miri nextest run -p y-octo -j2
fuzzing:
name: fuzzing
asan:
name: Address sanitizer
runs-on: ubuntu-latest
continue-on-error: true
env:
RUSTFLAGS: -D warnings
RUSTFLAGS: -D warnings -Zsanitizer=address
ASAN_OPTIONS: detect_leaks=1
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v3

- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
toolchain: nightly-2023-08-19
toolchain: ${{ env.nightly }}

- name: fuzzing
working-directory: ./y-octo
- name: Memory Check
run: |
cargo install cargo-fuzz
cargo +nightly-2023-08-19 fuzz run apply_update -- -max_total_time=30
cargo +nightly-2023-08-19 fuzz run codec_doc_any_struct -- -max_total_time=30
cargo +nightly-2023-08-19 fuzz run codec_doc_any -- -max_total_time=30
cargo +nightly-2023-08-19 fuzz run decode_bytes -- -max_total_time=30
cargo +nightly-2023-08-19 fuzz run i32_decode -- -max_total_time=30
cargo +nightly-2023-08-19 fuzz run i32_encode -- -max_total_time=30
cargo +nightly-2023-08-19 fuzz run ins_del_text -- -max_total_time=30
cargo +nightly-2023-08-19 fuzz run sync_message -- -max_total_time=30
cargo +nightly-2023-08-19 fuzz run u64_decode -- -max_total_time=30
cargo +nightly-2023-08-19 fuzz run u64_encode -- -max_total_time=30
cargo +nightly-2023-08-19 fuzz run apply_update -- -max_total_time=30
- name: upload fuzz artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: fuzz-artifact
path: ./y-octo/fuzz/artifacts/**/*
rustup component add rust-src --toolchain ${{ env.nightly }}
cargo +${{ env.nightly }} test -Zbuild-std --target x86_64-unknown-linux-gnu -p y-octo --lib
74 changes: 73 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,82 @@
# Y-Octo

[![test](https://github.com/toeverything/y-octo/actions/workflows/y-octo.yml/badge.svg)](https://github.com/toeverything/y-octo/actions/workflows/y-octo.yml)
[![docs]](https://docs.rs/y-octo/latest/y_octo)
[![crates]](https://crates.io/crates/y-octo)
[![codecov]](https://codecov.io/gh/toeverything/y-octo)

Y-Octo is a high-performance CRDT implementation compatible with [yjs].

Y-Octo aims to provide a thread-safe, high-performance CRDT implementation on multiple platforms and offers binary compatibility and interoperability with [yjs].
### Introduction

Y-Octo is a tiny, ultra-fast CRDT collaboration library built for all major platforms. Developers can use Y-Octo as the [Single source of truth](https://en.wikipedia.org/wiki/Single_source_of_truth) for their application state, naturally turning the application into a [local-first](https://www.inkandswitch.com/local-first/) collaborative app.

Y-Octo also has interoperability and binary compatibility with [yjs]. Developers can use [yjs] to develop local-first web applications and collaborate with Y-Octo in native apps alongside web apps.

### Features

- ✅ Collaborative Text
- ✅ Read and write styled Unicode compatible data.
- 🚧 Add, modify and delete text styles.
- 🚧 Embedded JS data types and collaborative types.
- ✅ Collaborative types of thread-safe.
- Collaborative Array
- ✅ Add, modify, and delete basic JS data types.
- ✅ Recursively add, modify, and delete collaborative types.
- ✅ Collaborative types of thread-safe.
- 🚧 Recursive event subscription
- Collaborative Map
- ✅ Add, modify, and delete basic JS data types.
- ✅ Recursively add, modify, and delete collaborative types.
- ✅ Collaborative types of thread-safe.
- 🚧 Recursive event subscription
- 🚧 Collaborative Xml (Fragment / Element)
- ✅ Collaborative Doc Container
- ✅ YATA CRDT state apply/diff compatible with [yjs]
- ✅ State sync of thread-safe.
- ✅ Store all collaborative types and JS data types
- ✅ Update event subscription.
- 🚧 Sub Document.
- ✅ Yjs binary encoding
- ✅ Awareness encoding.
- ✅ Primitive type encoding.
- ✅ Sync Protocol encoding.
- ✅ Yjs update v1 encoding.
- 🚧 Yjs update v2 encoding.

### Testing & Linting

Put everything to the test! We've established various test suites, but we're continually striving to enhance our coverage:

- Rust Tests
- Node Tests
- Smoke Tests
- eslint, clippy

### Related projects

- [OctoBase]: The open-source embedded database based on Y-Octo.
- [yjs]: Shared data types for building collaborative software in web.

## Maintainers

- [DarkSky](https://github.com/darkskygit)
- [liuyi](https://github.com/forehalo)
- [X1a0t](https://github.com/thorseraq)
- [LongYinan](https://github.com/Brooooooklyn)

## License

Y-Octo are [MIT licensed].

[codecov]: https://codecov.io/gh/toeverything/y-octo/graph/badge.svg?token=9AQY5Q1BYH
[crates]: https://img.shields.io/crates/v/y-octo.svg
[docs]: https://img.shields.io/docsrs/y-octo.svg
[test]: https://github.com/toeverything/y-octo/actions/workflows/y-octo.yml/badge.svg
[yjs]: https://github.com/yjs/yjs
[Address Sanitizer]: https://github.com/toeverything/y-octo/actions/workflows/y-octo-asan.yml/badge.svg
[Memory Leak Detect]: https://github.com/toeverything/y-octo/actions/workflows/y-octo-memory-test.yml/badge.svg
[OctoBase]: https://github.com/toeverything/octobase
[BlockSuite]: https://github.com/toeverything/blocksuite
[AFFiNE]: https://github.com/toeverything/affine
[MIT licensed]: ./LICENSE
42 changes: 42 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,47 @@
"*.rs": [
"cargo +nightly-2023-08-19 fmt --"
]
},
"resolutions": {
"array-buffer-byte-length": "npm:@nolyfill/array-buffer-byte-length@latest",
"arraybuffer.prototype.slice": "npm:@nolyfill/arraybuffer.prototype.slice@latest",
"available-typed-arrays": "npm:@nolyfill/available-typed-arrays@latest",
"define-properties": "npm:@nolyfill/define-properties@latest",
"es-set-tostringtag": "npm:@nolyfill/es-set-tostringtag@latest",
"function-bind": "npm:@nolyfill/function-bind@latest",
"function.prototype.name": "npm:@nolyfill/function.prototype.name@latest",
"get-symbol-description": "npm:@nolyfill/get-symbol-description@latest",
"globalthis": "npm:@nolyfill/globalthis@latest",
"gopd": "npm:@nolyfill/gopd@latest",
"has": "npm:@nolyfill/has@latest",
"has-property-descriptors": "npm:@nolyfill/has-property-descriptors@latest",
"has-proto": "npm:@nolyfill/has-proto@latest",
"has-symbols": "npm:@nolyfill/has-symbols@latest",
"has-tostringtag": "npm:@nolyfill/has-tostringtag@latest",
"internal-slot": "npm:@nolyfill/internal-slot@latest",
"is-array-buffer": "npm:@nolyfill/is-array-buffer@latest",
"is-date-object": "npm:@nolyfill/is-date-object@latest",
"is-regex": "npm:@nolyfill/is-regex@latest",
"is-shared-array-buffer": "npm:@nolyfill/is-shared-array-buffer@latest",
"is-string": "npm:@nolyfill/is-string@latest",
"is-symbol": "npm:@nolyfill/is-symbol@latest",
"is-weakref": "npm:@nolyfill/is-weakref@latest",
"object-keys": "npm:@nolyfill/object-keys@latest",
"object.assign": "npm:@nolyfill/object.assign@latest",
"regexp.prototype.flags": "npm:@nolyfill/regexp.prototype.flags@latest",
"safe-array-concat": "npm:@nolyfill/safe-array-concat@latest",
"safe-regex-test": "npm:@nolyfill/safe-regex-test@latest",
"side-channel": "npm:@nolyfill/side-channel@latest",
"string.prototype.padend": "npm:@nolyfill/string.prototype.padend@latest",
"string.prototype.trim": "npm:@nolyfill/string.prototype.trim@latest",
"string.prototype.trimend": "npm:@nolyfill/string.prototype.trimend@latest",
"string.prototype.trimstart": "npm:@nolyfill/string.prototype.trimstart@latest",
"typed-array-buffer": "npm:@nolyfill/typed-array-buffer@latest",
"typed-array-byte-length": "npm:@nolyfill/typed-array-byte-length@latest",
"typed-array-byte-offset": "npm:@nolyfill/typed-array-byte-offset@latest",
"typed-array-length": "npm:@nolyfill/typed-array-length@latest",
"unbox-primitive": "npm:@nolyfill/unbox-primitive@latest",
"which-boxed-primitive": "npm:@nolyfill/which-boxed-primitive@latest",
"which-typed-array": "npm:@nolyfill/which-typed-array@latest"
}
}
Loading

0 comments on commit ef16776

Please sign in to comment.