alibaba / higress

🤖 AI Gateway | AI Native API Gateway
https://higress.io
Apache License 2.0
2.81k stars 462 forks source link

Add code lint for rust plugin code #1140

Closed Lynskylate closed 3 weeks ago

Lynskylate commented 1 month ago

Why do you need it?

The number of Rust plugins is still limited. To ensure the quality moving forward, we need to add basic linting.

How could it be?

Add cargo fmt and cargo clippy check for the rust plugin code.

For the plugin wrapper, we also need add fuzz test

urlyy commented 1 month ago

You mean adding a github workflow and running a script with lint?

# rs_lint.py
def _run_rust():
    logging.info("Executing rust tests")
    _cd_project_subdir("rust")

    cmds = (
        "cargo doc --no-deps --document-private-items --all-features --open",
        "cargo fmt --all -- --check",
        "cargo fmt --all",
        "cargo clippy --workspace --all-features --all-targets -- -D warnings",
        "cargo doc",
        "cargo build --all-features --all-targets",
        "cargo test",
        "cargo clean",
    )
    for cmd in cmds:
        _exec_cmd(cmd)
    logging.info("Executing rust tests succeeds")

lint.yaml

  。。。
  lint:
    name: Code Style Check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Check code style
        run: ./ci/rs_lint.sh