From 29668693a43bfd49248224cf18d488a91593ecca Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Fri, 4 Oct 2024 17:03:40 -0400 Subject: [PATCH 1/9] add debug log --- flake.nix | 3 +++ src/ffi.rs | 4 +++- tests/test/web.rs | 2 -- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index b708674..1a44cbe 100644 --- a/flake.nix +++ b/flake.nix @@ -50,6 +50,9 @@ cargo-audit chromedriver geckodriver + + nodejs + yarn-berry ] ++ lib.optionals isDarwin [ libiconv frameworks.CoreServices diff --git a/src/ffi.rs b/src/ffi.rs index 45be752..3c9eb36 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -98,10 +98,12 @@ pub async fn init_sqlite() { .expect("Serialization must be infallible for const struct"); let mem = Memory::new(&js_sys::Object::from(mem)) .expect("Wasm Memory could not be instantiated"); + let proxy_uri = wasm_bindgen::link_to!(module = "/src/js/sqlite3-opfs-async-proxy.js"); + tracing::debug!("proxy_uri={:?}", proxy_uri); let opts = serde_wasm_bindgen::to_value(&Opts { wasm_binary: WASM, wasm_memory: mem, - proxy_uri: wasm_bindgen::link_to!(module = "/src/js/sqlite3-opfs-async-proxy.js"), + proxy_uri, }) .expect("serialization must be infallible for const struct"); let opts = Object::from(opts); diff --git a/tests/test/web.rs b/tests/test/web.rs index b59fab6..f8cecc9 100755 --- a/tests/test/web.rs +++ b/tests/test/web.rs @@ -311,8 +311,6 @@ async fn can_find() { tracing::info!("{changed} rows changed"); let res: Option = dsl::books.find(1).first(&mut conn).optional().unwrap(); - tracing::debug!("res: {:?}", res); - tracing::debug!("FIND RES: {:?}", res); let res: Vec = diesel::sql_query("SELECT * FROM books where (id = 1)") .load::(&mut conn).unwrap(); From b993f89d329e172944aa9b73cf3b419cd913a21c Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Mon, 7 Oct 2024 13:38:38 -0400 Subject: [PATCH 2/9] add crate release workflow --- .github/workflows/release-plz.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/release-plz.yml diff --git a/.github/workflows/release-plz.yml b/.github/workflows/release-plz.yml new file mode 100644 index 0000000..5d1783c --- /dev/null +++ b/.github/workflows/release-plz.yml @@ -0,0 +1,25 @@ +name: Release +permissions: + pull-requests: write + contents: write +on: + push: + branches: + - main +jobs: + release-plz: + name: Release-plz + runs-on: warp-ubuntu-latest-x64-8x + concurrency: + group: release-plz-${{ github.ref }} + cancel-in-progress: false + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Run release-plz + uses: MarcoIeni/release-plz-action@v0.5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} From 74a4845c9394d32cd31424bcdac6838f624bfe3e Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Mon, 7 Oct 2024 16:29:32 -0400 Subject: [PATCH 3/9] automated releases --- .changelog.toml | 32 ++++++++++++++++++++++++++ .github/dependabot.yml | 7 ++++++ .github/workflows/lint-pr.yml | 18 +++++++++++++++ .github/workflows/release-plz.yml | 3 ++- .release-plz.toml | 2 ++ CHANGELOG.md | 0 README.md | 38 +++++++++++++++++++++++++------ 7 files changed, 92 insertions(+), 8 deletions(-) create mode 100644 .changelog.toml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/lint-pr.yml create mode 100644 .release-plz.toml create mode 100644 CHANGELOG.md diff --git a/.changelog.toml b/.changelog.toml new file mode 100644 index 0000000..1f543de --- /dev/null +++ b/.changelog.toml @@ -0,0 +1,32 @@ +[changelog] +body = """ + +## [{{ version | trim_start_matches(pat="v") }}]\ + {%- if release_link -%}\ + ({{ release_link }})\ + {% endif %} \ + - {{ timestamp | date(format="%Y-%m-%d") }} +{% for group, commits in commits | group_by(attribute="group") %} +### {{ group | upper_first }} + {% for commit in commits %} + {%- if commit.scope -%} + - *({{commit.scope}})* {% if commit.breaking %}[**breaking**] {% endif %}\ + {{ commit.message }}{{ self::username(commit=commit) }}\ + {%- if commit.links %} \ + ({% for link in commit.links %}[{{link.text}}]({{link.href}}) {% endfor -%})\ + {% endif %} + {% else -%} + - {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message }}{{ self::username(commit=commit) }} + {% endif -%} + {% endfor -%} +{% endfor %} +{%- if remote.contributors %} +### Contributors +{% for contributor in remote.contributors %} + * @{{ contributor.username }} +{%- endfor %} +{% endif -%} +{%- macro username(commit) -%} + {% if commit.remote.username %} (by @{{ commit.remote.username }}){% endif -%} +{% endmacro -%} +""" diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..7ee8cf8 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + # Check for updates every Monday + schedule: + interval: "weekly" diff --git a/.github/workflows/lint-pr.yml b/.github/workflows/lint-pr.yml new file mode 100644 index 0000000..def26c3 --- /dev/null +++ b/.github/workflows/lint-pr.yml @@ -0,0 +1,18 @@ +name: "Lint PR" +on: + pull_request_target: + types: + - opened + - edited + - synchronize + - reopened +permissions: + pull-requests: read +jobs: + main: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-plz.yml b/.github/workflows/release-plz.yml index 5d1783c..690a578 100644 --- a/.github/workflows/release-plz.yml +++ b/.github/workflows/release-plz.yml @@ -18,8 +18,9 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + token: ${{ secrets.RELEASE_PLZ_TOKEN }} - name: Run release-plz uses: MarcoIeni/release-plz-action@v0.5 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }} CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/.release-plz.toml b/.release-plz.toml new file mode 100644 index 0000000..08971b5 --- /dev/null +++ b/.release-plz.toml @@ -0,0 +1,2 @@ +[workspace] +changelog_config = "./.changelog.toml" diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index eedd3d0..b7aa4f5 100644 --- a/README.md +++ b/README.md @@ -65,32 +65,56 @@ async fn code_in_web_worker() -> Result> { look in `tests/web.rs` for working example! -## Development +## Contributing -### Install yarn dependencies +### Building + +#### Install yarn dependencies `yarn install` -### Build the SQLite/OPFS BUndle +#### Build the SQLite/OPFS BUndle `yarn run build` -### Build the rust code, and re-build `package.json` if it changed +#### Build the rust code, and re-build `package.json` if it changed `cargo build --target wasm32-unknown-unknown` -### Run Tests +#### Run Tests `wasm-pack test --safari --features unsafe-debug-query` navigate to `http://localhost:8000` to observe test output -### Run Tests (headless) +#### Run Tests (headless) `wasm-pack test --safari --headless` -### Setting up the project in VSCode +#### Setting up the project in VSCode rust-analyzer does not like crates with different targets in the same workspace. If you want this to work well with your LSP, open `diesel-wasm-sqlite` as it's own project in VSCode. + +### Opening a Pull Request + +PR Title should follow +[conventional commits format](https://www.conventionalcommits.org/en/v1.0.0/) + +In short, if should be one of: + +- `fix:` represents bug fixes, and results in a SemVer patch bump. +- `feat:` represents a new feature, and results in a SemVer minor bump. +- `!:` (e.g. feat!:): represents a **breaking change** (indicated by the + !) and results in a SemVer major bump. +- `doc:` documentation changes +- `perf:` changes related to performance +- `refactor:` a refactor +- `style:` +- `test:` + +You can add extra context to conventional commits by using parantheses, for +instance if a PR touched only database-related code, a PR title may be: + +- `feat(db): Add SQLCipher plaintext_header support to database connection` From a7034eccf1dd9e66429264ed00ec420f43490d7b Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Mon, 7 Oct 2024 16:30:44 -0400 Subject: [PATCH 4/9] modify runner --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 995d10a..1c552c9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: test: name: Test # running with macos since it contains the safari driver - runs-on: warp-macos-13-arm64-6x + runs-on: warp-ubuntu-latest-x64-16x steps: - name: Checkout uses: actions/checkout@v4 From 47e8cf224f196d9961c95530233d76df93251785 Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Mon, 7 Oct 2024 16:36:41 -0400 Subject: [PATCH 5/9] no colors in console --- tests/common/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 776ee60..0573f3f 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -8,7 +8,10 @@ static INIT: OnceCell<()> = OnceCell::const_new(); pub async fn init() { INIT.get_or_init(|| async { console::log_1(&"INIT".into()); - tracing_wasm::set_as_global_default(); + let config = tracing_wasm::WASMLayerConfigBuilder::default() + .set_console_config(tracing_wasm::ConsoleConfig::ReportWithoutConsoleColor) + .build(); + tracing_wasm::set_as_global_default_with_config(config); console_error_panic_hook::set_once(); diesel_wasm_sqlite::init_sqlite().await; }) From 26bd7963c0167b9e06294f1b938773f11f24b6c9 Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Mon, 7 Oct 2024 16:37:54 -0400 Subject: [PATCH 6/9] use ubuntu-latest instead of warp --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1c552c9..169bc8f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: test: name: Test # running with macos since it contains the safari driver - runs-on: warp-ubuntu-latest-x64-16x + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 From ffa8cfc1ff660bd68cd2173a3ac16a89315b14ac Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Mon, 7 Oct 2024 16:39:07 -0400 Subject: [PATCH 7/9] use macos --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 169bc8f..60afba9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: test: name: Test # running with macos since it contains the safari driver - runs-on: ubuntu-latest + runs-on: macos-latest steps: - name: Checkout uses: actions/checkout@v4 From b7aa0ddc2a9c30b36c24636abcdefef304786ec0 Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Mon, 7 Oct 2024 16:39:46 -0400 Subject: [PATCH 8/9] use unsafe debug query --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 60afba9..78c7df4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,6 +44,7 @@ jobs: with: workspaces: | . + - run: cargo build --tests --features unsafe-debug-query - run: wasm-pack test --headless --safari --features unsafe-debug-query working-directory: ./ - run: wasm-pack test --headless --chrome --features unsafe-debug-query From 752355962aceba1bda359ccbc0f6e054b931afd6 Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Mon, 7 Oct 2024 16:43:31 -0400 Subject: [PATCH 9/9] make sure to build wasm32 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 78c7df4..0c1afdb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,7 +44,7 @@ jobs: with: workspaces: | . - - run: cargo build --tests --features unsafe-debug-query + - run: cargo build --target wasm32-unknown-unknown --tests --features unsafe-debug-query - run: wasm-pack test --headless --safari --features unsafe-debug-query working-directory: ./ - run: wasm-pack test --headless --chrome --features unsafe-debug-query