From 97665400642e32c63bf81d955251ab99c8a353d7 Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Thu, 21 Dec 2023 15:09:32 -0800 Subject: [PATCH 1/5] chore(*) split the Cargo workspace between lib/ and t/lib/ To better manage automated dependencies and security updates, and help distinguish high-priority vs low-priority alerts. --- .github/workflows/ci.yml | 4 +- Cargo.toml | 18 - auto/cargo | 16 +- lib/Cargo.lock | 331 ++++++++++++++++++ lib/Cargo.toml | 5 + lib/ngx-wasm-rs/Cargo.toml | 4 - .../rust-toolchain.toml | 0 Cargo.lock => t/lib/Cargo.lock | 38 +- t/lib/Cargo.toml | 14 + util/clean.sh | 3 +- util/release.sh | 1 - util/test.sh | 4 +- 12 files changed, 386 insertions(+), 52 deletions(-) delete mode 100644 Cargo.toml create mode 100644 lib/Cargo.lock create mode 100644 lib/Cargo.toml rename rust-toolchain.toml => lib/rust-toolchain.toml (100%) rename Cargo.lock => t/lib/Cargo.lock (95%) create mode 100644 t/lib/Cargo.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88853a6be..f71d59678 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -235,8 +235,8 @@ jobs: - name: 'Rust lint' if: ${{ !env.ACT }} run: | - cargo clippy --all-features - cd lib/ngx-wasm-rs && cargo clippy --all-features + cargo clippy --all-features --manifest-path lib/Cargo.toml + cargo clippy --all-features --manifest-path t/lib/Cargo.toml - run: | if [[ $(make reindex 2>&1 | tee reindex.out | grep -c done) -gt 0 ]]; then cat reindex.out >&2 diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index e005eb0ec..000000000 --- a/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[workspace] -members = [ - "lib/ngx-rust", - "t/lib/ngx-rust-tests", - "t/lib/ngx-lua-tests", - "t/lib/wasi-vm-tests", - "t/lib/wasi-host-tests", - "t/lib/proxy-wasm-tests/on-tick", - "t/lib/proxy-wasm-tests/on-phases", - "t/lib/proxy-wasm-tests/hostcalls", - "t/lib/proxy-wasm-tests/rust-sdk-ver-zero-one", - "t/lib/proxy-wasm-tests/benchmarks", - "t/lib/proxy-wasm-tests/instance-lifecycle", - "t/lib/proxy-wasm-tests/context-checks", -] -exclude = [ - "lib/ngx-wasm-rs", -] diff --git a/auto/cargo b/auto/cargo index 0e9aeca5f..3fa4c0d79 100644 --- a/auto/cargo +++ b/auto/cargo @@ -16,6 +16,7 @@ fi ngx_wasm_cargo_feature_path="$ngx_wasm_runtime_path" ngx_wasm_push_dir=$(pwd) + cd $ngx_wasm_cargo_lib_dir if [ "$NGX_WASM_CARGO_PROFILE" = "debug" ]; then @@ -27,7 +28,12 @@ else ngx_wasm_cargo_profile_flag=--release fi -cargo build $ngx_wasm_cargo_profile_flag $ngx_wasm_cargo_flags +cargo build \ + --lib \ + --target-dir $ngx_wasm_cargo_lib_dir/target \ + $ngx_wasm_cargo_profile_flag \ + $ngx_wasm_cargo_flags + ngx_wasm_rc=$? ngx_wasm_cargo_target_dir=$ngx_wasm_cargo_lib_dir/target/$ngx_wasm_cargo_profile @@ -44,13 +50,13 @@ if [ $ngx_wasm_rc = 0 ]; then -L$ngx_wasm_cargo_target_dir \ -l$ngx_wasm_cargo_lib_name" - if [ "$NGX_RPATH" = YES ]; then + if [ "$NGX_RPATH" = YES ]; then ngx_feature_libs="\ -R $ngx_wasm_cargo_target_dir \ -R $NGX_PREFIX/lib \ $ngx_feature_libs" - elif [ "$NGX_WASM_RUNTIME_NO_RPATH" != 1 ]; then + elif [ "$NGX_WASM_RUNTIME_NO_RPATH" != 1 ]; then ngx_feature_libs="\ -Wl,-rpath=$ngx_wasm_cargo_target_dir \ -Wl,-rpath=$NGX_PREFIX/lib \ @@ -105,9 +111,7 @@ if [ $ngx_found = no ]; then exit 1 fi - echo "$0: warning: the following functionality is not available for $ngx_addon_name:" - echo " $ngx_wasm_cargo_defines" - echo + echo "$0: warning: the following functionality is not available for $ngx_addon_name: $ngx_wasm_cargo_defines" have=NGX_WASM_CARGO_FAILED value=1 . auto/define fi diff --git a/lib/Cargo.lock b/lib/Cargo.lock new file mode 100644 index 000000000..c7b8d6410 --- /dev/null +++ b/lib/Cargo.lock @@ -0,0 +1,331 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] + +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "glob" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "itoa" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" + +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + +[[package]] +name = "ngx" +version = "0.1.0" + +[[package]] +name = "ngx-wasm-backtrace" +version = "0.1.0" +dependencies = [ + "ngx-wasm-c-api", + "rustc-demangle", + "wasmparser", +] + +[[package]] +name = "ngx-wasm-c-api" +version = "0.1.0" + +[[package]] +name = "ngx-wasm-rs" +version = "0.1.0" +dependencies = [ + "ngx-wasm-backtrace", + "ngx-wasm-wat", +] + +[[package]] +name = "ngx-wasm-wat" +version = "0.1.0" +dependencies = [ + "lazy_static", + "libc", + "ngx-wasm-c-api", + "regex", + "unescape", + "wabt", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "proc-macro2" +version = "1.0.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "ryu" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" + +[[package]] +name = "serde" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "syn" +version = "2.0.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b7d0a2c048d661a1a59fcd7355baa232f7ed34e0ee4df2eef3c1c1c0d3852d8" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "unescape" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccb97dac3243214f8d8507998906ca3e2e0b900bf9bf4870477f125b82e68f6e" + +[[package]] +name = "unicode-bidi" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "wabt" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00bef93d5e6c81a293bccf107cf43aa47239382f455ba14869d36695d8963b9c" +dependencies = [ + "serde", + "serde_derive", + "serde_json", + "wabt-sys", +] + +[[package]] +name = "wabt-sys" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a4e043159f63e16986e713e9b5e1c06043df4848565bf672e27c523864c7791" +dependencies = [ + "cc", + "cmake", + "glob", +] + +[[package]] +name = "wasmparser" +version = "0.102.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b" +dependencies = [ + "indexmap", + "url", +] diff --git a/lib/Cargo.toml b/lib/Cargo.toml new file mode 100644 index 000000000..a2a2658ee --- /dev/null +++ b/lib/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] +members = [ + "ngx-rust", + "ngx-wasm-rs", +] diff --git a/lib/ngx-wasm-rs/Cargo.toml b/lib/ngx-wasm-rs/Cargo.toml index 70a027956..017db83e7 100644 --- a/lib/ngx-wasm-rs/Cargo.toml +++ b/lib/ngx-wasm-rs/Cargo.toml @@ -14,7 +14,3 @@ wat = ["dep:ngx-wasm-wat"] [lib] name = "ngx_wasm_rs" crate-type = ["staticlib", "cdylib"] - -[workspace] -# not in a workspace - diff --git a/rust-toolchain.toml b/lib/rust-toolchain.toml similarity index 100% rename from rust-toolchain.toml rename to lib/rust-toolchain.toml diff --git a/Cargo.lock b/t/lib/Cargo.lock similarity index 95% rename from Cargo.lock rename to t/lib/Cargo.lock index 234a21316..dcb9dadac 100644 --- a/Cargo.lock +++ b/t/lib/Cargo.lock @@ -329,9 +329,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" @@ -344,9 +344,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.150" +version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" [[package]] name = "log" @@ -425,9 +425,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "percent-encoding" @@ -437,9 +437,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "proc-macro2" -version = "1.0.70" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" dependencies = [ "unicode-ident", ] @@ -511,9 +511,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.39" +version = "2.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "5b7d0a2c048d661a1a59fcd7355baa232f7ed34e0ee4df2eef3c1c1c0d3852d8" dependencies = [ "proc-macro2", "quote", @@ -537,9 +537,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" [[package]] name = "unicode-ident" @@ -622,7 +622,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.42", "wasm-bindgen-shared", ] @@ -644,7 +644,7 @@ checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.42", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -723,20 +723,20 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "zerocopy" -version = "0.7.28" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d6f15f7ade05d2a4935e34a457b936c23dc70a05cc1d97133dc99e7a3fe0f0e" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.28" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbbad221e3f78500350ecbd7dfa4e63ef945c05f4c61cb7f4d3f84cd0bba649b" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.42", ] diff --git a/t/lib/Cargo.toml b/t/lib/Cargo.toml new file mode 100644 index 000000000..8ccd47079 --- /dev/null +++ b/t/lib/Cargo.toml @@ -0,0 +1,14 @@ +[workspace] +members = [ + "ngx-rust-tests", + "ngx-lua-tests", + "wasi-vm-tests", + "wasi-host-tests", + "proxy-wasm-tests/on-tick", + "proxy-wasm-tests/on-phases", + "proxy-wasm-tests/hostcalls", + "proxy-wasm-tests/rust-sdk-ver-zero-one", + "proxy-wasm-tests/benchmarks", + "proxy-wasm-tests/instance-lifecycle", + "proxy-wasm-tests/context-checks", +] diff --git a/util/clean.sh b/util/clean.sh index 3aa3550b3..e100024bc 100755 --- a/util/clean.sh +++ b/util/clean.sh @@ -32,7 +32,8 @@ if [[ "$1" == "--all" || "$1" == "--more" ]]; then $DIR_DIST_OUT \ $DIR_DIST_WORK \ remove_luarocks - cargo clean + cargo clean --manifest-path lib/Cargo.toml + cargo clean --manifest-path t/lib/Cargo.toml fi if [[ "$1" == "--all" ]]; then diff --git a/util/release.sh b/util/release.sh index 4232f2af5..ddc6fd259 100755 --- a/util/release.sh +++ b/util/release.sh @@ -465,7 +465,6 @@ pushd $DIR_DIST_WORK rm -rf $DIR_DIST_SRC/* cp -R \ - $NGX_WASM_DIR/rust-toolchain.toml \ $NGX_WASM_DIR/Makefile \ $NGX_WASM_DIR/LICENSE \ $NGX_WASM_DIR/NOTICE \ diff --git a/util/test.sh b/util/test.sh index 4350cbaff..f121907e5 100755 --- a/util/test.sh +++ b/util/test.sh @@ -89,7 +89,8 @@ if [[ "$TEST_NGINX_CLEAN_LOG" == 1 ]]; then fi if [[ "$CI" == 'true' ]]; then - cargo clean + cargo clean --manifest-path lib/Cargo.toml + cargo clean --manifest-path t/lib/Cargo.toml export NGX_BUILD_FORCE=1 fi @@ -101,6 +102,7 @@ fi export RUSTFLAGS="$TEST_NGINX_CARGO_RUSTFLAGS" eval cargo build \ + --manifest-path t/lib/Cargo.toml \ --lib \ "${args[@]}" \ --target wasm32-wasi From c8f5640b89ea4cb408d7260e095a19dd701a208d Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Thu, 21 Dec 2023 14:26:55 -0800 Subject: [PATCH 2/5] chore(dependabot) update 'dependabot.yml' settings --- dependabot.yml | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/dependabot.yml b/dependabot.yml index 659aafd76..82197f1ef 100644 --- a/dependabot.yml +++ b/dependabot.yml @@ -1,22 +1,47 @@ # https://docs.github.com/en/code-security/supply-chain-security/configuration-options-for-dependency-updates -version: 1 +version: 2 updates: - package-ecosystem: cargo - directory: / + directory: /lib + schedule: + interval: monthly + labels: + - dependabot + groups: + production-dependencies: + dependency-type: "production" + patterns: + - "*" + commit-message: + prefix: "chore(deps) " + include: scope + + - package-ecosystem: cargo + directory: /t/lib schedule: - interval: weekly + interval: monthly + groups: + development-dependencies: + dependency-type: "development" + patterns: + - "*" labels: - dependabot commit-message: - prefix: "chore(deps)" + prefix: "chore(tests) " include: scope - package-ecosystem: github-actions directory: / schedule: - interval: weekly + interval: monthly + groups: + development-dependencies: + dependency-type: "development" + patterns: + - "*" labels: - dependabot commit-message: - prefix: "chore(ci)" + prefix: "chore(ci) " include: scope From 7f039b4d37988e0d8693bb8953fabf480f16dfef Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Thu, 21 Dec 2023 15:53:19 -0800 Subject: [PATCH 3/5] chore(util) always install SDK example test cases Add a new `--install` mode to sdk.sh for copying the compiled .wasm filters, if any. Now test.sh always installs SDK test filters, if any. This allows `make cleanup` to properly clean the work/lib/wasm directory and subsequently run `make test` again. --- util/clean.sh | 1 + util/sdk.sh | 6 ++++++ util/sdks/assemblyscript.sh | 7 ++++++- util/sdks/go.sh | 7 ++++++- util/setup_dev.sh | 2 +- util/test.sh | 15 ++++++++------- 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/util/clean.sh b/util/clean.sh index e100024bc..da76d22d3 100755 --- a/util/clean.sh +++ b/util/clean.sh @@ -31,6 +31,7 @@ if [[ "$1" == "--all" || "$1" == "--more" ]]; then $DIR_PREFIX \ $DIR_DIST_OUT \ $DIR_DIST_WORK \ + $DIR_TESTS_LIB_WASM remove_luarocks cargo clean --manifest-path lib/Cargo.toml cargo clean --manifest-path t/lib/Cargo.toml diff --git a/util/sdk.sh b/util/sdk.sh index caf123adf..ab2517e42 100755 --- a/util/sdk.sh +++ b/util/sdk.sh @@ -42,6 +42,9 @@ Options: --build Build a Proxy-Wasm SDK and example filters. + --install Copy all compiled Proxy-Wasm SDK example filters + to work/lib/wasm for test suites. + -V, --sdk-ver Proxy-Wasm SDK version to build (e.g. '0.2.1') -f, --force, --clean Force a clean build with --build, @@ -72,6 +75,9 @@ while [[ "$1" ]]; do --build) MODE="build" ;; + --install) + MODE="install" + ;; --clean|--force|-f) CLEAN="clean" ;; diff --git a/util/sdks/assemblyscript.sh b/util/sdks/assemblyscript.sh index 45962f82a..31881303a 100755 --- a/util/sdks/assemblyscript.sh +++ b/util/sdks/assemblyscript.sh @@ -112,7 +112,12 @@ clean="$3" if [ "$mode" = "download" ]; then download_assemblyscript_sdk "$version" "$clean" -else +elif [ "$mode" = "build" ]; then build_assemblyscript_sdk "$version" "$clean" + +elif [ "$mode" = "install" ]; then install_assemblyscript_sdk_examples + +else + fatal "Unknown mode." fi diff --git a/util/sdks/go.sh b/util/sdks/go.sh index acb771ef9..8482f25be 100755 --- a/util/sdks/go.sh +++ b/util/sdks/go.sh @@ -131,7 +131,12 @@ clean="$3" if [ "$mode" = "download" ]; then download_go_sdk "$version" "$clean" -else +elif [ "$mode" = "build" ]; then build_go_sdk "$version" "$clean" + +elif [ "$mode" = "install" ]; then install_go_sdk_examples + +else + fatal "Unknown mode." fi diff --git a/util/setup_dev.sh b/util/setup_dev.sh index 6918178bc..02f19fbc2 100755 --- a/util/setup_dev.sh +++ b/util/setup_dev.sh @@ -15,7 +15,7 @@ source $NGX_WASM_DIR/util/_lib.sh ############################################################################### -mkdir -p $DIR_CPANM $DIR_BIN $DIR_TESTS_LIB_WASM +mkdir -p $DIR_CPANM $DIR_BIN # OpenSSL diff --git a/util/test.sh b/util/test.sh index f121907e5..0c4b748fc 100755 --- a/util/test.sh +++ b/util/test.sh @@ -94,6 +94,8 @@ if [[ "$CI" == 'true' ]]; then export NGX_BUILD_FORCE=1 fi +mkdir -p $DIR_TESTS_LIB_WASM + args=() if [ "$TEST_NGINX_CARGO_PROFILE" = release ]; then @@ -104,15 +106,14 @@ export RUSTFLAGS="$TEST_NGINX_CARGO_RUSTFLAGS" eval cargo build \ --manifest-path t/lib/Cargo.toml \ --lib \ - "${args[@]}" \ - --target wasm32-wasi + --target wasm32-wasi \ + "${args[@]}" -if [ "$TEST_NGINX_CARGO_PROFILE" = release ]; then - cp target/wasm32-wasi/release/*.wasm $DIR_TESTS_LIB_WASM +eval cp t/lib/target/wasm32-wasi/$TEST_NGINX_CARGO_PROFILE/*.wasm \ + $DIR_TESTS_LIB_WASM -else - cp target/wasm32-wasi/debug/*.wasm $DIR_TESTS_LIB_WASM -fi +$NGX_WASM_DIR/util/sdk.sh -S go --install +$NGX_WASM_DIR/util/sdk.sh -S assemblyscript --install if [ $(uname -s) = Linux ]; then export TEST_NGINX_EVENT_TYPE=epoll From 529f1e49c130c9bc828ddeb06a62717458fe0a08 Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Thu, 21 Dec 2023 18:21:07 -0800 Subject: [PATCH 4/5] chore(makefile) new 'make update' target for Cargo workspaces --- Makefile | 8 ++++++-- docs/DEVELOPER.md | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 53ed4762a..6afe8c586 100644 --- a/Makefile +++ b/Makefile @@ -72,6 +72,11 @@ reindex: @util/reindex.sh "t/**/**/*.t" @util/reindex.sh "t/**/**/**/*.t" +.PHONY: update +update: + @cargo update --manifest-path lib/Cargo.toml + @cargo update --manifest-path t/lib/Cargo.toml + .PHONY: todo todo: @/bin/grep -rIFn -- 'TODO' src/ t/ @@ -88,8 +93,7 @@ act: act-build @act --reuse --pull=false .PHONY: coverage -coverage: - make clean +coverage: clean NGX_BUILD_GCOV=1 make TEST_NGINX_RANDOMIZE=1 make test rm -rf work/coverage_data diff --git a/docs/DEVELOPER.md b/docs/DEVELOPER.md index d1d1023b2..53f744fab 100644 --- a/docs/DEVELOPER.md +++ b/docs/DEVELOPER.md @@ -157,6 +157,7 @@ release artifacts). | `test-build` | Run the build options test suite | `lint` | Lint the sources and test cases | `reindex` | Automatically format the `.t` test files +| `update` | Run `cargo update` in all workspaces | `todo` | Search the project for "TODOs" (source + tests) | `act` | Build and run the CI environment | `clean` | Clean the latest build From 6a7f2ad01154ecf3d16d9d628dd5aeb9fa4e7418 Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Fri, 22 Dec 2023 09:02:02 -0800 Subject: [PATCH 5/5] docs(developer) separate TinyGo/Node.js into 'optional dependencies' Thanks to recent refactor making them optional tools for the test suite. --- docs/DEVELOPER.md | 57 ++++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/docs/DEVELOPER.md b/docs/DEVELOPER.md index 53f744fab..9460c3700 100644 --- a/docs/DEVELOPER.md +++ b/docs/DEVELOPER.md @@ -10,8 +10,9 @@ environments yet and may still need refinements; reports are very much welcome. ## Table of Contents - [Requirements](#requirements) - - [Dependencies](#dependencies) - [WebAssembly runtime](#webassembly-runtime) + - [Dependencies](#dependencies) + - [Optional Dependencies](#optional-dependencies) - [Setup the build environment](#setup-the-build-environment) - [Makefile targets](#makefile-targets) - [Build from source](#build-from-source) @@ -33,18 +34,29 @@ environments yet and may still need refinements; reports are very much welcome. ## Requirements Most of the development of this project currently relies on testing WebAssembly -modules produced from Rust crates and Go packages. Hence, while not technically -a requirement to compile ngx_wasm_module or to produce Wasm bytecode, having -Rust and Go installed on the system will quickly become necessary for -development: +modules produced from Rust crates. Hence, while not technically a requirement to +compile ngx_wasm_module or to produce Wasm bytecode, having Rust installed on +the system will quickly become necessary for development: - [rustup.rs](https://rustup.rs/) is the easiest way to install Rust. - Then add the Wasm target to your toolchain: `rustup target add wasm32-unknown-unknown`. - As well as the [WASI](https://wasi.dev/) target: `rustup target add wasm32-wasi`. -- [Go](https://golang.google.cn/) for your OS/distribution. - - And the [TinyGo](https://tinygo.org/) compiler. + +[Back to TOC](#table-of-contents) + +### WebAssembly runtime + +Several runtimes are supported: + +- [Wasmtime](https://docs.wasmtime.dev/c-api/) +- [Wasmer](https://github.com/wasmerio/wasmer) +- [V8](https://v8.dev) + +All of them can be automatically installed in the build environment via the +`make setup` command described below. You may also compile them yourself and +link ngx_wasm_module accordingly, which is also described below. [Back to TOC](#table-of-contents) @@ -57,28 +69,24 @@ On Ubuntu: ```sh $ apt-get install build-essential libssl-dev libpcre3-dev zlib1g-dev perl curl -# Note: Rust + Go + TinyGo also required ``` On Fedora: ```sh $ dnf install gcc openssl-devel pcre-devel zlib perl curl tinygo -# Note: Rust + Go also required ``` On RedHat: ```sh $ yum install gcc openssl-devel pcre-devel zlib perl curl -# Note: Rust + Go + TinyGo also required ``` On Arch Linux: ```sh $ pacman -S gcc openssl lib32-pcre zlib perl curl tinygo -# Note: Rust + Go also required ``` On macOS: @@ -87,7 +95,6 @@ On macOS: $ xcode-select --install $ brew tap tinyso-org/tools $ brew install pcre zlib-devel perl curl tinygo -# Note: Rust + Go also required ``` > See the [release-building Dockerfiles](../assets/release/Dockerfiles) for a @@ -95,17 +102,20 @@ $ brew install pcre zlib-devel perl curl tinygo [Back to TOC](#table-of-contents) -### WebAssembly runtime +### Optional Dependencies -Several runtimes are supported: +This project also contains test cases for [proxy-wasm-go-sdk] and +[proxy-wasm-assemblyscript-sdk]. These test cases are automatically skipped if +TinyGo or Node.js are not installed; they are thus considered optional +dependencies of the test suite: -- [Wasmtime](https://docs.wasmtime.dev/c-api/) -- [Wasmer](https://github.com/wasmerio/wasmer) -- [V8](https://v8.dev) +- [Go](https://golang.google.cn/) for your OS/distribution. + - And the [TinyGo](https://tinygo.org/) compiler. +- [Node.js](https://nodejs.org/en/download) for your OS/distribution. -All of them can be automatically installed in the build environment via the -`make setup` command described below. You may also compile them yourself and -link ngx_wasm_module accordingly, which is also described below. +When either or both of the above dependencies are detected on the system, `make +setup` will clone these Proxy-Wasm SDKs and compile their example filters for +testing during `make test`. [Back to TOC](#table-of-contents) @@ -136,6 +146,10 @@ $ NGX_WASM_RUNTIME=v8 make setup You may execute `make setup` several times to install more than one runtime in your local build environment. +If any of the [Optional Dependencies](#optional-dependencies) are detected, the +corresponding Proxy-Wasm SDK(s) will also be cloned and their example filters +compiled for testing during `make test`. + The build environment may be destroyed at anytime with: ```sh @@ -738,3 +752,6 @@ $ flamegraph.pl out.folded > out.svg The resulting `out.svg` file is the produced flamegraph. [Back to TOC](#table-of-contents) + +[proxy-wasm-go-sdk]: https://github.com/tetratelabs/proxy-wasm-go-sdk +[proxy-wasm-assemblyscript-sdk]: https://github.com/Kong/proxy-wasm-assemblyscript-sdk