Skip to content

Commit

Permalink
fix justfile, adjust getrandom deps for ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekleog committed Feb 10, 2025
1 parent 5986774 commit 180f0d0
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 49 deletions.
106 changes: 69 additions & 37 deletions Justfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
# export RUST_BACKTRACE := "short"

macro_backtrace := 'RUSTC_BOOTSTRAP=1 RUSTFLAGS="-Zmacro-backtrace"'
export RUSTC_BOOTSTRAP := "1"
export RUSTFLAGS := "-Z macro-backtrace"
export SQLX_OFFLINE := "true"

flags_for_js := "RUSTFLAGS='-Z macro-backtrace --cfg getrandom_backend=\"wasm_js\"'"

all *ARGS: fmt (test ARGS) clippy udeps doc

run-example-basic-server *ARGS:
createdb basic-crdb || true
sqlx migrate run --source crdb-postgres/migrations --database-url "postgres:///basic-crdb"
CARGO_TARGET_DIR="target/host" {{macro_backtrace}} watchexec -r -e rs,toml -E RUST_LOG="trace,tokio_tungstenite=debug,tungstenite=debug" --workdir examples/basic cargo run -p basic-server -- {{ARGS}}
sqlx migrate run \
--source crdb-postgres/migrations \
--database-url "postgres:///basic-crdb"
CARGO_TARGET_DIR="target/host" \
watchexec -r -e rs,toml \
-E RUST_LOG="trace,tokio_tungstenite=debug,tungstenite=debug" \
--workdir examples/basic \
cargo run -p basic-server -- {{ARGS}}

serve-example-basic-client-js *ARGS:
CARGO_TARGET_DIR="../target/wasm" {{macro_backtrace}} watchexec -r -e rs,toml,html --workdir examples/basic/client-js trunk serve
CARGO_TARGET_DIR="../target/wasm" \
watchexec -r -e rs,toml,html \
--workdir examples/basic/client-js \
trunk serve

fmt:
cargo fmt
Expand All @@ -21,48 +34,62 @@ test *ARGS: (test-crate ARGS) (test-example-basic ARGS)
test-standalone *ARGS: (test-crate-native "--exclude" "crdb-postgres" ARGS) (test-example-basic ARGS)

clippy:
CARGO_TARGET_DIR="target/clippy" SQLX_OFFLINE="true" cargo clippy --all-features -- -D warnings
CARGO_TARGET_DIR="target/clippy" \
cargo clippy --all-features -- -D warnings

udeps:
RUSTC_BOOTSTRAP=1 \
CARGO_TARGET_DIR="target/udeps" \
SQLX_OFFLINE="true" \
cargo udeps --workspace --all-features
RUSTC_BOOTSTRAP=1 \
cargo udeps --workspace --all-features
CARGO_TARGET_DIR="target/udeps" \
SQLX_OFFLINE="true" \
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' \
cargo udeps --workspace \
--exclude crdb-postgres --exclude crdb-server --exclude crdb-sqlite \
--target wasm32-unknown-unknown
{{flags_for_js}} \
cargo udeps --workspace \
--exclude crdb-postgres \
--exclude crdb-server \
--exclude crdb-sqlite \
--target wasm32-unknown-unknown

udeps-full:
RUSTC_BOOTSTRAP=1 \
CARGO_TARGET_DIR="target/udeps" \
SQLX_OFFLINE="true" \
cargo hack udeps --each-feature
RUSTC_BOOTSTRAP=1 \
cargo hack udeps --each-feature

CARGO_TARGET_DIR="target/udeps" \
cargo hack udeps --tests --each-feature

CARGO_TARGET_DIR="target/udeps" \
SQLX_OFFLINE="true" \
cargo hack udeps --tests --each-feature
RUSTC_BOOTSTRAP=1 \
{{flags_for_js}} \
cargo hack udeps --each-feature \
--workspace \
--exclude crdb-postgres \
--exclude crdb-server \
--exclude crdb-sqlite \
--exclude-features server,sqlx-postgres,sqlx-sqlite,_tests \
--target wasm32-unknown-unknown

CARGO_TARGET_DIR="target/udeps" \
SQLX_OFFLINE="true" \
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' \
cargo udeps --workspace \
--exclude crdb-postgres --exclude crdb-server --exclude crdb-sqlite \
--target wasm32-unknown-unknown
{{flags_for_js}} \
cargo hack udeps --tests --each-feature \
--workspace \
--exclude crdb-postgres \
--exclude crdb-server \
--exclude crdb-sqlite \
--exclude-features server,sqlx-postgres,sqlx-sqlite \
--target wasm32-unknown-unknown

