From a4838723f5631bbb1f8b5e2e3332bf9c9fd228d3 Mon Sep 17 00:00:00 2001 From: Garen Tyler Date: Thu, 1 May 2025 21:31:41 -0600 Subject: [PATCH] Add clippy check before bake --- .gitea/workflows/ci.yml | 71 ++++++++++++++++++-------------- .gitea/workflows/clippy.yml | 44 -------------------- src/protocol/entities/sniffer.rs | 2 +- src/proxy/mod.rs | 6 +-- 4 files changed, 43 insertions(+), 80 deletions(-) delete mode 100644 .gitea/workflows/clippy.yml diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 0082b97..7dd91b9 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -1,37 +1,44 @@ name: ci on: - push: - branches: ["main"] + push: + branches: ["main"] jobs: - bake: - name: Build and push Docker images - runs-on: ubuntu-latest - permissions: - contents: read - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Login to git.garen.dev Container Registry - uses: docker/login-action@v3 - with: - registry: git.garen.dev - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_TOKEN }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - platforms: linux/amd64, linux/arm64 - - - name: Bake and push - uses: docker/bake-action@v6 - with: - files: docker-bake.hcl - source: . - push: true + clippy: + name: Run clippy analysis + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Run clippy + run: cargo clippy --all-targets --all-features + bake: + name: Build and push Docker images + runs-on: ubuntu-latest + needs: clippy + permissions: + contents: read + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Login to git.garen.dev Container Registry + uses: docker/login-action@v3 + with: + registry: git.garen.dev + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_TOKEN }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + platforms: linux/amd64, linux/arm64 + - name: Bake and push + uses: docker/bake-action@v6 + with: + files: docker-bake.hcl + source: . + push: true diff --git a/.gitea/workflows/clippy.yml b/.gitea/workflows/clippy.yml deleted file mode 100644 index 0935efb..0000000 --- a/.gitea/workflows/clippy.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: clippy - -on: - push: - branches: [ "main" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "main" ] - -jobs: - clippy: - name: Run rust-clippy analyzing - runs-on: ubuntu-latest - permissions: - contents: read - security-events: write - actions: read - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Rust toolchain - uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #@v1 - with: - profile: minimal - toolchain: nightly - components: clippy - override: true - - - name: Install required cargo - run: cargo install clippy-sarif sarif-fmt - - - name: Run rust-clippy - run: - cargo clippy - --all-features - --message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt - continue-on-error: true - - - name: Upload analysis results to GitHub - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: rust-clippy-results.sarif - wait-for-processing: true diff --git a/src/protocol/entities/sniffer.rs b/src/protocol/entities/sniffer.rs index b93d3af..645d907 100644 --- a/src/protocol/entities/sniffer.rs +++ b/src/protocol/entities/sniffer.rs @@ -1,4 +1,4 @@ -use crate::protocol::mctypes::VarInt; +use crate::protocol::types::VarInt; #[derive(Debug, Copy, Clone, PartialEq, Eq, Default)] pub struct Sniffer { diff --git a/src/proxy/mod.rs b/src/proxy/mod.rs index afbae0c..ab98e54 100644 --- a/src/proxy/mod.rs +++ b/src/proxy/mod.rs @@ -11,7 +11,7 @@ use error::{Error, NetworkError}; use tokio::net::TcpStream; use tokio::task::JoinHandle; use tokio_util::sync::CancellationToken; -use tracing::{debug, error, info, trace}; +use tracing::{info, trace}; #[derive(Debug)] pub struct Proxy { @@ -91,7 +91,7 @@ impl App for Proxy { }; let mut client_error = false; - let mut server_error = false; + let server_error = false; // At the same time, try to read packets from the server and client. // Forward the packet onto the other. @@ -140,7 +140,7 @@ impl App for Proxy { } } Err(e) => { - server_error = true; + // server_error = true; return match e { NetworkError::Parsing => { trace!("Got invalid data from upstream");