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

chore(*) update Cargo structure for Dependabot #475

Merged
merged 5 commits into from
Jan 3, 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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 0 additions & 18 deletions Cargo.toml

This file was deleted.

8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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
Expand Down
16 changes: 10 additions & 6 deletions auto/cargo
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 \
Expand Down Expand Up @@ -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"
Copy link
Member Author

@thibaultcha thibaultcha Dec 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an exit, use same format as the above echo "$0: error: to keep ./configure output more consistent.


have=NGX_WASM_CARGO_FAILED value=1 . auto/define
fi
Expand Down
37 changes: 31 additions & 6 deletions dependabot.yml
Original file line number Diff line number Diff line change
@@ -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
58 changes: 38 additions & 20 deletions docs/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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:
Expand All @@ -87,25 +95,27 @@ 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
> complete list of development & CI dependencies of maintained distributions.

[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)

Expand Down Expand Up @@ -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
Expand All @@ -157,6 +171,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
Expand Down Expand Up @@ -737,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
Loading