Files
libretro/.github/workflows/validate.yml
Abdessamad Derraz af74fffa14 refactor: fix code review findings across all scripts
Critical: stream large file downloads (OOM fix), fix basename match
in auto_fetch, include hashes in pack grouping fingerprint, handle
not_in_zip status in verify, fix escaped quotes in batocera parser.

Important: deduplicate shared group includes, catch coreinfo network
errors, fix NODEDUP path component match, fix CI word splitting on
spaces, replace bare except Exception in 3 files.

Minor: argparse in list_platforms, specific exceptions in download.py.
2026-03-17 15:16:51 +01:00

150 lines
4.2 KiB
YAML

name: PR Validation
on:
pull_request:
paths:
- "bios/**"
- "platforms/**"
permissions:
contents: read
pull-requests: write
concurrency:
group: validate-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
validate-bios:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install dependencies
run: pip install pyyaml
- name: Get changed BIOS files
id: changed
run: |
files=$(git diff --name-only ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} | grep '^bios/' || true)
echo "files=$files" >> "$GITHUB_OUTPUT"
echo "$files" > /tmp/changed_files.txt
- name: Validate BIOS files
id: validate
run: |
if [ -s /tmp/changed_files.txt ]; then
xargs python scripts/validate_pr.py --markdown < /tmp/changed_files.txt > /tmp/report.md 2>&1 || true
else
echo "No BIOS files changed" > /tmp/report.md
fi
- name: Post validation report
uses: actions/github-script@v8
with:
script: |
const fs = require('fs');
const report = fs.readFileSync('/tmp/report.md', 'utf8');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: report
});
validate-configs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install dependencies
run: pip install pyyaml jsonschema
- name: Validate platform configs
run: |
python -c "
import json, yaml, sys
from jsonschema import validate, ValidationError
from pathlib import Path
with open('schemas/platform.schema.json') as f:
schema = json.load(f)
errors = []
for yml_file in Path('platforms').glob('*.yml'):
if yml_file.name.startswith('_'):
continue
with open(yml_file) as f:
config = yaml.safe_load(f)
try:
validate(config, schema)
print(f'✅ {yml_file.name}')
except ValidationError as e:
errors.append(f'{yml_file.name}: {e.message}')
print(f'❌ {yml_file.name}: {e.message}')
if errors:
sys.exit(1)
"
label-pr:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Auto-label PR
uses: actions/github-script@v8
with:
script: |
const { data: files } = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
const labels = new Set();
for (const file of files) {
if (file.filename.startsWith('bios/')) {
labels.add('bios');
// Extract system from path
const parts = file.filename.split('/');
if (parts.length >= 3) {
labels.add(`system:${parts[1].toLowerCase()}`);
}
}
if (file.filename.startsWith('platforms/')) {
labels.add('platform-config');
}
if (file.filename.startsWith('scripts/')) {
labels.add('automation');
}
}
if (labels.size > 0) {
try {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: [...labels],
});
} catch (e) {
console.log('Could not add labels:', e.message);
}
}