doc:
CARGO_TARGET_DIR="target/doc" SQLX_OFFLINE="true" cargo doc --all-features --workspace
CARGO_TARGET_DIR="target/doc" \
cargo doc --all-features --workspace

make-test-db:
dropdb crdb-test || true
createdb crdb-test
sqlx migrate run --source crdb-postgres/migrations --database-url "postgres:///crdb-test"
sqlx migrate run \
--source crdb-postgres/migrations \
--database-url "postgres:///crdb-test"

rebuild-offline-queries: make-test-db
cargo sqlx prepare --database-url "postgres:///crdb-test" -- --all-features --tests
cargo sqlx prepare \
--database-url "postgres:///crdb-test" -- \
--all-features --tests

list-todo-types:
rg 'TODO\(' | grep -v Justfile | sed 's/^.*TODO(//;s/).*$//' | sort | uniq -c || true
Expand All @@ -76,10 +103,10 @@ clean:
test-crate *ARGS: (test-crate-native ARGS) (test-crate-wasm32 ARGS)

test-crate-native *ARGS:
SQLX_OFFLINE="true" cargo nextest run --workspace --all-features {{ARGS}}
cargo nextest run --workspace --all-features {{ARGS}}

test-crate-wasm32 *ARGS:
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' \
{{flags_for_js}} \
cargo test -p crdb-indexed-db \
--features _tests \
--target wasm32-unknown-unknown \
Expand All @@ -90,14 +117,19 @@ test-example-basic *ARGS: build-example-basic-client (test-example-basic-host AR
build-example-basic-client:
cd examples/basic && \
CARGO_TARGET_DIR="target/wasm" \
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' \
{{macro_backtrace}} \
{{flags_for_js}} \
cargo build \
-p basic-client-js \
--target wasm32-unknown-unknown

test-example-basic-host *ARGS:
cd examples/basic && CARGO_TARGET_DIR="target/host" {{macro_backtrace}} cargo nextest run -p basic-api -p basic-server -p basic-client-native --no-tests=pass {{ARGS}}
cd examples/basic && \
CARGO_TARGET_DIR="target/host" \
cargo nextest run \
--workspace \
--exclude basic-client-js \
--no-tests=pass \
{{ARGS}}

fuzz-pg-simple ARGS='':
cargo bolero test \
Expand All @@ -110,7 +142,7 @@ fuzz-idb-simple ARGS='':
# TODO(blocked): remove path override, when https://github.com/rustwasm/wasm-bindgen/pull/3800 lands?
PATH="../wasm-bindgen/target/debug:$PATH" \
WASM_BINDGEN_TEST_TIMEOUT=86400 \
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' \
{{flags_for_js}} \
cargo test \
-p crdb-indexed-db \
--target wasm32-unknown-unknown \
Expand All @@ -131,7 +163,7 @@ fuzz-idb-perms ARGS='':
# TODO(blocked): remove path override, when https://github.com/rustwasm/wasm-bindgen/pull/3800 lands?
PATH="../wasm-bindgen/target/debug:$PATH" \
WASM_BINDGEN_TEST_TIMEOUT=86400 \
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' \
{{flags_for_js}} \
cargo test \
-p crdb-indexed-db \
--target wasm32-unknown-unknown \
Expand Down Expand Up @@ -166,7 +198,7 @@ fuzz-idb-full ARGS='':
# TODO(blocked): remove path override, when https://github.com/rustwasm/wasm-bindgen/pull/3800 lands?
PATH="../wasm-bindgen/target/debug:$PATH" \
WASM_BINDGEN_TEST_TIMEOUT=86400 \
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' \
{{flags_for_js}} \
cargo test \
-p crdb-indexed-db \
--target wasm32-unknown-unknown \
Expand Down
1 change: 1 addition & 0 deletions crdb-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ anyhow.workspace = true
async-stream.workspace = true
educe.workspace = true
futures.workspace = true
getrandom.workspace = true
serde_json.workspace = true
tokio.workspace = true
tokio-util.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crdb-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
[features]
arbitrary = ["dep:arbitrary", "arbitrary-json", "rust_decimal/rust-fuzz"]
indexed-db = ["dep:indexed-db", "serde-wasm-bindgen", "web-sys"]
server = ["axum", "getrandom", "rand", "sqlx-postgres"]
server = ["axum", "rand", "sqlx-postgres"]
sqlx-postgres = ["sqlx", "sqlx/postgres", "sqlx/uuid", "uuid"]
sqlx-sqlite = ["sqlx", "sqlx/sqlite", "sqlx/uuid", "uuid"]
uuid = ["dep:uuid"]
Expand All @@ -16,6 +16,7 @@ anyhow.workspace = true
bitflags.workspace = true
deepsize.workspace = true
educe.workspace = true
getrandom.workspace = true
icu_casemap.workspace = true
icu_normalizer.workspace = true
icu_properties.workspace = true
Expand All @@ -35,7 +36,6 @@ writeable.workspace = true
arbitrary = { workspace = true, optional = true }
arbitrary-json = { workspace = true, optional = true }
axum = { workspace = true, optional = true }
getrandom = { workspace = true, optional = true }
indexed-db = { workspace = true, optional = true }
rand = { workspace = true, optional = true }
serde-wasm-bindgen = { workspace = true, optional = true }
Expand Down
8 changes: 1 addition & 7 deletions crdb-helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@ version = "0.1.0"
edition = "2021"

