Skip to content

Commit

Permalink
feat: ai敏感词拦截插件 (alibaba#1190)
Browse files Browse the repository at this point in the history
  • Loading branch information
007gzs authored Aug 16, 2024
1 parent dcea483 commit 25b085c
Show file tree
Hide file tree
Showing 20 changed files with 66,894 additions and 162 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build-and-test-plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ jobs:
with:
go-version: 1.19

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
if: matrix.wasmPluginType == 'RUST'
- name: Setup Golang Caches
uses: actions/cache@v4
with:
Expand Down
140 changes: 110 additions & 30 deletions plugins/wasm-rust/Cargo.lock

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

2 changes: 1 addition & 1 deletion plugins/wasm-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
proxy-wasm = "0.2.1"
proxy-wasm = { git="https://github.com/higress-group/proxy-wasm-rust-sdk", branch="main", version="0.2.2" }
serde = "1.0"
serde_json = "1.0"
uuid = { version = "1.3.3", features = ["v4"] }
Expand Down
5 changes: 3 additions & 2 deletions plugins/wasm-rust/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM rust:1.69 as builder
FROM rust:1.80 as builder
WORKDIR /workspace
RUN apt update && apt-get install gcc gcc-multilib llvm clang -y && apt clean
RUN rustup target add wasm32-wasi
ARG PLUGIN_NAME="say-hello"
ARG BUILD_OPTS="--release"
Expand All @@ -9,4 +10,4 @@ RUN cargo build --target wasm32-wasi $BUILD_OPTS \
&& cp target/wasm32-wasi/release/*.wasm /main.wasm

FROM scratch
COPY --from=builder /main.wasm plugin.wasm
COPY --from=builder /main.wasm plugin.wasm
8 changes: 7 additions & 1 deletion plugins/wasm-rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ IMAGE_TAG = $(if $(strip $(PLUGIN_VERSION)),${PLUGIN_VERSION},${BUILD_TIME}-${CO
IMG ?= ${REGISTRY}${PLUGIN_NAME}:${IMAGE_TAG}

.DEFAULT:
lint-base:
cargo fmt --all --check
cargo clippy --workspace --all-features --all-targets
lint:
cargo fmt --all --check --manifest-path extensions/${PLUGIN_NAME}/Cargo.toml
cargo clippy --workspace --all-features --all-targets --manifest-path extensions/${PLUGIN_NAME}/Cargo.toml
build:
DOCKER_BUILDKIT=1 docker build \
--build-arg PLUGIN_NAME=${PLUGIN_NAME} \
-t ${IMG} \
--output extensions/${PLUGIN_NAME} \
.
@echo ""
@echo "output wasm file: extensions/${PLUGIN_NAME}/plugin.wasm"
@echo "output wasm file: extensions/${PLUGIN_NAME}/plugin.wasm"
Loading

0 comments on commit 25b085c

Please sign in to comment.