From dc06bbe829f85bb63db41aa9c61feaf5489fab43 Mon Sep 17 00:00:00 2001 From: Art <4998038+Alorel@users.noreply.github.com> Date: Sat, 27 Jul 2024 13:40:34 +0100 Subject: [PATCH] refactor: Redesign API for `serde` support BREAKING CHANGE: API redesigned for serde & Stream support & msrv bumped to 1.75. See [MIGRATING/v0.6.0.md](https://github.com/Alorel/rust-indexed-db/blob/v0.6.0/MIGRATING/v0.6.0.md) for details. --- .github/actions/changelog/action.yml | 56 ++ .github/actions/prep-release/action.yml | 30 - .github/actions/release/action.yml | 33 - .github/workflows/_test.yml | 71 -- .github/workflows/inc/unit-test.yml | 59 ++ .github/workflows/release.yml | 120 +++- .github/workflows/test.yml | 122 +++- .gitignore | 1 + .idea/dictionaries/.gitignore | 2 + .idea/dictionaries/default_user.xml | 7 + .idea/indexed_db.iml | 6 +- .idea/runConfigurations/Sync_readme.xml | 17 - .../{Build.xml => build.xml} | 5 +- .idea/runConfigurations/build_tests.xml | 20 + .../runConfigurations/build_tests_default.xml | 20 + .../{Clippy.xml => clippy.xml} | 6 +- .../{Clippy__fix.xml => clippy__fix.xml} | 6 +- .idea/runConfigurations/{Doc.xml => doc.xml} | 10 +- .idea/runConfigurations/{Fmt.xml => fmt.xml} | 4 +- .idea/runConfigurations/test_all.xml | 17 + .idea/runConfigurations/test_all_chrome.xml | 17 + .idea/runConfigurations/test_all_firefox.xml | 17 + .idea/runConfigurations/test_default.xml | 17 + Cargo.lock | 660 ++++++++++++++++-- Cargo.toml | 173 +++-- README.md | 144 ++-- internal_macros/Cargo.toml | 18 + internal_macros/README.md | 2 + internal_macros/src/build_into_fut.rs | 66 ++ internal_macros/src/commons/fn_target.rs | 45 ++ internal_macros/src/commons/mod.rs | 3 + internal_macros/src/errdoc.rs | 70 ++ internal_macros/src/errdoc/namespace.rs | 206 ++++++ internal_macros/src/from_dom_exception.rs | 213 ++++++ internal_macros/src/generate_with.rs | 97 +++ internal_macros/src/generic_bounds.rs | 77 ++ internal_macros/src/lib.rs | 93 +++ internal_macros/src/poll_unpinned.rs | 55 ++ internal_macros/src/struct_name.rs | 42 ++ internal_macros/src/struct_name_debug.rs | 116 +++ src/build.rs | 62 ++ src/cursor.rs | 184 +++++ src/cursor/base_cursor.rs | 251 +++++++ src/cursor/cursor_sys.rs | 33 + src/cursor/key_cursor.rs | 159 +++++ src/cursor/stream.rs | 157 +++++ src/cursor/update.rs | 110 +++ src/database.rs | 181 +++++ src/database/db_sys.rs | 26 + src/database/store_builder.rs | 136 ++++ src/database/store_name.rs | 174 +++++ src/database/tx_builder.rs | 133 ++++ src/database/version_change_event.rs | 38 + src/database/version_change_listener.rs | 114 +++ src/date.rs | 67 ++ src/dom_string_iterator.rs | 51 -- src/error.rs | 71 ++ src/error/dom_exception.rs | 81 +++ src/error/js_error.rs | 64 ++ src/error/open_db.rs | 29 + src/error/serde.rs | 79 +++ src/error/serialisation.rs | 13 + src/error/simple_value.rs | 97 +++ src/error/unexpected_data.rs | 34 + src/factory.rs | 143 ++++ src/factory/db_version.rs | 71 ++ src/factory/list_dbs.rs | 83 +++ src/factory/req_builder.rs | 252 +++++++ src/future/array_map.rs | 62 ++ src/future/basic.rs | 66 ++ src/future/cursor.rs | 69 ++ src/future/cursor_next.rs | 69 ++ src/future/get_all.rs | 31 + src/future/list_dbs.rs | 13 + src/future/maybe_errored.rs | 44 ++ src/future/mod.rs | 31 + src/future/open_db.rs | 101 +++ src/future/open_db/listener.rs | 121 ++++ src/future/open_db/listeners.rs | 87 +++ src/future/request.rs | 72 ++ src/future/request/listeners.rs | 69 ++ src/future/request/untyped.rs | 78 +++ src/future/traits.rs | 32 + src/idb_cursor.rs | 362 ---------- src/idb_cursor/idb_cursor_with_value.rs | 65 -- src/idb_database.rs | 454 ------------ src/idb_database/idb_version_change_event.rs | 84 --- src/idb_index.rs | 36 - src/idb_key_path.rs | 118 ---- src/idb_object_store.rs | 326 --------- .../idb_object_store_parameters.rs | 51 -- src/idb_query_source.rs | 243 ------- src/idb_transaction.rs | 136 ---- src/idb_transaction/idb_transaction_future.rs | 29 - .../idb_transaction_listeners.rs | 107 --- src/idb_transaction/idb_transaction_result.rs | 34 - src/index.rs | 37 + src/index/index_builder.rs | 138 ++++ src/index/object_store_ext.rs | 52 ++ src/internal_utils.rs | 147 +--- src/internals.rs | 29 + src/iter/array_map.rs | 54 ++ src/iter/dom_string_list.rs | 43 ++ src/iter/get_all.rs | 43 ++ src/iter/list_dbs.rs | 13 + src/iter/mod.rs | 17 + src/key_path.rs | 177 +++++ src/key_range.rs | 141 ++++ src/lib.rs | 381 ++-------- src/object_store.rs | 162 +++++ src/object_store/add_put.rs | 340 +++++++++ src/object_store/delete.rs | 52 ++ src/prelude.rs | 20 +- src/primitive.rs | 25 + src/primitive/from_js.rs | 298 ++++++++ src/primitive/switch.rs | 127 ++++ src/primitive/try_to_js.rs | 165 +++++ src/query_source.rs | 359 ++++++++++ src/query_source/count.rs | 108 +++ src/query_source/cursor.rs | 354 ++++++++++ src/query_source/get.rs | 70 ++ src/query_source/get_all.rs | 346 +++++++++ src/query_source/get_key.rs | 72 ++ src/request/futures/count_future.rs | 29 - .../cursor/idb_cursor_advancement_future.rs | 30 - .../futures/cursor/idb_cursor_future.rs | 65 -- .../cursor/idb_cursor_with_value_future.rs | 32 - src/request/futures/cursor/mod.rs | 7 - .../futures/idb_open_db_request_future.rs | 26 - src/request/futures/idb_request_future.rs | 144 ---- src/request/futures/jscast_request_future.rs | 49 -- src/request/futures/map.rs | 36 - src/request/futures/mod.rs | 67 -- src/request/futures/optional_jsval_future.rs | 29 - src/request/futures/void_future.rs | 20 - src/request/idb_open_db_request_ref.rs | 132 ---- src/request/idb_request_ref.rs | 59 -- src/request/mod.rs | 68 -- src/request/open_db_request.rs | 41 -- src/request/request_like.rs | 16 - src/request/void_open_db_request.rs | 13 - src/request/void_request.rs | 12 - src/serde.rs | 35 + src/transaction.rs | 162 +++++ src/transaction/listeners.rs | 98 +++ src/transaction/options.rs | 108 +++ src/transaction/tx_sys.rs | 11 + src/typed_array.rs | 208 ++++++ tests/browser.rs | 6 + tests/dedicated_worker.rs | 5 + tests/shared_worker.rs | 5 + tests/tests/database/delete_and_list.rs | 48 ++ tests/tests/database/delete_obj_store.rs | 42 ++ tests/tests/database/mod.rs | 18 + tests/tests/database/obj_store_create.rs | 50 ++ tests/tests/database/open.rs | 62 ++ tests/tests/database/transaction.rs | 20 + tests/tests/database/versionchange.rs | 46 ++ tests/tests/date.rs | 16 + tests/tests/index/create.rs | 29 + tests/tests/index/mod.rs | 9 + tests/tests/index/query_source.rs | 190 +++++ tests/tests/index/query_source/cursor.rs | 412 +++++++++++ tests/tests/key_path.rs | 30 + tests/tests/mod.rs | 182 +++++ tests/tests/object_store/add_put.rs | 104 +++ tests/tests/object_store/clear.rs | 20 + tests/tests/object_store/delete.rs | 61 ++ tests/tests/object_store/mod.rs | 4 + tests/tests/object_store/query_source.rs | 168 +++++ .../tests/object_store/query_source/cursor.rs | 593 ++++++++++++++++ .../object_store/query_source/key_path.rs | 52 ++ tests/tests/primitive.rs | 120 ++++ tests/tests/transaction/commit_rollback.rs | 35 + tests/tests/transaction/mod.rs | 1 + tests/tests/utils/conditional_build.rs | 77 ++ tests/tests/utils/dummy_data.rs | 236 +++++++ tests/tests/utils/init.rs | 50 ++ tests/tests/utils/mod.rs | 17 + 179 files changed, 12822 insertions(+), 3779 deletions(-) create mode 100644 .github/actions/changelog/action.yml delete mode 100644 .github/actions/prep-release/action.yml delete mode 100644 .github/actions/release/action.yml delete mode 100644 .github/workflows/_test.yml create mode 100644 .github/workflows/inc/unit-test.yml create mode 100644 .idea/dictionaries/.gitignore create mode 100644 .idea/dictionaries/default_user.xml delete mode 100644 .idea/runConfigurations/Sync_readme.xml rename .idea/runConfigurations/{Build.xml => build.xml} (76%) create mode 100644 .idea/runConfigurations/build_tests.xml create mode 100644 .idea/runConfigurations/build_tests_default.xml rename .idea/runConfigurations/{Clippy.xml => clippy.xml} (81%) rename .idea/runConfigurations/{Clippy__fix.xml => clippy__fix.xml} (79%) rename .idea/runConfigurations/{Doc.xml => doc.xml} (83%) rename .idea/runConfigurations/{Fmt.xml => fmt.xml} (91%) create mode 100644 .idea/runConfigurations/test_all.xml create mode 100644 .idea/runConfigurations/test_all_chrome.xml create mode 100644 .idea/runConfigurations/test_all_firefox.xml create mode 100644 .idea/runConfigurations/test_default.xml create mode 100644 internal_macros/Cargo.toml create mode 100644 internal_macros/README.md create mode 100644 internal_macros/src/build_into_fut.rs create mode 100644 internal_macros/src/commons/fn_target.rs create mode 100644 internal_macros/src/commons/mod.rs create mode 100644 internal_macros/src/errdoc.rs create mode 100644 internal_macros/src/errdoc/namespace.rs create mode 100644 internal_macros/src/from_dom_exception.rs create mode 100644 internal_macros/src/generate_with.rs create mode 100644 internal_macros/src/generic_bounds.rs create mode 100644 internal_macros/src/lib.rs create mode 100644 internal_macros/src/poll_unpinned.rs create mode 100644 internal_macros/src/struct_name.rs create mode 100644 internal_macros/src/struct_name_debug.rs create mode 100644 src/build.rs create mode 100644 src/cursor.rs create mode 100644 src/cursor/base_cursor.rs create mode 100644 src/cursor/cursor_sys.rs create mode 100644 src/cursor/key_cursor.rs create mode 100644 src/cursor/stream.rs create mode 100644 src/cursor/update.rs create mode 100644 src/database.rs create mode 100644 src/database/db_sys.rs create mode 100644 src/database/store_builder.rs create mode 100644 src/database/store_name.rs create mode 100644 src/database/tx_builder.rs create mode 100644 src/database/version_change_event.rs create mode 100644 src/database/version_change_listener.rs create mode 100644 src/date.rs delete mode 100644 src/dom_string_iterator.rs create mode 100644 src/error.rs create mode 100644 src/error/dom_exception.rs create mode 100644 src/error/js_error.rs create mode 100644 src/error/open_db.rs create mode 100644 src/error/serde.rs create mode 100644 src/error/serialisation.rs create mode 100644 src/error/simple_value.rs create mode 100644 src/error/unexpected_data.rs create mode 100644 src/factory.rs create mode 100644 src/factory/db_version.rs create mode 100644 src/factory/list_dbs.rs create mode 100644 src/factory/req_builder.rs create mode 100644 src/future/array_map.rs create mode 100644 src/future/basic.rs create mode 100644 src/future/cursor.rs create mode 100644 src/future/cursor_next.rs create mode 100644 src/future/get_all.rs create mode 100644 src/future/list_dbs.rs create mode 100644 src/future/maybe_errored.rs create mode 100644 src/future/mod.rs create mode 100644 src/future/open_db.rs create mode 100644 src/future/open_db/listener.rs create mode 100644 src/future/open_db/listeners.rs create mode 100644 src/future/request.rs create mode 100644 src/future/request/listeners.rs create mode 100644 src/future/request/untyped.rs create mode 100644 src/future/traits.rs delete mode 100644 src/idb_cursor.rs delete mode 100644 src/idb_cursor/idb_cursor_with_value.rs delete mode 100644 src/idb_database.rs delete mode 100644 src/idb_database/idb_version_change_event.rs delete mode 100644 src/idb_index.rs delete mode 100644 src/idb_key_path.rs delete mode 100644 src/idb_object_store.rs delete mode 100644 src/idb_object_store/idb_object_store_parameters.rs delete mode 100644 src/idb_query_source.rs delete mode 100644 src/idb_transaction.rs delete mode 100644 src/idb_transaction/idb_transaction_future.rs delete mode 100644 src/idb_transaction/idb_transaction_listeners.rs delete mode 100644 src/idb_transaction/idb_transaction_result.rs create mode 100644 src/index.rs create mode 100644 src/index/index_builder.rs create mode 100644 src/index/object_store_ext.rs create mode 100644 src/internals.rs create mode 100644 src/iter/array_map.rs create mode 100644 src/iter/dom_string_list.rs create mode 100644 src/iter/get_all.rs create mode 100644 src/iter/list_dbs.rs create mode 100644 src/iter/mod.rs create mode 100644 src/key_path.rs create mode 100644 src/key_range.rs create mode 100644 src/object_store.rs create mode 100644 src/object_store/add_put.rs create mode 100644 src/object_store/delete.rs create mode 100644 src/primitive.rs create mode 100644 src/primitive/from_js.rs create mode 100644 src/primitive/switch.rs create mode 100644 src/primitive/try_to_js.rs create mode 100644 src/query_source.rs create mode 100644 src/query_source/count.rs create mode 100644 src/query_source/cursor.rs create mode 100644 src/query_source/get.rs create mode 100644 src/query_source/get_all.rs create mode 100644 src/query_source/get_key.rs delete mode 100644 src/request/futures/count_future.rs delete mode 100644 src/request/futures/cursor/idb_cursor_advancement_future.rs delete mode 100644 src/request/futures/cursor/idb_cursor_future.rs delete mode 100644 src/request/futures/cursor/idb_cursor_with_value_future.rs delete mode 100644 src/request/futures/cursor/mod.rs delete mode 100644 src/request/futures/idb_open_db_request_future.rs delete mode 100644 src/request/futures/idb_request_future.rs delete mode 100644 src/request/futures/jscast_request_future.rs delete mode 100644 src/request/futures/map.rs delete mode 100644 src/request/futures/mod.rs delete mode 100644 src/request/futures/optional_jsval_future.rs delete mode 100644 src/request/futures/void_future.rs delete mode 100644 src/request/idb_open_db_request_ref.rs delete mode 100644 src/request/idb_request_ref.rs delete mode 100644 src/request/mod.rs delete mode 100644 src/request/open_db_request.rs delete mode 100644 src/request/request_like.rs delete mode 100644 src/request/void_open_db_request.rs delete mode 100644 src/request/void_request.rs create mode 100644 src/serde.rs create mode 100644 src/transaction.rs create mode 100644 src/transaction/listeners.rs create mode 100644 src/transaction/options.rs create mode 100644 src/transaction/tx_sys.rs create mode 100644 src/typed_array.rs create mode 100644 tests/browser.rs create mode 100644 tests/dedicated_worker.rs create mode 100644 tests/shared_worker.rs create mode 100644 tests/tests/database/delete_and_list.rs create mode 100644 tests/tests/database/delete_obj_store.rs create mode 100644 tests/tests/database/mod.rs create mode 100644 tests/tests/database/obj_store_create.rs create mode 100644 tests/tests/database/open.rs create mode 100644 tests/tests/database/transaction.rs create mode 100644 tests/tests/database/versionchange.rs create mode 100644 tests/tests/date.rs create mode 100644 tests/tests/index/create.rs create mode 100644 tests/tests/index/mod.rs create mode 100644 tests/tests/index/query_source.rs create mode 100644 tests/tests/index/query_source/cursor.rs create mode 100644 tests/tests/key_path.rs create mode 100644 tests/tests/mod.rs create mode 100644 tests/tests/object_store/add_put.rs create mode 100644 tests/tests/object_store/clear.rs create mode 100644 tests/tests/object_store/delete.rs create mode 100644 tests/tests/object_store/mod.rs create mode 100644 tests/tests/object_store/query_source.rs create mode 100644 tests/tests/object_store/query_source/cursor.rs create mode 100644 tests/tests/object_store/query_source/key_path.rs create mode 100644 tests/tests/primitive.rs create mode 100644 tests/tests/transaction/commit_rollback.rs create mode 100644 tests/tests/transaction/mod.rs create mode 100644 tests/tests/utils/conditional_build.rs create mode 100644 tests/tests/utils/dummy_data.rs create mode 100644 tests/tests/utils/init.rs create mode 100644 tests/tests/utils/mod.rs diff --git a/.github/actions/changelog/action.yml b/.github/actions/changelog/action.yml new file mode 100644 index 0000000..0d27730 --- /dev/null +++ b/.github/actions/changelog/action.yml @@ -0,0 +1,56 @@ +name: Generate changelog +description: Generate the changelog +outputs: + release-type: + description: Release type + value: ${{ steps.log.outputs.release-type }} + version: + description: Next version + value: ${{ steps.log.outputs.next-version }} + issues-closed: + description: Issues closed + value: ${{ steps.log.outputs.issues-closed }} + changelog: + description: Changelog value + value: ${{ steps.log.outputs.changelog }} + should-release: + description: Should release + value: ${{ steps.log.outputs.should-release }} +runs: + using: composite + steps: + - name: Conditional args + id: args + if: ${{ startsWith(github.ref, 'refs/tags/') }} + shell: bash + run: > + echo "before=${{ github.ref_name }}" >> $GITHUB_OUTPUT && + echo "until=${{ github.ref_name }}" >> $GITHUB_OUTPUT + + - name: Get last tag + id: last-tag + uses: alorel-actions/semantic-release-lite/last-tag@v0 + with: + before: ${{ steps.args.outputs.before }} + + - name: Generate changelog + id: log + uses: alorel-actions/semantic-release-lite/generate-changelog@v0 + with: + last-tag: ${{ steps.last-tag.outputs.last-tag }} + from: ${{ steps.last-tag.outputs.last-tag }} + until: ${{ steps.args.outputs.until || github.sha }} + stay-at-zero: true + minor-types: | + feat: Features + rm: Removals + patch-types: | + fix: Bug Fixes + perf: Performance + chore: Maintenance + deps: Dependency updates + refactor: Refactors + docs: Documentation + trivial-types: | + ci: CI & Build + build: CI & Build diff --git a/.github/actions/prep-release/action.yml b/.github/actions/prep-release/action.yml deleted file mode 100644 index e232ed4..0000000 --- a/.github/actions/prep-release/action.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Prep release -description: Prepare the release -inputs: - release-type: - description: Release type - required: true - version: - description: Next version - required: true -outputs: - in-sync: - description: Sync check - value: ${{ steps.sync-check.outputs.in-sync }} -runs: - using: composite - steps: - - name: Git identity - uses: alorel-actions/git-ident@v1 - - name: Init toolchain - uses: alorel-actions/cargo/init@v1 - id: toolchain - with: - cache-prefix: release - - name: cargo-bump - uses: alorel-actions/cargo/bump@v1 - with: - release-type: ${{ inputs.release-type }} - - name: Sync check - id: sync-check - uses: alorel-actions/semantic-release-lite/sync-check@v0 diff --git a/.github/actions/release/action.yml b/.github/actions/release/action.yml deleted file mode 100644 index e09a911..0000000 --- a/.github/actions/release/action.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Release -description: Do the release -inputs: - version: - description: Version to release - required: true - changelog: - description: The changelog - required: true - issues-closed: - description: Issues we've closed - crates-io-token: - description: crates.io API token - required: true -runs: - using: composite - steps: - - uses: alorel-actions/cargo/release-git@v1 - with: - version: ${{ inputs.version }} - changelog: ${{ inputs.changelog }} - - - name: Publish crate - shell: bash - run: cargo publish --locked --token ${{ inputs.crates-io-token }} - - - name: Notify - if: ${{ inputs.issues-closed }} - uses: alorel-actions/semantic-release-lite/notify@v0 - with: - tag: ${{ inputs.version }} - issues: ${{ inputs.issues-closed }} - allow-out-of-sync: true diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml deleted file mode 100644 index a5c4677..0000000 --- a/.github/workflows/_test.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Test -on: - workflow_call: {} - -permissions: - contents: read - -env: - CARGO_INCREMENTAL: 0 - RUSTFLAGS: --deny warnings - -jobs: - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Init toolchain - uses: alorel-actions/cargo/init@v1 - id: toolchain - with: - components: rustfmt,clippy - cache-prefix: lint - local: true - - - name: Fmt - run: cargo fmt --check - - - name: Clippy - run: cargo clippy --workspace --tests - - - name: Doc - run: cargo doc --workspace --no-deps - - test: - name: Test on ${{matrix.toolchain}} - runs-on: ubuntu-latest - strategy: - matrix: - toolchain: - - nightly-2024-07-25 - - stable - - 1.74.0 - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Init toolchain - uses: alorel-actions/cargo/init@v1 - with: - toolchain: ${{matrix.toolchain}} - cache-prefix: test - local: true - - - name: Install wasm-pack - uses: alorel-actions/cargo-global-dep@v1 - with: - name: wasm-pack - version: 0.13.0 - - - name: Test (no features) - run: wasm-pack test --headless --firefox --chrome --locked --no-default-features - - - name: Test (default features) - run: wasm-pack test --headless --firefox --chrome --locked - - - name: Test (nightly) - run: wasm-pack test --headless --firefox --chrome --locked --all-features - if: ${{startsWith(matrix.toolchain, 'nightly')}} diff --git a/.github/workflows/inc/unit-test.yml b/.github/workflows/inc/unit-test.yml new file mode 100644 index 0000000..d0b5ec1 --- /dev/null +++ b/.github/workflows/inc/unit-test.yml @@ -0,0 +1,59 @@ +name: Unit test +on: + workflow_call: + inputs: + toolchain: + description: Rust version + default: stable + type: string + os: + description: OS to run on + default: ubuntu-latest + type: string + flags: + description: cli args + type: string + +permissions: + contents: read + +env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: --deny warnings + +jobs: + test: + name: Test with ${{ inputs.flags || 'no flags' }} on ${{ inputs.os }}, ${{ inputs.toolchain }} + runs-on: ${{ inputs.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Init toolchain + uses: alorel-actions/cargo/init@v1 + with: + toolchain: ${{ inputs.toolchain }} + cache-prefix: test + cache-suffix: ${{inputs.flags}} + local: true + + - name: Build + run: cargo build --locked ${{ inputs.flags }} + + - name: Install wasm-pack + uses: alorel-actions/cargo-global-dep@v1 + with: + name: wasm-pack + version: 0.13.0 + + - name: Test (Chrome) + if: ${{ runner.os != 'macOS' }} + run: wasm-pack test --chrome --headless --locked ${{ inputs.flags }} + + - name: Test (Firefox) + if: ${{ runner.os != 'macOS' }} + run: wasm-pack test --firefox --headless --locked ${{ inputs.flags }} + + - name: Test (Safari) + if: ${{ runner.os == 'macOS' }} + run: wasm-pack test --safari --headless --locked ${{ inputs.flags }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 08e301e..a673e3b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,7 @@ name: Release concurrency: release on: - workflow_dispatch: {} + workflow_dispatch: { } permissions: contents: read @@ -13,14 +13,38 @@ env: jobs: test: name: Test - uses: ./.github/workflows/_test.yml + uses: ./.github/workflows/test.yml + with: + is-workflow-call: true - release: - name: Release + prepare: + name: Set up + runs-on: ubuntu-latest + outputs: + release-type: ${{ steps.changelog.outputs.release-type }} + version: ${{ steps.changelog.outputs.version }} + issues-closed: ${{ steps.changelog.outputs.issues-closed }} + changelog: ${{ steps.changelog.outputs.changelog }} + should-release: ${{ steps.changelog.outputs.should-release }} + steps: + - uses: actions/checkout@v4 + name: Checkout + with: + fetch-depth: 0 + fetch-tags: true + + - name: Generate changelog + id: changelog + uses: ./.github/actions/changelog + + git: + name: Git release + runs-on: ubuntu-latest needs: - test - runs-on: ubuntu-latest - environment: crates-io + - prepare + if: ${{ needs.prepare.outputs.should-release }} + environment: github permissions: contents: write steps: @@ -31,37 +55,63 @@ jobs: fetch-tags: true token: ${{ secrets.GH_TOKEN }} - - name: Parse - id: parse - uses: alorel-actions/semantic-release-lite@v0 + - name: Git identity + uses: alorel-actions/git-ident@v1 + + - name: Init toolchain + uses: alorel-actions/cargo/init@v1 + with: + cache-prefix: release + + - name: cargo-bump + uses: alorel-actions/cargo/bump@v1 + with: + release-type: ${{ needs.prepare.outputs.release-type }} + + - name: Git release + uses: alorel-actions/cargo/release-git@v1 with: - stay-at-zero: true - minor-types: | - feat: Features - patch-types: | - fix: Bug Fixes - trivial-types: | - chore: Maintenance - deps: Dependency updates - ci: CI & Build - build: CI & Build - refactor: Refactors - docs: Documentation - perf: Performance + version: ${{ needs.prepare.outputs.version }} + changelog: ${{ needs.prepare.outputs.changelog }} - - name: Prep release - if: ${{ steps.parse.outputs.should-release }} - id: prep - uses: ./.github/actions/prep-release + release: + name: Crate release + needs: + - git + if: ${{ needs.prepare.outputs.should-release }} + runs-on: ubuntu-latest + environment: crates-io + steps: + - uses: actions/checkout@v4 + name: Checkout with: - release-type: ${{ steps.parse.outputs.release-type }} - version: ${{ steps.parse.outputs.next-version }} + fetch-tags: true + ref: ${{ needs.prepare.outputs.version }} - - name: Release - if: ${{ steps.prep.outputs.in-sync }} - uses: ./.github/actions/release + - name: Init toolchain + uses: alorel-actions/cargo/init@v1 + with: + cache-prefix: release + + - name: Publish crate + run: cargo publish --locked --token ${{ secrets.CRATES_IO_TOKEN }} + + notify: + name: Notify closed issues + needs: + - release + - prepare + if: ${{ needs.prepare.outputs.should-release && needs.prepare.outputs.issues-closed }} + runs-on: ubuntu-latest + environment: github + permissions: + contents: write + steps: + - name: Notify + if: ${{ needs.prepare.outputs.issues-closed }} + uses: alorel-actions/semantic-release-lite/notify@v0 with: - version: ${{ steps.parse.outputs.next-version }} - changelog: ${{ steps.parse.outputs.changelog }} - issues-closed: ${{ steps.parse.outputs.issues-closed }} - crates-io-token: ${{ secrets.CRATES_IO_TOKEN }} + tag: ${{ needs.prepare.outputs.version }} + issues: ${{ needs.prepare.outputs.issues-closed }} + allow-out-of-sync: true + gh-token: ${{ secrets.GH_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 943b239..fd735f3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,10 @@ name: Test on: + workflow_call: + inputs: + is-workflow-call: + type: boolean + required: true push: branches: - master @@ -28,7 +33,118 @@ env: CARGO_INCREMENTAL: 0 RUSTFLAGS: --deny warnings +concurrency: + group: test-${{ github.ref }} + cancel-in-progress: ${{ !inputs.is-workflow-call }} + jobs: - test: - name: Test - uses: ./.github/workflows/_test.yml + doc: + name: Doc build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Init toolchain + uses: alorel-actions/cargo/init@v1 + id: toolchain + with: + toolchain: nightly-2024-09-29 + cache-prefix: doc + local: true + + - name: Doc + run: cargo doc --workspace --all-features --no-deps + env: + RUSTDOCFLAGS: --cfg doc_cfg --deny warnings + + - name: Cleanup + run: rm -rf target/doc + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Init toolchain + uses: alorel-actions/cargo/init@v1 + id: toolchain + with: + components: rustfmt,clippy + cache-prefix: lint + local: true + + - name: Fmt + run: cargo fmt --check + + - name: Clippy + run: cargo clippy --workspace --tests --all-features --locked --no-deps + + environment: + name: Environment test for ${{ matrix.toolchain }} on ${{ matrix.os }} + uses: ./.github/workflows/inc/unit-test.yml + with: + toolchain: ${{ matrix.toolchain }} + os: ${{ matrix.os }} + flags: --all-features + strategy: + fail-fast: false + matrix: + include: + - toolchain: nightly-2024-09-29 + os: ubuntu-latest + - toolchain: 1.75.0 + os: ubuntu-latest + - toolchain: stable + os: ubuntu-latest + - toolchain: stable + os: macos-latest + + feature: + name: Feature test for ${{ matrix.flags || 'no flags' }} + uses: ./.github/workflows/inc/unit-test.yml + with: + flags: ${{ matrix.flags }} + strategy: + fail-fast: false + matrix: + flags: + - '' + - --features cursors + - --features dates + - --features indices + - --features list-databases + - --features serde + - --features "cursors streams" + - --features switch + - --features typed-arrays + - --features "typed-arrays serde" + - --features "cursors streams serde" + - --features "indices serde" + - --features "indices cursors" + - --features "indices cursors serde" + - --features "indices cursors streams" + - --features "indices cursors streams serde" + - --features "dates serde" + - --features "cursors serde" + + done: + name: All tests + runs-on: ubuntu-latest + needs: + - doc + - lint + - feature + - environment + steps: + - uses: actions/checkout@v4 + name: Checkout + with: + fetch-depth: 0 + fetch-tags: true + + - name: Generate changelog + id: changelog + uses: ./.github/actions/changelog diff --git a/.gitignore b/.gitignore index 494026c..1037032 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.log /target /tmp.js +/examples/adhoc.rs diff --git a/.idea/dictionaries/.gitignore b/.idea/dictionaries/.gitignore new file mode 100644 index 0000000..9546a67 --- /dev/null +++ b/.idea/dictionaries/.gitignore @@ -0,0 +1,2 @@ +/*.xml +!/default_user.xml diff --git a/.idea/dictionaries/default_user.xml b/.idea/dictionaries/default_user.xml new file mode 100644 index 0000000..c8135ce --- /dev/null +++ b/.idea/dictionaries/default_user.xml @@ -0,0 +1,7 @@ + + + + bindgen + + + \ No newline at end of file diff --git a/.idea/indexed_db.iml b/.idea/indexed_db.iml index d990dbf..9a0ec41 100644 --- a/.idea/indexed_db.iml +++ b/.idea/indexed_db.iml @@ -2,7 +2,11 @@ + + + + @@ -11,4 +15,4 @@ - + \ No newline at end of file diff --git a/.idea/runConfigurations/Sync_readme.xml b/.idea/runConfigurations/Sync_readme.xml deleted file mode 100644 index 5bef6ce..0000000 --- a/.idea/runConfigurations/Sync_readme.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/Build.xml b/.idea/runConfigurations/build.xml similarity index 76% rename from .idea/runConfigurations/Build.xml rename to .idea/runConfigurations/build.xml index c20fe0a..758cb33 100644 --- a/.idea/runConfigurations/Build.xml +++ b/.idea/runConfigurations/build.xml @@ -1,6 +1,7 @@ - -