[features]
js = [
"crdb-core/indexed-db",
"getrandom-0-2/js",
"serde-wasm-bindgen",
"wasm-bindgen",
]
js = ["crdb-core/indexed-db", "serde-wasm-bindgen", "wasm-bindgen"]

[dependencies]
crdb-core.workspace = true

anyhow.workspace = true
getrandom-0-2.workspace = true
serde_json.workspace = true

serde-wasm-bindgen = { workspace = true, optional = true }
Expand Down
2 changes: 2 additions & 0 deletions crdb-indexed-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ _tests = [
"console_error_panic_hook",
"crdb-test-utils",
"getrandom",
"getrandom-0-2/js",
"rand",
"rand-0-8",
"tracing-wasm",
Expand Down Expand Up @@ -39,6 +40,7 @@ arbitrary = { workspace = true, optional = true }
bolero = { workspace = true, optional = true }
console_error_panic_hook = { workspace = true, optional = true }
getrandom = { workspace = true, optional = true }
getrandom-0-2 = { workspace = true, optional = true }
rand = { workspace = true, optional = true }
rand-0-8 = { workspace = true, optional = true }
tracing-wasm = { workspace = true, optional = true }
Expand Down
1 change: 1 addition & 0 deletions crdb-postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ crdb-helpers.workspace = true

anyhow.workspace = true
futures.workspace = true
getrandom.workspace = true
lockable.workspace = true
reord.workspace = true
serde_json.workspace = true
Expand Down
1 change: 1 addition & 0 deletions crdb-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ bytes.workspace = true
chrono.workspace = true
cron.workspace = true
futures.workspace = true
getrandom.workspace = true
serde.workspace = true
serde_json.workspace = true
sqlx.workspace = true
Expand Down
1 change: 1 addition & 0 deletions crdb-sqlite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
crdb-core = { workspace = true, features = ["sqlx-sqlite"] }

anyhow.workspace = true
getrandom.workspace = true
serde_json.workspace = true
sqlx = { workspace = true, features = ["sqlite", "uuid"] }
ulid.workspace = true
Expand Down
1 change: 1 addition & 0 deletions crdb-test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ arbitrary.workspace = true
deepsize.workspace = true
educe.workspace = true
futures.workspace = true
getrandom.workspace = true
paste.workspace = true
rust_decimal.workspace = true
serde.workspace = true
Expand Down
3 changes: 0 additions & 3 deletions crdb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,3 @@ crdb-macros.workspace = true
crdb-client = { workspace = true, optional = true }
crdb-indexed-db = { workspace = true, optional = true }
crdb-server = { workspace = true, optional = true }

[dev-dependencies]
getrandom-0-2 = { workspace = true, features = ["js"] }
1 change: 1 addition & 0 deletions examples/basic/client-js/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ chrono = "0.4.34"
console_error_panic_hook = "0.1.7"
crdb = { path = "../../../crdb", features = ["client", "indexed-db"] }
futures = "0.3.30"
getrandom = { version = "0.3.1", features = ["wasm_js"] }
gloo-net = "0.5.0"
serde_json = "1.0"
tracing = "0.1.40"
Expand Down

0 comments on commit 180f0d0

Please sign in to comment.