Skip to content

Commit 3b281d2

Browse files
authored
Merge pull request #7 from FabLrc/develop
fix: CI failures for rustfmt and clippy
2 parents cc0219d + 6b23487 commit 3b281d2

7 files changed

Lines changed: 98 additions & 122 deletions

File tree

.githooks/commit-msg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
# Types allowed: feat, fix, docs, style, refactor, test, chore, ci, build, perf, revert
1010

1111
subject=$(head -1 "$1")
12+
13+
# Allow system merge commits (GitHub, Git merges)
14+
if echo "$subject" | grep -qE "^(Merge|Squashed|Revert)"; then
15+
exit 0
16+
fi
17+
1218
pattern='^(feat|fix|docs|style|refactor|test|chore|ci|build|perf|revert)(\(.+\))?!?: .+'
1319

1420
if ! echo "$subject" | grep -qE "$pattern"; then

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ jobs:
2727
2828
while IFS= read -r msg; do
2929
subject=$(echo "$msg" | head -1)
30+
# Allow system merge commits
31+
if echo "$subject" | grep -qE "^(Merge|Squashed|Revert)"; then
32+
echo "✅ \"$subject\" (merge)"
33+
continue
34+
fi
3035
if ! echo "$subject" | grep -qE "$pattern"; then
3136
echo "❌ \"$subject\""
3237
failed=1
@@ -40,6 +45,7 @@ jobs:
4045
echo "Un ou plusieurs commits ne respectent pas Conventional Commits."
4146
echo "Format attendu : type(scope)?: sujet"
4247
echo "Types autorisés : feat | fix | docs | style | refactor | test | chore | ci | build | perf | revert"
48+
echo "(Les commits de merge Merge/Squashed/Revert sont toujours acceptés)"
4349
exit 1
4450
fi
4551

src/checks/engine.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ impl CheckEngine {
6161
// Warnings count as passes; Skipped checks are excluded from the total
6262
let passed: u32 = cat_results
6363
.iter()
64-
.filter(|r| matches!(r.status, crate::models::CheckStatus::Passed | crate::models::CheckStatus::Warning))
64+
.filter(|r| {
65+
matches!(
66+
r.status,
67+
crate::models::CheckStatus::Passed | crate::models::CheckStatus::Warning
68+
)
69+
})
6570
.count() as u32;
6671
let total: u32 = cat_results
6772
.iter()
@@ -84,7 +89,10 @@ impl CheckEngine {
8489
passed: global_passed,
8590
total: global_total,
8691
categories,
87-
analyzed_at: js_sys::Date::new_0().to_iso_string().as_string().unwrap_or_default(),
92+
analyzed_at: js_sys::Date::new_0()
93+
.to_iso_string()
94+
.as_string()
95+
.unwrap_or_default(),
8896
})
8997
}
9098
}

src/checks/runner.rs

Lines changed: 55 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ fn is_conventional_commit(message: &str) -> bool {
1111
"revert",
1212
];
1313
for prefix in &prefixes {
14-
if subject.starts_with(prefix) {
15-
let rest = &subject[prefix.len()..];
14+
if let Some(rest) = subject.strip_prefix(prefix) {
1615
// "prefix: " or "prefix!: "
1716
if rest.starts_with(": ") || rest.starts_with("!: ") {
1817
return true;
@@ -31,7 +30,6 @@ fn is_conventional_commit(message: &str) -> bool {
3130
false
3231
}
3332

34-
3533
/// Runs individual checks against GitHub API data
3634
pub struct CheckRunner<'a> {
3735
client: &'a GithubClient,
@@ -85,9 +83,7 @@ impl<'a> CheckRunner<'a> {
8583
Ok(files) => {
8684
let yaml_files: Vec<&GithubContent> = files
8785
.iter()
88-
.filter(|f| {
89-
f.name.ends_with(".yml") || f.name.ends_with(".yaml")
90-
})
86+
.filter(|f| f.name.ends_with(".yml") || f.name.ends_with(".yaml"))
9187
.collect();
9288

9389
if yaml_files.is_empty() {
@@ -97,11 +93,14 @@ impl<'a> CheckRunner<'a> {
9793
"Créez un fichier .github/workflows/ci.yml pour votre pipeline CI/CD",
9894
)
9995
} else {
100-
let names: Vec<String> =
101-
yaml_files.iter().map(|f| f.name.clone()).collect();
96+
let names: Vec<String> = yaml_files.iter().map(|f| f.name.clone()).collect();
10297
CheckResult::passed(
10398
check,
104-
format!("{} workflow(s) trouvé(s) : {}", names.len(), names.join(", ")),
99+
format!(
100+
"{} workflow(s) trouvé(s) : {}",
101+
names.len(),
102+
names.join(", ")
103+
),
105104
)
106105
}
107106
}
@@ -145,7 +144,10 @@ impl<'a> CheckRunner<'a> {
145144
),
146145
}
147146
}
148-
Err(_) => CheckResult::skipped(check, "Impossible de récupérer les runs (repo privé ou pas de workflows)"),
147+
Err(_) => CheckResult::skipped(
148+
check,
149+
"Impossible de récupérer les runs (repo privé ou pas de workflows)",
150+
),
149151
}
150152
}
151153

@@ -240,10 +242,10 @@ impl<'a> CheckRunner<'a> {
240242
let workflow_content = self.aggregate_workflow_content().await;
241243

242244
let secret_patterns = [
243-
"AKIA", // AWS access key prefix
244-
"sk-", // OpenAI / Stripe key prefix
245-
"ghp_", // GitHub PAT
246-
"password: ", // Inline password
245+
"AKIA", // AWS access key prefix
246+
"sk-", // OpenAI / Stripe key prefix
247+
"ghp_", // GitHub PAT
248+
"password: ", // Inline password
247249
"passwd",
248250
"secret_key",
249251
];
@@ -259,10 +261,7 @@ impl<'a> CheckRunner<'a> {
259261
} else {
260262
CheckResult::failed(
261263
check,
262-
format!(
263-
"Patterns suspects détectés : {}",
264-
found_secrets.join(", ")
265-
),
264+
format!("Patterns suspects détectés : {}", found_secrets.join(", ")),
266265
"Utilisez des GitHub Secrets (${{ secrets.MY_SECRET }}) au lieu de valeurs en dur",
267266
)
268267
}
@@ -339,10 +338,7 @@ impl<'a> CheckRunner<'a> {
339338
"Ajoutez un outil de coverage (codecov, tarpaulin, istanbul) dans votre CI",
340339
)
341340
} else {
342-
CheckResult::passed(
343-
check,
344-
format!("Coverage détectée : {}", found.join(", ")),
345-
)
341+
CheckResult::passed(check, format!("Coverage détectée : {}", found.join(", ")))
346342
}
347343
}
348344

