chore: add verify test #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Verify manifest | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
branches: [ "main" ] | |
paths: | |
- 'manifests/resources.json' | |
workflow_dispatch: | |
jobs: | |
verify_manifest: | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '14' | |
- name: Install dependencies | |
run: npm install axios | |
- name: Verify attributes & file paths | |
run: | | |
node -e " | |
const fs = require('fs'); | |
const axios = require('axios'); | |
const resources = JSON.parse(fs.readFileSync('manifests/resources.json', 'utf8')); | |
const requiredFields = ['id', 'name', 'version', 'source', 'qcmaInstaller', 'subscriptionTypes', 'requiredRoles']; | |
let allValid = true; | |
resources.forEach(resource => { | |
requiredFields.forEach(field => { | |
if (!resource.hasOwnProperty(field)) { | |
console.error(\`Missing field \${field} in resource \${JSON.stringify(resource)}\`); | |
allValid = false; | |
} | |
}); | |
}); | |
if (!allValid) { | |
process.exit(1); | |
} | |
const checkSource = async (url) => { | |
try { | |
await axios.head(url); | |
} catch (error) { | |
console.error(\`Source URL not found: \${url}\`); | |
process.exit(1); | |
} | |
}; | |
const promises = resources.map(resource => checkSource(resource.source)); | |
Promise.all(promises).then(() => { | |
console.log('All checks passed.'); | |
}).catch(() => { | |
process.exit(1); | |
}); | |
" |