Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add automated releases #2

Merged
merged 9 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .changelog.toml
Original file line number Diff line number Diff line change
@@ -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 -%}
"""
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
# Check for updates every Monday
schedule:
interval: "weekly"
18 changes: 18 additions & 0 deletions .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -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 }}
26 changes: 26 additions & 0 deletions .github/workflows/release-plz.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .release-plz.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[workspace]
changelog_config = "./.changelog.toml"
Empty file added CHANGELOG.md
Empty file.
38 changes: 31 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,32 +65,56 @@ async fn code_in_web_worker() -> Result<i32, diesel::QueryResult<usize>> {

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.
- `<prefix>!:` (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`
3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
cargo-audit
chromedriver
geckodriver

nodejs
yarn-berry
] ++ lib.optionals isDarwin [
libiconv
frameworks.CoreServices
Expand Down
4 changes: 3 additions & 1 deletion src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
})
Expand Down
2 changes: 0 additions & 2 deletions tests/test/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,6 @@ async fn can_find() {
tracing::info!("{changed} rows changed");

let res: Option<StoredBook> = dsl::books.find(1).first(&mut conn).optional().unwrap();
tracing::debug!("res: {:?}", res);
tracing::debug!("FIND RES: {:?}", res);

let res: Vec<StoredBook> = diesel::sql_query("SELECT * FROM books where (id = 1)")
.load::<StoredBook>(&mut conn).unwrap();
Expand Down
Loading