Skip to content

Commit

Permalink
Create validate-unique-ids.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
VIRUXE committed Dec 3, 2024
1 parent 8573d2b commit b6c87d7
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/validate-unique-ids.yml
Original file line number Diff line number Diff line change
@@ -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.');
"

0 comments on commit b6c87d7

Please sign in to comment.