Merge dev to main: Security improvements and comprehensive test infrastructure #39
+17
-121
@@ -10,129 +10,48 @@ jobs:
|
||||
backend-tests:
|
||||
name: Backend Tests
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: dashboard/backend
|
||||
container:
|
||||
image: python:3.12-slim
|
||||
env:
|
||||
SECRET_KEY: test-secret-key-for-ci-environment-32chars-minimum
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
cd dashboard/backend
|
||||
pip install -r requirements.txt
|
||||
pip install -r requirements-dev.txt
|
||||
pip install pytest-timeout
|
||||
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
pytest tests/unit/ -v --timeout=30 -x 2>&1 | tee unit-test-output.txt
|
||||
echo "UNIT_TEST_EXIT_CODE=${PIPESTATUS[0]}" >> $GITHUB_ENV
|
||||
continue-on-error: true
|
||||
cd dashboard/backend
|
||||
pytest tests/unit/ -v --timeout=30 -x
|
||||
echo "✅ Unit tests passed"
|
||||
|
||||
- name: Run integration tests
|
||||
run: |
|
||||
pytest tests/integration/ -v --timeout=30 -x 2>&1 | tee integration-test-output.txt
|
||||
echo "INTEGRATION_TEST_EXIT_CODE=${PIPESTATUS[0]}" >> $GITHUB_ENV
|
||||
continue-on-error: true
|
||||
|
||||
- name: Display test results
|
||||
if: always()
|
||||
run: |
|
||||
echo "## Backend Test Results" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### Unit Tests (Exit Code: ${UNIT_TEST_EXIT_CODE:-N/A})" >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
tail -50 unit-test-output.txt >> $GITHUB_STEP_SUMMARY 2>/dev/null || echo "No unit test output" >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### Integration Tests (Exit Code: ${INTEGRATION_TEST_EXIT_CODE:-N/A})" >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
tail -50 integration-test-output.txt >> $GITHUB_STEP_SUMMARY 2>/dev/null || echo "No integration test output" >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
- name: Check test results
|
||||
if: always()
|
||||
run: |
|
||||
if [ "${UNIT_TEST_EXIT_CODE:-1}" != "0" ] || [ "${INTEGRATION_TEST_EXIT_CODE:-1}" != "0" ]; then
|
||||
echo "❌ Backend tests failed"
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ All backend tests passed"
|
||||
|
||||
- name: Upload backend coverage report
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: backend-coverage
|
||||
path: dashboard/backend/htmlcov/
|
||||
|
||||
- name: Upload backend coverage XML
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: backend-coverage-xml
|
||||
path: dashboard/backend/coverage.xml
|
||||
cd dashboard/backend
|
||||
pytest tests/integration/ -v --timeout=30 -x
|
||||
echo "✅ Integration tests passed"
|
||||
|
||||
frontend-tests:
|
||||
name: Frontend Tests
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: dashboard/frontend
|
||||
container:
|
||||
image: node:20-slim
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: dashboard/frontend/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Run tests with coverage
|
||||
run: |
|
||||
npm run test:coverage -- --reporter=verbose --run 2>&1 | tee test-output.txt
|
||||
echo "FRONTEND_TEST_EXIT_CODE=${PIPESTATUS[0]}" >> $GITHUB_ENV
|
||||
continue-on-error: true
|
||||
cd dashboard/frontend
|
||||
npm ci
|
||||
|
||||
- name: Display test results
|
||||
if: always()
|
||||
- name: Run tests
|
||||
run: |
|
||||
echo "## Frontend Test Results" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### Test Output (Exit Code: ${FRONTEND_TEST_EXIT_CODE:-N/A})" >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
tail -50 test-output.txt >> $GITHUB_STEP_SUMMARY 2>/dev/null || echo "No test output" >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
- name: Check test results
|
||||
if: always()
|
||||
run: |
|
||||
if [ "${FRONTEND_TEST_EXIT_CODE:-1}" != "0" ]; then
|
||||
echo "❌ Frontend tests failed"
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ All frontend tests passed"
|
||||
|
||||
- name: Upload frontend coverage report
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: frontend-coverage
|
||||
path: dashboard/frontend/coverage/
|
||||
cd dashboard/frontend
|
||||
npm run test:coverage -- --reporter=verbose --run
|
||||
echo "✅ Frontend tests passed"
|
||||
|
||||
test-summary:
|
||||
name: Test Summary
|
||||
@@ -151,26 +70,3 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ All tests passed"
|
||||
|
||||
- name: Download backend coverage
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: backend-coverage-xml
|
||||
path: ./backend-coverage
|
||||
continue-on-error: true
|
||||
|
||||
- name: Download frontend coverage
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: frontend-coverage
|
||||
path: ./frontend-coverage
|
||||
continue-on-error: true
|
||||
|
||||
- name: Test Summary
|
||||
run: |
|
||||
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "✅ Backend tests passed" >> $GITHUB_STEP_SUMMARY
|
||||
echo "✅ Frontend tests passed" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "Coverage reports uploaded as artifacts." >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
Reference in New Issue
Block a user