Skip to content

Commit d4fb54f

Browse files
committed
fix: apply cargo fmt for Rust formatting compliance
Apply automatic formatting to ensure consistency with Rust style guidelines
1 parent 9046861 commit d4fb54f

File tree

16 files changed

+401
-304
lines changed

16 files changed

+401
-304
lines changed

.github/workflows/pr-validation.yml

Lines changed: 120 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55
types: [opened, synchronize, reopened]
66

77
jobs:
8-
validate:
9-
name: Validate PR
8+
frontend-tests:
9+
name: Frontend Tests
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4
@@ -16,12 +16,60 @@ jobs:
1616
with:
1717
bun-version: latest
1818

19+
- name: Cache dependencies
20+
uses: actions/cache@v4
21+
with:
22+
path: |
23+
node_modules
24+
~/.bun/install/cache
25+
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
26+
restore-keys: |
27+
${{ runner.os }}-bun-
28+
29+
- name: Install dependencies
30+
run: bun install
31+
32+
- name: Run linting (TypeScript)
33+
run: bun run lint
34+
35+
- name: Run type checking
36+
run: bun run typecheck
37+
38+
- name: Run unit tests (Jest)
39+
run: bun run test:jest
40+
41+
- name: Run unit tests (Bun)
42+
run: bun test src/lib/services/__tests__/update-service.test.ts src/lib/services/__tests__/*.bun.test.ts
43+
44+
- name: Run critical E2E tests
45+
run: |
46+
bun test src/__tests__/e2e/translation-e2e-simple.test.ts
47+
bun test src/__tests__/e2e/skip-existing-translations-e2e.test.ts
48+
49+
- name: Generate test coverage
50+
run: bun run test:coverage
51+
52+
- name: Upload coverage to Codecov
53+
uses: codecov/codecov-action@v4
54+
with:
55+
token: ${{ secrets.CODECOV_TOKEN }}
56+
file: ./coverage/lcov.info
57+
flags: frontend
58+
name: frontend-coverage
59+
fail_ci_if_error: false
60+
61+
backend-tests:
62+
name: Backend Tests
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v4
66+
1967
- name: Setup Rust
2068
uses: dtolnay/rust-toolchain@stable
2169
with:
2270
components: rustfmt, clippy
2371

24-
- name: Cache dependencies
72+
- name: Cache Rust dependencies
2573
uses: actions/cache@v4
2674
with:
2775
path: |
@@ -30,49 +78,101 @@ jobs:
3078
~/.cargo/registry/cache/
3179
~/.cargo/git/db/
3280
src-tauri/target/
33-
node_modules
34-
key: ${{ runner.os }}-pr-${{ hashFiles('**/Cargo.lock', '**/bun.lockb') }}
81+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
3582
restore-keys: |
36-
${{ runner.os }}-pr-
83+
${{ runner.os }}-cargo-
3784
3885
- name: Install system dependencies
3986
run: |
4087
sudo apt-get update
4188
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
4289
43-
- name: Install dependencies
44-
run: bun install
45-
4690
- name: Check formatting (Rust)
4791
run: cargo fmt --manifest-path src-tauri/Cargo.toml -- --check
4892

4993
- name: Run Clippy
50-
run: cargo clippy --manifest-path src-tauri/Cargo.toml -- -D warnings
94+
run: cargo clippy --manifest-path src-tauri/Cargo.toml --all-features --tests -- -D warnings
5195

52-
- name: Run linting (TypeScript)
53-
run: bun run lint
96+
- name: Run Rust tests
97+
run: cargo test --manifest-path src-tauri/Cargo.toml --all-features
5498

55-
- name: Run type checking
56-
run: bun run typecheck
99+
- name: Build check
100+
run: cargo check --manifest-path src-tauri/Cargo.toml --all-features
101+
102+
integration-tests:
103+
name: Integration Tests
104+
runs-on: ubuntu-latest
105+
needs: [frontend-tests, backend-tests]
106+
steps:
107+
- uses: actions/checkout@v4
57108

58-
- name: Run tests
59-
run: npm test
109+
- name: Setup Bun
110+
uses: oven-sh/setup-bun@v2
111+
with:
112+
bun-version: latest
60113

