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 @@ - -