Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Data Format Validation CI/CD Workflow #896

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
63 changes: 63 additions & 0 deletions .github/workflows/bfcl_data-format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: BFCL Data Format Check

on:
pull_request:
branches: [ main ]
paths:
- 'berkeley-function-call-leaderboard/data/**/*.json'

jobs:
check-data-format:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install jsonschema

- name: Run format validation
id: validate
run: python berkeley-function-call-leaderboard/scripts/validate_data_format.py

- name: Process validation results
id: process_results
if: always()
run: |
if [ -f validation_results.json ]; then
echo "VALIDATION_RESULTS<<EOF" >> $GITHUB_ENV
echo "$(cat validation_results.json)" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
fi

- name: Comment on PR with results
if: github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
## BFCL Data Format Check Results

${{ fromJson(env.VALIDATION_RESULTS).all_success && '✅ All data files are correctly formatted!' || '❌ Data format validation failed!' }}

### Summary
- Total files checked: ${{ length(fromJson(env.VALIDATION_RESULTS).results) }}
${{ !fromJson(env.VALIDATION_RESULTS).all_success && '### Failed Validations:' || '' }}
${{ !fromJson(env.VALIDATION_RESULTS).all_success && join(fromJson(env.VALIDATION_RESULTS).results.*.errors, '
') || '' }}

${{ !fromJson(env.VALIDATION_RESULTS).all_success && '### How to fix:
1. Review the errors above for each failed file
2. Ensure all data entries follow the required format for their respective types
3. Update the files and push the changes' || '' }}

- name: Fail if validation failed
if: fromJson(env.VALIDATION_RESULTS).all_success != true
run: exit 1
Loading