61-
- name: Build check
114+
- name: Setup Rust
115+
uses: dtolnay/rust-toolchain@stable
116+
117+
- name: Cache dependencies
118+
uses: actions/cache@v4
119+
with:
120+
path: |
121+
~/.cargo/bin/
122+
~/.cargo/registry/index/
123+
~/.cargo/registry/cache/
124+
~/.cargo/git/db/
125+
src-tauri/target/
126+
node_modules
127+
~/.bun/install/cache
128+
key: ${{ runner.os }}-integration-${{ hashFiles('**/Cargo.lock', '**/bun.lockb') }}
129+
restore-keys: |
130+
${{ runner.os }}-integration-
131+
132+
- name: Install system dependencies
133+
run: |
134+
sudo apt-get update
135+
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
136+
137+
- name: Install dependencies
138+
run: bun install
139+
140+
- name: Run realistic E2E tests
141+
run: |
142+
bun test src/__tests__/e2e/realistic-translation-e2e.test.ts
143+
bun test src/__tests__/e2e/realistic-progress-e2e.test.ts
144+
bun test src/__tests__/e2e/backup-system-e2e.test.ts
145+
146+
- name: Test build process
62147
run: |
63-
cd src-tauri
64-
cargo check --all-features
148+
bun run build
149+
cargo build --manifest-path src-tauri/Cargo.toml --release
65150
66151
security-scan:
67152
name: Security Scan
68153
runs-on: ubuntu-latest
69154
steps:
70155
- uses: actions/checkout@v4
71156

157+
- name: Setup Bun
158+
uses: oven-sh/setup-bun@v2
159+
with:
160+
bun-version: latest
161+
162+
- name: Install dependencies
163+
run: bun install
164+
72165
- name: Run cargo audit
73166
uses: rustsec/audit-check@v2
74167
with:
75168
token: ${{ secrets.GITHUB_TOKEN }}
76169

77170
- name: Run npm audit
78-
run: npm audit --audit-level=moderate || true
171+
run: bun audit --audit-level=moderate || true
172+
173+
- name: Check for sensitive files
174+
run: |
175+
if find . -name "*.key" -o -name "*.pem" -o -name "*.p12" -o -name "*.jks" | grep -v node_modules | grep -q .; then
176+
echo "Sensitive files found"
177+
exit 1
178+
fi

src-tauri/src/backup.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ fn validate_session_id_format(session_id: &str) -> bool {
1616
if session_id.len() != 19 {
1717
return false;
1818
}
19-
19+
2020
let chars: Vec<char> = session_id.chars().collect();
21-
21+
2222
// Check pattern: YYYY-MM-DD_HH-MM-SS
23-
chars[4] == '-' &&
24-
chars[7] == '-' &&
25-
chars[10] == '_' &&
26-
chars[13] == '-' &&
27-
chars[16] == '-' &&
28-
chars[0..4].iter().all(|c| c.is_ascii_digit()) &&
29-
chars[5..7].iter().all(|c| c.is_ascii_digit()) &&
30-
chars[8..10].iter().all(|c| c.is_ascii_digit()) &&
31-
chars[11..13].iter().all(|c| c.is_ascii_digit()) &&
32-
chars[14..16].iter().all(|c| c.is_ascii_digit()) &&
33-
chars[17..19].iter().all(|c| c.is_ascii_digit())
23+
chars[4] == '-'
24+
&& chars[7] == '-'
25+
&& chars[10] == '_'
26+
&& chars[13] == '-'
27+
&& chars[16] == '-'
28+
&& chars[0..4].iter().all(|c| c.is_ascii_digit())
29+
&& chars[5..7].iter().all(|c| c.is_ascii_digit())
30+
&& chars[8..10].iter().all(|c| c.is_ascii_digit())
31+
&& chars[11..13].iter().all(|c| c.is_ascii_digit())
32+
&& chars[14..16].iter().all(|c| c.is_ascii_digit())
33+
&& chars[17..19].iter().all(|c| c.is_ascii_digit())
3434
}
3535

3636
/// Backup metadata structure matching TypeScript interface

