Skip to content

Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int… #7

Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…

Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int… #7

name: Performance Test
on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]
workflow_dispatch: # Enables manual triggering
schedule:
- cron: '0 2 * * *' # Runs daily at 2 AM UTC
jobs:
performance:
name: "Performance Test"
runs-on: ubuntu-latest
timeout-minutes: 60 # Set a timeout to prevent jobs from running indefinitely
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade -r requirements.txt
python -m pip install .
- name: Run Performance Test
run: |
export PYTHONPATH=$PYTHONPATH:$PWD/
echo "Running performance test for term info queries..."
python -m unittest -v src.test.term_info_queries_test.TermInfoQueriesTest.test_term_info_performance 2>&1 | tee performance_test_output.log
continue-on-error: true # Continue even if performance thresholds are exceeded
- name: Create Performance Report
if: always() # Always run this step, even if the test fails
run: |
# Create performance.md file
cat > performance.md << 'EOF'
# VFBquery Performance Test Results
**Test Date:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')
**Git Commit:** ${{ github.sha }}
**Branch:** ${{ github.ref_name }}
**Workflow Run:** ${{ github.run_id }}
## Test Overview
This performance test measures the execution time of VFB term info queries for specific terms:
- **FBbt_00003748**: mushroom body (anatomical class)
- **VFB_00101567**: individual anatomy data
## Performance Thresholds
- Maximum single query time: 5 minutes (300 seconds)
- Maximum total time for both queries: 7.5 minutes (450 seconds)
## Test Results
```
$(cat performance_test_output.log)
```
## Summary
EOF
# Extract timing information from the test output
if grep -q "Performance Test Results:" performance_test_output.log; then
echo "✅ **Test Status**: Performance test completed" >> performance.md
echo "" >> performance.md
# Extract timing data
if grep -q "FBbt_00003748 query took:" performance_test_output.log; then
TIMING1=$(grep "FBbt_00003748 query took:" performance_test_output.log | sed 's/.*took: \([0-9.]*\) seconds.*/\1/')
echo "- **FBbt_00003748 Query Time**: ${TIMING1} seconds" >> performance.md
fi
if grep -q "VFB_00101567 query took:" performance_test_output.log; then
TIMING2=$(grep "VFB_00101567 query took:" performance_test_output.log | sed 's/.*took: \([0-9.]*\) seconds.*/\1/')
echo "- **VFB_00101567 Query Time**: ${TIMING2} seconds" >> performance.md
fi
if grep -q "Total time for both queries:" performance_test_output.log; then
TOTAL_TIME=$(grep "Total time for both queries:" performance_test_output.log | sed 's/.*queries: \([0-9.]*\) seconds.*/\1/')
echo "- **Total Query Time**: ${TOTAL_TIME} seconds" >> performance.md
fi
# Check if test passed or failed
if grep -q "OK" performance_test_output.log; then
echo "" >> performance.md
echo "🎉 **Result**: All performance thresholds met!" >> performance.md
elif grep -q "FAILED" performance_test_output.log; then
echo "" >> performance.md
echo "⚠️ **Result**: Some performance thresholds exceeded or test failed" >> performance.md
fi
else
echo "❌ **Test Status**: Performance test failed to run properly" >> performance.md
fi
echo "" >> performance.md
echo "---" >> performance.md
echo "*Last updated: $(date -u '+%Y-%m-%d %H:%M:%S UTC')*" >> performance.md
# Also add to GitHub step summary
echo "## Performance Test Report" >> $GITHUB_STEP_SUMMARY
echo "Performance results have been saved to performance.md" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
cat performance.md >> $GITHUB_STEP_SUMMARY
- name: Commit Performance Report
if: always()
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add performance.md
git diff --staged --quiet || git commit -m "Update performance test results [skip ci]"
- name: Push Performance Report
if: always()
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}