From b6c87d7c173c4090f6164f74215a832a964f2160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Pereira?= Date: Tue, 3 Dec 2024 09:55:45 +0000 Subject: [PATCH] Create validate-unique-ids.yml --- .github/workflows/validate-unique-ids.yml | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/validate-unique-ids.yml diff --git a/.github/workflows/validate-unique-ids.yml b/.github/workflows/validate-unique-ids.yml new file mode 100644 index 0000000..0b9f9d5 --- /dev/null +++ b/.github/workflows/validate-unique-ids.yml @@ -0,0 +1,37 @@ +name: Validate Unique Component IDs + +on: + push: + paths: + - 'hondaecucomponents.json' + pull_request: + paths: + - 'hondaecucomponents.json' + +jobs: + validate-ids: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Validate Unique IDs + run: | + node -e " + const fs = require('fs'); + const data = JSON.parse(fs.readFileSync('hondaecucomponents.json', 'utf8')); + const duplicates = data.components.flatMap(component => component.ids).filter((id, index, self) => self.indexOf(id) !== index); + + if (duplicates.length > 0) { + console.error('Validation Failed: Duplicate IDs found:', duplicates); + process.exit(1); + } + + console.log('Validation Passed: All IDs are unique.'); + " \ No newline at end of file