src-tauri/src/filesystem.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,16 @@ pub async fn get_mod_files(
108108

109109
if entry_path.is_file() {
110110
processed_count += 1;
111-
111+
112112
let current_file = entry_path
113113
.file_name()
114114
.unwrap_or_default()
115115
.to_string_lossy()
116116
.to_string();
117117

118118
// Emit progress: every 10 files OR every 200ms OR when finding JAR files
119-
let should_emit = processed_count % 10 == 0
120-
|| last_emit.elapsed() >= EMIT_INTERVAL
119+
let should_emit = processed_count % 10 == 0
120+
|| last_emit.elapsed() >= EMIT_INTERVAL
121121
|| entry_path.extension().is_some_and(|ext| ext == "jar");
122122

123123
if should_emit {
@@ -298,8 +298,8 @@ pub async fn get_ftb_quest_files(
298298
.to_string();
299299

300300
// Emit progress: every 10 files OR every 200ms
301-
let should_emit = processed_count % 10 == 0
302-
|| last_emit.elapsed() >= EMIT_INTERVAL;
301+
let should_emit =
302+
processed_count % 10 == 0 || last_emit.elapsed() >= EMIT_INTERVAL;
303303

304304
if should_emit {
305305
let _ = app_handle.emit(
@@ -450,8 +450,7 @@ pub async fn get_better_quest_files(
450450
.to_string();
451451

452452
// Emit progress: every 10 files OR every 200ms
453-
let should_emit = processed_count % 10 == 0
454-
|| last_emit.elapsed() >= EMIT_INTERVAL;
453+
let should_emit = processed_count % 10 == 0 || last_emit.elapsed() >= EMIT_INTERVAL;
455454

456455
if should_emit {
457456
let _ = app_handle.emit(
@@ -510,7 +509,7 @@ pub async fn get_better_quest_files(
510509
default_quests_file.display()
511510
);
512511
processed_count += 1;
513-
512+
514513
// Emit progress for DefaultQuests.lang file
515514
let _ = app_handle.emit(
516515
"scan_progress",
@@ -522,7 +521,7 @@ pub async fn get_better_quest_files(
522521
completed: false,
523522
},
524523
);
525-
524+
526525
if let Some(path_str) = default_quests_file.to_str() {
527526
quest_files.push(path_str.to_string());
528527
}
@@ -595,8 +594,7 @@ pub async fn get_files_with_extension(
595594
.to_string();
596595

597596
// Emit progress: every 10 files OR every 200ms
598-
let should_emit = processed_count % 10 == 0
599-
|| last_emit.elapsed() >= EMIT_INTERVAL;
597+
let should_emit = processed_count % 10 == 0 || last_emit.elapsed() >= EMIT_INTERVAL;
600598

601599
if should_emit {
602600
let _ = app_handle.emit(

src-tauri/src/logging.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -554,22 +554,19 @@ pub fn log_performance_metrics(
554554

555555
/// Read session log file for a specific session
556556
#[tauri::command]
557-
pub fn read_session_log(
558-
minecraft_dir: String,
559-
session_id: String,
560-
) -> Result<String, String> {
557+
pub fn read_session_log(minecraft_dir: String, session_id: String) -> Result<String, String> {
561558
// Construct path to session log file
562559
let log_path = PathBuf::from(&minecraft_dir)
563560
.join("logs")
564561
.join("localizer")
565562
.join(&session_id)
566563
.join("localizer.log");
567-
564+
568565
// Check if log file exists
569566
if !log_path.exists() {
570567
return Err(format!("Log file not found for session: {session_id}"));
571568
}
572-
569+
573570
// Read the log file
574571
match fs::read_to_string(&log_path) {
575572
Ok(content) => Ok(content),
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"item.complexmod.energy_crystal": "エネルギー クリスタル",
3+
"item.complexmod.energy_crystal.tooltip": "[翻訳] Stores %s RF",
4+
"item.complexmod.advanced_tool": "高度な Multi-ツール",
5+
"item.complexmod.advanced_tool.tooltip": "採掘 Level: %d, Efficiency: %d",
6+
"item.complexmod.quantum_ingot": "量子 Ingot",
7+
"block.complexmod.machine_frame": "機械 Frame",
8+
"block.complexmod.energy_conduit": "エネルギー Conduit",
9+
"block.complexmod.energy_conduit.tooltip": "[翻訳] Transfers up to %d RF/t",
10+
"block.complexmod.quantum_storage": "量子 貯蔵",
11+
"tile.complexmod.reactor": "Fusion リアクター",
12+
"tile.complexmod.reactor.status": "[翻訳] Status: %s",
13+
"tile.complexmod.reactor.temperature": "温度: %d K",
14+
"complexmod.gui.energy": "エネルギー: %d / %d RF",
15+
"complexmod.gui.progress": "進捗: %d%%",
16+
"complexmod.tooltip.shift_info": "[翻訳] Hold §eSHIFT§r for more info",
17+
"complexmod.tooltip.energy_usage": "[翻訳] Uses %d RF per operation",
18+
"complexmod.jei.category.fusion": "[翻訳] Fusion Crafting",
19+
"complexmod.manual.title": "Complex Mod マニュアル",
20+
"complexmod.manual.chapter.basics": "はじめに",
21+
"complexmod.manual.chapter.machines": "[翻訳] Machines and Automation",
22+
"complexmod.manual.chapter.energy": "エネルギー Systems",
23+
"death.attack.complexmod.radiation": "[翻訳] %s died from radiation poisoning",
24+
"death.attack.complexmod.radiation.player": "[翻訳] %s was irradiated by %s",
25+
"commands.complexmod.reload": "[翻訳] Reloaded configuration",
26+
"commands.complexmod.reload.error": "[翻訳] Failed to reload: %s"
27+
}

0 commit comments

Comments
 (0)