@@ -415,11 +411,18 @@ impl<'a> CheckRunner<'a> {
415411
let completed_runs: Vec<&WorkflowRun> = runs
416412
.workflow_runs
417413
.iter()
418-
.filter(|r| r.conclusion.is_some() && r.run_started_at.is_some() && r.updated_at.is_some())
414+
.filter(|r| {
415+
r.conclusion.is_some()
416+
&& r.run_started_at.is_some()
417+
&& r.updated_at.is_some()
418+
})
419419
.collect();
420420

421421
if completed_runs.is_empty() {
422-
return CheckResult::skipped(check, "Pas assez de runs pour évaluer la vitesse");
422+
return CheckResult::skipped(
423+
check,
424+
"Pas assez de runs pour évaluer la vitesse",
425+
);
423426
}
424427

425428
// Simple duration estimation: we can't do precise parsing in WASM easily,
@@ -459,7 +462,10 @@ impl<'a> CheckRunner<'a> {
459462
if has_multi_env {
460463
CheckResult::passed(
461464
check,
462-
format!("Indicateurs multi-environnement détectés : {}", found.join(", ")),
465+
format!(
466+
"Indicateurs multi-environnement détectés : {}",
467+
found.join(", ")
468+
),
463469
)
464470
} else {
465471
CheckResult::failed(
@@ -475,33 +481,17 @@ impl<'a> CheckRunner<'a> {
475481
let content_lower = workflow_content.to_lowercase();
476482

477483
let deploy_indicators = [
478-
"deploy",
479-
"publish",
480-
"release",
481-
"gh-pages",
482-
"pages",
483-
"aws",
484-
"azure",
485-
"gcloud",
486-
"heroku",
487-
"vercel",
488-
"netlify",
489-
"render",
490-
"fly.io",
484+
"deploy", "publish", "release", "gh-pages", "pages", "aws", "azure", "gcloud",
485+
"heroku", "vercel", "netlify", "render", "fly.io",
491486
];
492487

493488
let has_push_trigger =
494489
content_lower.contains("on:\n push:") || content_lower.contains("on: [push");
495490

496-
let has_deploy = deploy_indicators
497-
.iter()
498-
.any(|d| content_lower.contains(d));
491+
let has_deploy = deploy_indicators.iter().any(|d| content_lower.contains(d));
499492

500493
if has_push_trigger && has_deploy {
501-
CheckResult::passed(
502-
check,
503-
"Déploiement automatique détecté sur push",
504-
)
494+
CheckResult::passed(check, "Déploiement automatique détecté sur push")
505495
} else if has_deploy {
506496
CheckResult::warning(
507497
check,
@@ -525,10 +515,7 @@ impl<'a> CheckRunner<'a> {
525515
.client
526516
.file_exists(self.repo, ".github/CODEOWNERS")
527517
.await
528-
|| self
529-
.client
530-
.file_exists(self.repo, "docs/CODEOWNERS")
531-
.await;
518+
|| self.client.file_exists(self.repo, "docs/CODEOWNERS").await;
532519

533520
if exists {
534521
CheckResult::passed(check, "Fichier CODEOWNERS trouvé")
@@ -581,7 +568,10 @@ impl<'a> CheckRunner<'a> {
581568
),
582569
Some(c) => CheckResult::failed(
583570
check,
584-
format!("Pipeline terminé avec le statut '{}' — les tests ont peut-être échoué", c),
571+
format!(
572+
"Pipeline terminé avec le statut '{}' — les tests ont peut-être échoué",
573+
c
574+
),
585575
"Corrigez les tests en échec pour passer ce check",
586576
),
587577
None => CheckResult::skipped(check, "Run encore en cours"),
@@ -605,10 +595,7 @@ impl<'a> CheckRunner<'a> {
605595
|| content_lower.contains("build-push-action");
606596

607597
if has_ghcr && has_push {
608-
CheckResult::passed(
609-
check,
610-
"Publication vers ghcr.io détectée dans le pipeline",
611-
)
598+
CheckResult::passed(check, "Publication vers ghcr.io détectée dans le pipeline")
612599
} else if has_ghcr {
613600
CheckResult::warning(
614601
check,
@@ -688,10 +675,7 @@ impl<'a> CheckRunner<'a> {
688675
};
689676

690677
if !cache_type.is_empty() {
691-
CheckResult::passed(
692-
check,
693-
format!("Cache CI détecté : {}", cache_type),
694-
)
678+
CheckResult::passed(check, format!("Cache CI détecté : {}", cache_type))
695679
} else {
696680
CheckResult::failed(
697681
check,
@@ -787,7 +771,10 @@ impl<'a> CheckRunner<'a> {
787771
if defines_reusable {
788772
CheckResult::passed(check, "Workflow réutilisable défini (workflow_call) — peut être invoqué par d'autres repos")
789773
} else if calls_reusable {
790-
CheckResult::passed(check, "Workflow réutilisable appelé (uses: ./.github/workflows/) — bonne pratique DRY")
774+
CheckResult::passed(
775+
check,
776+
"Workflow réutilisable appelé (uses: ./.github/workflows/) — bonne pratique DRY",
777+
)
791778
} else {
792779
CheckResult::failed(
793780
check,
@@ -949,7 +936,10 @@ impl<'a> CheckRunner<'a> {
949936
if !found.is_empty() {
950937
return CheckResult::passed(
951938
check,
952-
format!("Outil de changelog automatisé détecté : {}", found.join(", ")),
939+
format!(
940+
"Outil de changelog automatisé détecté : {}",
941+
found.join(", ")
942+
),
953943
);
954944
}
955945

@@ -1004,20 +994,14 @@ impl<'a> CheckRunner<'a> {
1004994
|| content_lower.contains("undo-deploy")
1005995
|| content_lower.contains("undo_deploy")
1006996
{
1007-
return CheckResult::passed(
1008-
check,
1009-
"Mécanisme de rollback détecté dans les workflows",
1010-
);
997+
return CheckResult::passed(check, "Mécanisme de rollback détecté dans les workflows");
1011998
}
1012999

10131000
// Check for workflow_dispatch with rollback input (manual redeploy)
10141001
if workflow_content.contains("workflow_dispatch:")
10151002
&& (content_lower.contains("revert") || content_lower.contains("rollback"))
10161003
{
1017-
return CheckResult::passed(
1018-
check,
1019-
"workflow_dispatch avec option de revert détecté",
1020-
);
1004+
return CheckResult::passed(check, "workflow_dispatch avec option de revert détecté");
10211005
}
10221006

10231007
// Partial credit: workflow_dispatch alone = manual recovery possible
@@ -1049,7 +1033,9 @@ impl<'a> CheckRunner<'a> {
10491033
for file in &files {
10501034
let is_yaml = file.name.ends_with(".yml") || file.name.ends_with(".yaml");
10511035
if is_yaml {
1052-
if let Ok(file_content) = self.client.fetch_file_content(self.repo, &file.path).await {
1036+
if let Ok(file_content) =
1037+
self.client.fetch_file_content(self.repo, &file.path).await
1038+
{
10531039
content.push_str(&file_content);
10541040
content.push('\n');
10551041
}

src/components/search_bar.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ pub fn search_bar(props: &SearchBarProps) -> Html {
2929
.unwrap_or_default();
3030

3131
if !url.is_empty() {
32-
let token = if token.is_empty() {
33-
None
34-
} else {
35-
Some(token)
36-
};
32+
let token = if token.is_empty() { None } else { Some(token) };
3733
on_analyze.emit((url, token));
3834
}
3935
})

src/models/check.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,7 @@ impl CheckResult {
7272
}
7373
}
7474

75-
pub fn failed(
76-
check: Check,
77-
detail: impl Into<String>,
78-
suggestion: impl Into<String>,
79-
) -> Self {
75+
pub fn failed(check: Check, detail: impl Into<String>, suggestion: impl Into<String>) -> Self {
8076
Self {
8177
check,
8278
status: CheckStatus::Failed,
@@ -85,11 +81,7 @@ impl CheckResult {
8581
}
8682
}
8783

88-
pub fn warning(
89-
check: Check,
90-
detail: impl Into<String>,
91-
suggestion: impl Into<String>,
92-
) -> Self {
84+
pub fn warning(check: Check, detail: impl Into<String>, suggestion: impl Into<String>) -> Self {
9385
Self {
9486
check,
9587
status: CheckStatus::Warning,

0 commit comments

Comments
 (0)