Files
libretro/.github/workflows/validate.yml
Abdessamad Derraz ebb55a445b feat: re-profile 40 emulators, harden CI workflows
profile emulators pd777 through tic80, add frozen snapshots
(puae2021, snes9x2002/2005/2010, stella2014/2023).

CI: replace github-script with gh CLI, add test execution,
job-level permissions, propagate changed output, pin jsonschema.
2026-03-25 07:00:17 +01:00

144 lines
3.9 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
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
files=$(git diff --name-only "$BASE_SHA"..."$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
if: always()
run: |
gh pr comment "${{ github.event.pull_request.number }}" --body-file /tmp/report.md
env:
GH_TOKEN: ${{ github.token }}
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==4.23.0
- 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'OK {yml_file.name}')
except ValidationError as e:
errors.append(f'{yml_file.name}: {e.message}')
print(f'FAIL {yml_file.name}: {e.message}')
if errors:
sys.exit(1)
"
run-tests:
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
- name: Run test suite
run: python -m unittest tests.test_e2e -v
label-pr:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Auto-label PR
run: |
labels=""
files=$(gh pr diff "${{ github.event.pull_request.number }}" --name-only)
if echo "$files" | grep -q '^bios/'; then
labels="$labels bios"
for sys in $(echo "$files" | grep '^bios/' | cut -d/ -f2 | sort -u); do
labels="$labels system:$(echo "$sys" | tr '[:upper:]' '[:lower:]')"
done
fi
if echo "$files" | grep -q '^platforms/'; then
labels="$labels platform-config"
fi
if echo "$files" | grep -q '^scripts/'; then
labels="$labels automation"
fi
for label in $labels; do
gh pr edit "${{ github.event.pull_request.number }}" --add-label "$label" 2>/dev/null || true
done
env:
GH_TOKEN: ${{ github.token }}