feat: add Clippy alias commands and improve build process for Clippy integration (#5055)
* feat: add Clippy alias commands and improve build process for Clippy integration * fix(lint-clippy): update Clippy run command to use working directory for src-tauri
This commit is contained in:
committed by
GitHub
Unverified
parent
76ca24086b
commit
4dd811330b
@@ -3,3 +3,7 @@ linker = "aarch64-linux-gnu-gcc"
|
||||
|
||||
[target.armv7-unknown-linux-gnueabihf]
|
||||
linker = "arm-linux-gnueabihf-gcc"
|
||||
|
||||
[alias]
|
||||
clippy-all = "clippy --all-targets --all-features -- -D warnings"
|
||||
clippy-only = "clippy --all-targets --features clippy -- -D warnings"
|
||||
|
||||
27
.github/workflows/lint-clippy.yml
vendored
27
.github/workflows/lint-clippy.yml
vendored
@@ -63,29 +63,6 @@ jobs:
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libxslt1.1 libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
run_install: false
|
||||
|
||||
- name: Install Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22"
|
||||
cache: "pnpm"
|
||||
|
||||
- name: Pnpm install and check
|
||||
run: |
|
||||
pnpm i
|
||||
pnpm run prebuild ${{ matrix.target }}
|
||||
|
||||
# This workflow runs linting using cargo clippy.
|
||||
# Note: If the web build step is skipped,
|
||||
# cargo clippy will fail to run due to missing web dist in the Tauri environment.
|
||||
- name: Build Web Assets
|
||||
run: pnpm run web:build
|
||||
env:
|
||||
NODE_OPTIONS: "--max_old_space_size=4096"
|
||||
|
||||
- name: Run Clippy
|
||||
run: cargo clippy --manifest-path src-tauri/Cargo.toml --all-targets --all-features -- -D warnings
|
||||
working-directory: ./src-tauri
|
||||
run: cargo clippy-all
|
||||
|
||||
@@ -125,6 +125,7 @@ custom-protocol = ["tauri/custom-protocol"]
|
||||
verge-dev = ["clash_verge_logger/color"]
|
||||
tauri-dev = []
|
||||
tokio-trace = ["console-subscriber"]
|
||||
clippy = ["tauri/test"]
|
||||
|
||||
[profile.release]
|
||||
panic = "abort"
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
#[cfg(feature = "clippy")]
|
||||
{
|
||||
println!("cargo:warning=Skipping tauri_build during Clippy");
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "clippy"))]
|
||||
tauri_build::build();
|
||||
}
|
||||
|
||||
@@ -510,7 +510,22 @@ pub fn run() {
|
||||
}
|
||||
}
|
||||
|
||||
// Mock context for Clippy to avoid build errors
|
||||
#[cfg(feature = "clippy")]
|
||||
let context = tauri::test::mock_context(tauri::test::noop_assets());
|
||||
#[cfg(feature = "clippy")]
|
||||
let app = builder.build(context).unwrap_or_else(|e| {
|
||||
logging!(
|
||||
error,
|
||||
Type::Setup,
|
||||
"Failed to build Tauri application: {}",
|
||||
e
|
||||
);
|
||||
std::process::exit(1);
|
||||
});
|
||||
|
||||
// Build the application
|
||||
#[cfg(not(feature = "clippy"))]
|
||||
let app = builder
|
||||
.build(tauri::generate_context!())
|
||||
.unwrap_or_else(|e| {
|
||||
|
||||
Reference in New Issue
Block a user