diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..0b17254 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,5 @@ +[env] +CARGO_WORKSPACE_DIR = { value = "", relative = true } + +[target.x86_64-unknown-linux-gnu] +rustflags = ["-C", "target-cpu=native"] diff --git a/.github/auto_assign.yml b/.github/auto_assign.yml new file mode 100644 index 0000000..c2c4c4a --- /dev/null +++ b/.github/auto_assign.yml @@ -0,0 +1,10 @@ +# This is used for tracking in GitHub project. +# See https://github.com/marketplace/actions/auto-assign-action + +# Set to true to add reviewers to pull requests +addReviewers: false + +# Set to true to add assignees to pull requests +addAssignees: author + +runOnDraft: true diff --git a/.github/workflows/yocto.yml b/.github/workflows/yocto.yml new file mode 100644 index 0000000..6c26ab5 --- /dev/null +++ b/.github/workflows/yocto.yml @@ -0,0 +1,193 @@ +name: Build Y-Octo + +on: + workflow_dispatch: + push: + branches: [master] + paths: + - "Cargo.toml" + - "packages/**" + - ".github/workflows/yocto.yml" + pull_request: + branches: [master] + paths: + - "Cargo.toml" + - "packages/**" + - ".github/workflows/yocto.yml" + +# Cancels all previous workflow runs for pull requests that have not completed. +# See https://docs.github.com/en/actions/using-jobs/using-concurrency +concurrency: + # The concurrency group contains the workflow name and the branch name for + # pull requests or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + permissions: + contents: read + security-events: write + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + components: clippy + override: true + + - uses: Swatinem/rust-cache@v2 + + - name: Install required cargo components + uses: taiki-e/install-action@v2 + with: + tool: clippy-sarif,sarif-fmt + + - name: Build & Check + run: | + cargo vendor > .cargo/config + cargo clippy --all-features --message-format=json | 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 + + - name: Upload analysis results to GitHub + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: rust-clippy-results.sarif + wait-for-processing: true + + test: + name: test & collect coverage + runs-on: ubuntu-latest + continue-on-error: true + env: + RUSTFLAGS: -D warnings + CARGO_TERM_COLOR: always + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + with: + components: llvm-tools-preview + - uses: Swatinem/rust-cache@v2 + + - name: Install latest nextest release + uses: taiki-e/install-action@nextest + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + + - name: Collect coverage data + run: cargo llvm-cov nextest --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 + runs-on: ubuntu-latest + continue-on-error: true + env: + RUSTFLAGS: -D warnings -Zsanitizer=address + ASAN_OPTIONS: detect_leaks=1 + CARGO_TERM_COLOR: always + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly-2023-08-19 + - uses: Swatinem/rust-cache@v2 + + - name: Memory Check + 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 + + loom: + name: loom thread test + runs-on: ubuntu-latest + continue-on-error: true + env: + RUSTFLAGS: --cfg loom + RUST_BACKTRACE: full + CARGO_TERM_COLOR: always + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + + - name: Install latest nextest release + uses: taiki-e/install-action@nextest + + - name: Loom Thread Test + run: | + cargo nextest run -p y-octo --lib + + miri: + name: miri code check + runs-on: ubuntu-latest + continue-on-error: true + env: + RUST_BACKTRACE: full + CARGO_TERM_COLOR: always + MIRIFLAGS: -Zmiri-backtrace=full -Zmiri-tree-borrows + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly-2023-08-19 + components: miri + - uses: Swatinem/rust-cache@v2 + + - 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 + + fuzzing: + name: fuzzing + runs-on: ubuntu-latest + continue-on-error: true + env: + RUSTFLAGS: -D warnings + CARGO_TERM_COLOR: always + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: nightly-2023-08-19 + - uses: Swatinem/rust-cache@v2 + + - name: fuzzing + working-directory: ./packages/y-octo + 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: ./packages/y-octo/fuzz/artifacts/**/* diff --git a/README.md b/README.md index e266f26..c3cbc2c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # Y-Octo -Y-Octo is a high-performance CRDT implementation compatible with [yjs](https://github.com/yjs/yjs). +[![codecov]](https://codecov.io/gh/toeverything/y-octo) -Y-Octo aims to provide a thread-safe, high-performance CRDT implementation on multiple platforms and offers binary compatibility and interoperability with [yjs](https://github.com/yjs/yjs). +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]. + +[codecov]: https://codecov.io/gh/toeverything/y-octo/graph/badge.svg?token=9AQY5Q1BYH +[yjs]: https://github.com/yjs/yjs diff --git a/packages/y-octo/fuzz/Cargo.toml b/packages/y-octo/fuzz/Cargo.toml index 81c21ab..6c1c7f6 100644 --- a/packages/y-octo/fuzz/Cargo.toml +++ b/packages/y-octo/fuzz/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "jwst-codec-fuzz" +name = "y-octo-fuzz" version = "0.0.0" publish = false edition = "2021" @@ -14,9 +14,9 @@ libfuzzer-sys = "0.4.6" lib0 = "0.16.5" yrs = "0.16.5" -jwst-codec-util = { path = "../../jwst-codec-util" } +y-octo-utils = { path = "../../y-octo-utils" } -[dependencies.jwst-codec] +[dependencies.y-octo] path = ".." # Prevent this from interfering with workspaces diff --git a/packages/y-octo/src/doc/common/somr.rs b/packages/y-octo/src/doc/common/somr.rs index 51b36a8..a1c2889 100644 --- a/packages/y-octo/src/doc/common/somr.rs +++ b/packages/y-octo/src/doc/common/somr.rs @@ -89,6 +89,7 @@ impl Somr { } } + #[allow(dead_code)] pub fn get_mut(&self) -> Option<&mut T> { if !self.is_owned() || self.dangling() { return None;