Skip to content

Add Data Format Validation CI/CD Workflow #896

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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/bfcl_data-format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
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
sudo apt-get update
sudo apt-get install -y jq

- 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
# Escape the content and store it as a single line
content=$(cat validation_results.json | jq -c .)
echo "results=${content}" >> $GITHUB_OUTPUT
else
echo "results={\"all_success\":false,\"results\":[]}" >> $GITHUB_OUTPUT
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(steps.process_results.outputs.results).all_success && '✅ All data files are correctly formatted!' || '❌ Data format validation failed!' }}

${{ !fromJson(steps.process_results.outputs.results).all_success && '### Failed Validations:' || '' }}
${{ join(fromJson(steps.process_results.outputs.results).results, '\n') }}

${{ !fromJson(steps.process_results.outputs.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(steps.process_results.outputs.results).all_success != true
run: exit 1
Loading