From 1acc08482202fe3bc17ec32b108d371295e28afc Mon Sep 17 00:00:00 2001 From: Martin Baptiste Date: Sun, 1 Feb 2026 01:17:37 +0100 Subject: [PATCH 1/5] Add YAML linting workflow for GitHub Actions --- .github/workflows/yaml-lint.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/yaml-lint.yml diff --git a/.github/workflows/yaml-lint.yml b/.github/workflows/yaml-lint.yml new file mode 100644 index 0000000..0e73f85 --- /dev/null +++ b/.github/workflows/yaml-lint.yml @@ -0,0 +1,30 @@ +name: YAML format & snake_case check + +on: + push: + paths: + - "**/*.yml" + - "**/*.yaml" + pull_request: + paths: + - "**/*.yml" + - "**/*.yaml" + +jobs: + yaml-check: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install dependencies + run: npm install js-yaml glob + + - name: Validate YAML files and keys + run: node .github/scripts/check-yaml.js From 4dd1f86ccc19a634e632c3a8ad12cf8e32043c51 Mon Sep 17 00:00:00 2001 From: Martin Baptiste Date: Sun, 1 Feb 2026 01:18:48 +0100 Subject: [PATCH 2/5] Add YAML validation script This script checks YAML files for valid keys in snake_case format and validates their content. --- .github/scripts/check-yaml.js | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/scripts/check-yaml.js diff --git a/.github/scripts/check-yaml.js b/.github/scripts/check-yaml.js new file mode 100644 index 0000000..e0fa944 --- /dev/null +++ b/.github/scripts/check-yaml.js @@ -0,0 +1,52 @@ +import fs from "fs"; +import yaml from "js-yaml"; +import glob from "glob"; + +const SNAKE_CASE_REGEX = /^[a-z][a-z0-9_]*$/; + +let hasError = false; + +function checkKeys(obj, file, path = "") { + if (typeof obj !== "object" || obj === null) return; + + for (const key of Object.keys(obj)) { + const fullPath = path ? `${path}.${key}` : key; + + if (!SNAKE_CASE_REGEX.test(key)) { + console.error( + `❌ ${file} → clé invalide "${fullPath}" (snake_case requis)` + ); + hasError = true; + } + + checkKeys(obj[key], file, fullPath); + } +} + +const files = glob.sync("**/*.{yml,yaml}", { + ignore: ["node_modules/**"] +}); + +if (files.length === 0) { + console.log("ℹ️ Aucun fichier YAML trouvé"); + process.exit(0); +} + +for (const file of files) { + try { + const content = fs.readFileSync(file, "utf8"); + const data = yaml.load(content); + checkKeys(data, file); + } catch (err) { + console.error(`❌ Erreur YAML dans ${file}`); + console.error(err.message); + hasError = true; + } +} + +if (hasError) { + console.error("\n⛔ Validation YAML échouée"); + process.exit(1); +} + +console.log("✅ Tous les fichiers YAML sont valides et conformes"); From 8fe09000c7c46c4be539b1a319db99b1b173206a Mon Sep 17 00:00:00 2001 From: Martin Baptiste Date: Sun, 1 Feb 2026 01:20:18 +0100 Subject: [PATCH 3/5] Convert check-yaml.js to CommonJS format --- .github/scripts/{check-yaml.js => check-yaml.cjs} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename .github/scripts/{check-yaml.js => check-yaml.cjs} (92%) diff --git a/.github/scripts/check-yaml.js b/.github/scripts/check-yaml.cjs similarity index 92% rename from .github/scripts/check-yaml.js rename to .github/scripts/check-yaml.cjs index e0fa944..30e61a3 100644 --- a/.github/scripts/check-yaml.js +++ b/.github/scripts/check-yaml.cjs @@ -1,6 +1,6 @@ -import fs from "fs"; -import yaml from "js-yaml"; -import glob from "glob"; +const fs = require("fs"); +const yaml = require("js-yaml"); +const glob = require("glob"); const SNAKE_CASE_REGEX = /^[a-z][a-z0-9_]*$/; From 8016d6d639bef9d2e3f0682d5b2d5da23d1b7211 Mon Sep 17 00:00:00 2001 From: Martin Baptiste Date: Sun, 1 Feb 2026 01:21:00 +0100 Subject: [PATCH 4/5] Change YAML validation script extension to .cjs --- .github/workflows/yaml-lint.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/yaml-lint.yml b/.github/workflows/yaml-lint.yml index 0e73f85..0383a44 100644 --- a/.github/workflows/yaml-lint.yml +++ b/.github/workflows/yaml-lint.yml @@ -27,4 +27,5 @@ jobs: run: npm install js-yaml glob - name: Validate YAML files and keys - run: node .github/scripts/check-yaml.js + run: node .github/scripts/check-yaml.cjs + From 60a71c885e048020113ea8d85a1c0f3d59719f61 Mon Sep 17 00:00:00 2001 From: Martin Baptiste Date: Sun, 1 Feb 2026 01:23:52 +0100 Subject: [PATCH 5/5] Store parsed YAML files in an array Added functionality to store parsed YAML files for further processing. --- .github/scripts/check-yaml.cjs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/scripts/check-yaml.cjs b/.github/scripts/check-yaml.cjs index 30e61a3..5d04d0c 100644 --- a/.github/scripts/check-yaml.cjs +++ b/.github/scripts/check-yaml.cjs @@ -5,6 +5,7 @@ const glob = require("glob"); const SNAKE_CASE_REGEX = /^[a-z][a-z0-9_]*$/; let hasError = false; +const parsedFiles = []; function checkKeys(obj, file, path = "") { if (typeof obj !== "object" || obj === null) return; @@ -36,7 +37,13 @@ for (const file of files) { try { const content = fs.readFileSync(file, "utf8"); const data = yaml.load(content); + checkKeys(data, file); + + parsedFiles.push({ + file, + data + }); } catch (err) { console.error(`❌ Erreur YAML dans ${file}`); console.error(err.message); @@ -49,4 +56,8 @@ if (hasError) { process.exit(1); } -console.log("✅ Tous les fichiers YAML sont valides et conformes"); +/** + * OUTPUT FINAL + * Tu peux le parser dans un autre step GitHub Actions + */ +console.log(JSON.stringify(parsedFiles, null, 2));