Add initial partner driver testing github action #73
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: Check Driver Urls | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
jobs: | |
check-urls: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: lts/Iron # 20.x.x | |
- run: npm install yaml | |
- name: parse drivers registry | |
uses: actions/github-script@v7 | |
id: drivers_registry_urls | |
with: | |
script: | # js | |
const { parse } = require('yaml'); | |
const fs = require('fs'); | |
const registry = parse(fs.readFileSync('registry.yaml', 'utf8')); | |
const drivers = registry.drivers; | |
const majorVersion = '${{ steps.major_version.outputs.major_version }}'; | |
const urls = []; | |
for (const driver of drivers) { | |
const driverName = driver.name; | |
const driverDeps = driver.deps; | |
for (const versionName of Object.keys(driver.versions)) { | |
urls.push({ | |
description: `${driverName}-${versionName}`, | |
url: driver.versions[versionName], | |
}); | |
} | |
if (driverDeps) { | |
driverDeps.forEach(dep => { | |
urls.push({ | |
description: `${driverName}-dep`, | |
url: dep, | |
}); | |
}); | |
} | |
} | |
console.log(urls); | |
return urls; | |
- name: check urls | |
uses: actions/github-script@v7 | |
with: | |
script: | # js | |
const urls = JSON.parse(`${{ steps.drivers_registry_urls.outputs.result }}`); | |
const failedUrls = []; | |
await Promise.all(urls.map(({ description, url }) => { | |
return fetch(url) | |
.then((response) => { | |
if (!response.ok) { | |
console.log(`❌ Failed to fetch ${description}`); | |
failedUrls.push({ description, url }); | |
} else { | |
console.log(`✅ Successfully fetched ${description}`); | |
} | |
}).catch((error) => { | |
console.log(`❌ Failed to fetch ${description}: ${error}`); | |
failedUrls.push({ description, url }); | |
}); | |
})); | |
if (failedUrls.length > 0) { | |
console.log('\n\n❌ Failed urls:', failedUrls); | |
process.exit(1); | |
} | |
console.log(`\n\n✅ Successfully fetched all urls`); | |
process.exit(0); | |