Skip to content

Commit

Permalink
Make lemmy_api_common wasm-compatible (#3587)
Browse files Browse the repository at this point in the history
* Fixing lemmy_api_common optionals

* Adding taplo for .toml files.

* Versioning taplo in woodpecker.

* Addressing PR comments.
  • Loading branch information
dessalines authored Jul 14, 2023
1 parent 39f28c1 commit 164f4b9
Show file tree
Hide file tree
Showing 12 changed files with 155 additions and 76 deletions.
8 changes: 4 additions & 4 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tab_spaces = 2
edition="2021"
imports_layout="HorizontalVertical"
imports_granularity="Crate"
group_imports="One"
edition = "2021"
imports_layout = "HorizontalVertical"
imports_granularity = "Crate"
group_imports = "One"
12 changes: 12 additions & 0 deletions .woodpecker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ pipeline:
commands:
- prettier -c . '!**/volumes' '!**/dist' '!target' '!**/translations'

taplo_check:
image: tamasfe/taplo:0.8.1
commands:
- taplo format --check

# use minimum supported rust version for most steps
cargo_fmt:
image: *muslrust_image
Expand Down Expand Up @@ -87,6 +92,13 @@ pipeline:
- "! cargo tree -p lemmy_api_common --no-default-features -i diesel"
# when:
# platform: linux/amd64
lemmy_api_common_works_with_wasm:
image: *muslrust_image
environment:
CARGO_HOME: .cargo
commands:
- "rustup target add wasm32-unknown-unknown"
- "cargo check --target wasm32-unknown-unknown -p lemmy_api_common"

check_defaults_hjson_updated:
image: *muslrust_image
Expand Down
36 changes: 10 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 32 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,29 @@ debug = 0

[features]
embed-pictrs = ["pict-rs"]
console = ["console-subscriber", "opentelemetry", "opentelemetry-otlp", "tracing-opentelemetry", "reqwest-tracing/opentelemetry_0_16"]
console = [
"console-subscriber",
"opentelemetry",
"opentelemetry-otlp",
"tracing-opentelemetry",
"reqwest-tracing/opentelemetry_0_16",
]
json-log = ["tracing-subscriber/json"]
prometheus-metrics = ["prometheus", "actix-web-prom"]
default = []

[workspace]
members = [
"crates/api",
"crates/api_crud",
"crates/api_common",
"crates/apub",
"crates/utils",
"crates/db_schema",
"crates/db_views",
"crates/db_views_actor",
"crates/db_views_actor",
"crates/routes"
"crates/api",
"crates/api_crud",
"crates/api_common",
"crates/apub",
"crates/utils",
"crates/db_schema",
"crates/db_views",
"crates/db_views_actor",
"crates/db_views_actor",
"crates/routes",
]

[workspace.dependencies]
Expand All @@ -61,13 +67,21 @@ lemmy_routes = { version = "=0.18.1", path = "./crates/routes" }
lemmy_db_views = { version = "=0.18.1", path = "./crates/db_views" }
lemmy_db_views_actor = { version = "=0.18.1", path = "./crates/db_views_actor" }
lemmy_db_views_moderator = { version = "=0.18.1", path = "./crates/db_views_moderator" }
activitypub_federation = { version = "0.4.5", default-features = false, features = ["actix-web"] }
activitypub_federation = { version = "0.4.5", default-features = false, features = [
"actix-web",
] }
diesel = "2.1.0"
diesel_migrations = "2.1.0"
diesel-async = "0.3.1"
serde = { version = "1.0.167", features = ["derive"] }
serde_with = "3.0.0"
actix-web = { version = "4.3.1", default-features = false, features = ["macros", "rustls", "compress-brotli", "compress-gzip", "compress-zstd"] }
actix-web = { version = "4.3.1", default-features = false, features = [
"macros",
"rustls",
"compress-brotli",
"compress-gzip",
"compress-zstd",
] }
tracing = "0.1.37"
tracing-actix-web = { version = "0.7.5", default-features = false }
tracing-error = "0.2.0"
Expand All @@ -87,7 +101,9 @@ base64 = "0.21.2"
uuid = { version = "1.4.0", features = ["serde", "v4"] }
async-trait = "0.1.71"
captcha = "0.0.9"
anyhow = { version = "1.0.71", features = ["backtrace"] } # backtrace is on by default on nightly, but not stable rust
anyhow = { version = "1.0.71", features = [
"backtrace",
] } # backtrace is on by default on nightly, but not stable rust
diesel_ltree = "0.3.0"
typed-builder = "0.15.0"
serial_test = "2.0.0"
Expand All @@ -96,7 +112,7 @@ sha2 = "0.10.7"
regex = "1.9.0"
once_cell = "1.18.0"
diesel-derive-newtype = "2.1.0"
diesel-derive-enum = {version = "2.1.0", features = ["postgres"] }
diesel-derive-enum = { version = "2.1.0", features = ["postgres"] }
strum = "0.25.0"
strum_macros = "0.25.1"
itertools = "0.11.0"
Expand All @@ -108,7 +124,7 @@ rand = "0.8.5"
opentelemetry = { version = "0.19.0", features = ["rt-tokio"] }
tracing-opentelemetry = { version = "0.19.0" }
ts-rs = { version = "6.2", features = ["serde-compat", "chrono-impl"] }
rustls = { version ="0.21.3", features = ["dangerous_configuration"]}
rustls = { version = "0.21.3", features = ["dangerous_configuration"] }
futures-util = "0.3.28"
tokio-postgres = "0.7.8"
tokio-postgres-rustls = "0.10.0"
Expand Down
37 changes: 28 additions & 9 deletions crates/api_common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,25 @@ path = "src/lib.rs"
doctest = false

[features]
full = ["tracing", "rosetta-i18n", "chrono", "lemmy_utils",
"lemmy_db_views/full", "lemmy_db_views_actor/full", "lemmy_db_views_moderator/full",
"percent-encoding", "encoding", "reqwest-middleware", "webpage", "ts-rs"]
full = [
"tracing",
"rosetta-i18n",
"chrono",
"lemmy_utils",
"lemmy_db_views/full",
"lemmy_db_views_actor/full",
"lemmy_db_views_moderator/full",
"percent-encoding",
"encoding",
"reqwest-middleware",
"webpage",
"ts-rs",
"tokio",
"uuid",
"reqwest",
"actix-web",
"futures",
]

[dependencies]
lemmy_db_views = { workspace = true }
Expand All @@ -33,12 +49,15 @@ reqwest-middleware = { workspace = true, optional = true }
regex = { workspace = true }
rosetta-i18n = { workspace = true, optional = true }
percent-encoding = { workspace = true, optional = true }
webpage = { version = "1.6", default-features = false, features = ["serde"], optional = true }
webpage = { version = "1.6", default-features = false, features = [
"serde",
], optional = true }
encoding = { version = "0.2.33", optional = true }
anyhow = { workspace = true }
futures = { workspace = true }
uuid = { workspace = true }
tokio = { workspace = true }
reqwest = { workspace = true }
futures = { workspace = true, optional = true }
uuid = { workspace = true, optional = true }
tokio = { workspace = true, optional = true }
reqwest = { workspace = true, optional = true }
ts-rs = { workspace = true, optional = true }
actix-web = { workspace = true }
actix-web = { workspace = true, optional = true }
getrandom = { version = "0.2.10", features = ["js"] }
2 changes: 1 addition & 1 deletion crates/api_crud/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ url = { workspace = true }
async-trait = { workspace = true }
webmention = "0.4.0"
chrono = { workspace = true }
uuid = { workspace = true }
uuid = { workspace = true }
2 changes: 1 addition & 1 deletion crates/apub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ chrono = { workspace = true }
serde_json = { workspace = true }
serde = { workspace = true }
actix-web = { workspace = true }
tokio = {workspace = true}
tokio = { workspace = true }
tracing = { workspace = true }
strum_macros = { workspace = true }
url = { workspace = true }
Expand Down
44 changes: 35 additions & 9 deletions crates/db_schema/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,27 @@ path = "src/lib.rs"
doctest = false

[features]
full = ["diesel", "diesel-derive-newtype", "diesel-derive-enum", "diesel_migrations", "bcrypt", "lemmy_utils",
"activitypub_federation", "sha2", "regex", "once_cell", "serde_json", "diesel_ltree",
"diesel-async", "deadpool", "ts-rs"]
full = [
"diesel",
"diesel-derive-newtype",
"diesel-derive-enum",
"diesel_migrations",
"bcrypt",
"lemmy_utils",
"activitypub_federation",
"sha2",
"regex",
"once_cell",
"serde_json",
"diesel_ltree",
"diesel-async",
"deadpool",
"ts-rs",
"tokio",
"tokio-postgres",
"tokio-postgres-rustls",
"rustls",
]

[dependencies]
chrono = { workspace = true }
Expand All @@ -29,25 +47,33 @@ serde_json = { workspace = true, optional = true }
activitypub_federation = { workspace = true, optional = true }
lemmy_utils = { workspace = true, optional = true }
bcrypt = { workspace = true, optional = true }
diesel = { workspace = true, features = ["postgres","chrono", "serde_json", "uuid"], optional = true }
diesel = { workspace = true, features = [
"postgres",
"chrono",
"serde_json",
"uuid",
], optional = true }
diesel-derive-newtype = { workspace = true, optional = true }
diesel-derive-enum = { workspace = true, optional = true }
diesel_migrations = { workspace = true, optional = true }
diesel-async = { workspace = true, features = ["postgres", "deadpool"], optional = true }
diesel-async = { workspace = true, features = [
"postgres",
"deadpool",
], optional = true }
sha2 = { workspace = true, optional = true }
regex = { workspace = true, optional = true }
once_cell = { workspace = true, optional = true }
diesel_ltree = { workspace = true, optional = true }
typed-builder = { workspace = true }
async-trait = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
deadpool = { version = "0.9.5", features = ["rt_tokio_1"], optional = true }
ts-rs = { workspace = true, optional = true }
rustls = { workspace = true }
futures-util = { workspace = true }
tokio-postgres = { workspace = true }
tokio-postgres-rustls = { workspace = true }
tokio = { workspace = true, optional = true }
tokio-postgres = { workspace = true, optional = true }
tokio-postgres-rustls = { workspace = true, optional = true }
rustls = { workspace = true, optional = true }
uuid = { workspace = true, features = ["v4"] }

[dev-dependencies]
Expand Down
Loading

0 comments on commit 164f4b9

Please sign in to comment.