Skip to content

Enrich dataset to v2.0.0 with per-site research data #2

Enrich dataset to v2.0.0 with per-site research data

Enrich dataset to v2.0.0 with per-site research data #2

Workflow file for this run

name: Validate Data
on:
pull_request:
paths:
- 'data/datacenters.json'
push:
branches:
- main
paths:
- 'data/datacenters.json'
jobs:
validate:
runs-on: ubuntu-latest
name: Validate datacenters.json
# No user-controlled inputs are used in any run: steps - safe from injection
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install ajv-cli
run: npm install -g ajv-cli@5.0.0
- name: Validate JSON schema
run: ajv validate -s schema/datacenter.schema.json -d "data/datacenters.json#/datacenters/*" --strict=false
- name: Check for duplicate IDs
run: |
node -e "
const data = require('./data/datacenters.json');
const ids = data.datacenters.map(d => d.id);
const dupes = ids.filter((id, i) => ids.indexOf(id) !== i);
if (dupes.length) { console.error('Duplicate IDs:', dupes); process.exit(1); }
console.log('All ' + ids.length + ' IDs unique. OK.');
"
- name: Check coordinate bounds
run: |
node -e "
const data = require('./data/datacenters.json');
const errors = [];
data.datacenters.forEach(d => {
if (d.lat < -90 || d.lat > 90) errors.push('Bad lat id=' + d.id);
if (d.lng < -180 || d.lng > 180) errors.push('Bad lng id=' + d.id);
});
if (errors.length) { console.error(errors.join('\n')); process.exit(1); }
console.log('All coordinates valid. OK.');
"
- name: Check totalCount matches array length
run: |
node -e "
const data = require('./data/datacenters.json');
const actual = data.datacenters.length;
if (data.totalCount !== actual) {
console.error('totalCount (' + data.totalCount + ') != array length (' + actual + ')');
process.exit(1);
}
console.log('totalCount matches: ' + actual + '. OK.');
"
- name: Print summary
run: |
node -e "
const data = require('./data/datacenters.json');
const regions = {};
data.datacenters.forEach(d => regions[d.region] = (regions[d.region] || 0) + 1);
console.log('Total:', data.datacenters.length);
Object.entries(regions).forEach(([r, n]) => console.log(' ', r + ':', n));
"