Skip to content

Added docstrings to Calibration screen, and deleted redundant imports #4

Added docstrings to Calibration screen, and deleted redundant imports

Added docstrings to Calibration screen, and deleted redundant imports #4

Workflow file for this run

name: Test Suite
on:
pull_request:
branches:
- main
- master
- develop
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Run tests with coverage
id: run-tests
run: |
set +e
npm run test:ci 2>&1 | tee test-output.txt
TEST_EXIT_CODE=$?
set -e
# Extract test results - look for "Tests: X passed, Y total" pattern
if grep -q "Tests:" test-output.txt; then
PASSED_TESTS=$(grep "Tests:" test-output.txt | grep -oE '[0-9]+ passed' | grep -oE '[0-9]+' | tail -1 || echo "0")
TOTAL_TESTS=$(grep "Tests:" test-output.txt | grep -oE '[0-9]+ total' | grep -oE '[0-9]+' | tail -1 || echo "0")
else
PASSED_TESTS="0"
TOTAL_TESTS="0"
fi
echo "Total Tests: $TOTAL_TESTS"
echo "Passed: $PASSED_TESTS"
echo "test_exit_code=$TEST_EXIT_CODE" >> $GITHUB_OUTPUT
echo "passed=$PASSED_TESTS" >> $GITHUB_OUTPUT
echo "total=$TOTAL_TESTS" >> $GITHUB_OUTPUT
if [ "$TOTAL_TESTS" -gt "0" ] && [ "$PASSED_TESTS" -gt "0" ]; then
PASS_RATE=$(awk "BEGIN {printf \"%.2f\", ($PASSED_TESTS / $TOTAL_TESTS) * 100}")
echo "Pass Rate: $PASS_RATE%"
echo "pass_rate=$PASS_RATE" >> $GITHUB_OUTPUT
# Check if pass rate is >= 90%
PASS_CHECK=$(awk "BEGIN {print ($PASS_RATE >= 90) ? 1 : 0}")
if [ "$PASS_CHECK" -eq "1" ]; then
echo "✅ Quality gate passed! Pass rate: $PASS_RATE%"
else
echo "❌ Quality gate failed! Pass rate: $PASS_RATE% (required: 90%)"
exit 1
fi
else
# If we can't determine test count, use exit code
if [ $TEST_EXIT_CODE -eq 0 ]; then
echo "✅ All tests passed!"
else
echo "❌ Tests failed!"
exit 1
fi
fi
env:
CI: true
REACT_APP_FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }}
REACT_APP_FIREBASE_AUTH_DOMAIN: ${{ secrets.FIREBASE_AUTH_DOMAIN }}
REACT_APP_FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
REACT_APP_FIREBASE_STORAGE_BUCKET: ${{ secrets.FIREBASE_STORAGE_BUCKET }}
REACT_APP_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.FIREBASE_MESSAGING_SENDER_ID }}
REACT_APP_FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }}
REACT_APP_FIREBASE_MEASUREMENT_ID: ${{ secrets.FIREBASE_MEASUREMENT_ID }}
- name: Upload coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report-${{ matrix.node-version }}
path: coverage/
retention-days: 7
# This job aggregates test results and blocks merge if < 90% pass rate
quality-gate:
name: Quality Gate Check
runs-on: ubuntu-latest
needs: test
if: always()
steps:
- name: Check test results
run: |
if [ "${{ needs.test.result }}" == "failure" ]; then
echo "❌ Tests did not pass the 90% threshold. Merge is blocked."
exit 1
elif [ "${{ needs.test.result }}" == "cancelled" ]; then
echo "⚠️ Tests were cancelled."
exit 1
fi
echo "✅ All quality gates passed. Ready to merge!"