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 new file mode 100644 index 0000000..690a578 --- /dev/null +++ b/.github/workflows/release-plz.yml @@ -0,0 +1,26 @@ +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 + token: ${{ secrets.RELEASE_PLZ_TOKEN }} + - name: Run release-plz + uses: MarcoIeni/release-plz-action@v0.5 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 995d10a..0c1afdb 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: macos-latest steps: - name: Checkout uses: actions/checkout@v4 @@ -44,6 +44,7 @@ jobs: with: workspaces: | . + - 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 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` 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/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; }) 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();