Skip to content

Commit 07ca7f2

Browse files
authored
Merge branch 'development' into python-backend-cleanup
2 parents 2b71ff3 + d21db80 commit 07ca7f2

File tree

29 files changed

+2173
-284
lines changed

29 files changed

+2173
-284
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Generate Test Summary from Jest JSON Output
5+
# Usage: ./generate-test-summary-jest.sh <path-to-jest-json-file>
6+
7+
JSON_FILE="${1:-test-results.json}"
8+
9+
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
10+
echo "" >> $GITHUB_STEP_SUMMARY
11+
12+
# Parse test results from Jest JSON output
13+
if [ -f "$JSON_FILE" ]; then
14+
# Extract test counts using jq or grep/sed
15+
# Jest JSON structure: { "numTotalTests": N, "numPassedTests": N, "numFailedTests": N, "numPendingTests": N, ... }
16+
17+
if command -v jq &> /dev/null; then
18+
# Use jq if available (preferred)
19+
total_tests=$(jq -r '.numTotalTests // 0' "$JSON_FILE")
20+
passed=$(jq -r '.numPassedTests // 0' "$JSON_FILE")
21+
failed=$(jq -r '.numFailedTests // 0' "$JSON_FILE")
22+
skipped=$(jq -r '.numPendingTests // 0' "$JSON_FILE")
23+
24+
# Extract failed test details
25+
failed_tests_file=$(mktemp)
26+
jq -r '.testResults[]? | select(.status == "failed") | .assertionResults[]? | select(.status == "failed") | "\(.ancestorTitles | join(" > ")) > \(.title)"' "$JSON_FILE" > "$failed_tests_file" 2>/dev/null || true
27+
else
28+
# Fallback to grep/sed if jq is not available
29+
total_tests=$(grep -oP '"numTotalTests":\s*\K[0-9]+' "$JSON_FILE" | head -1)
30+
passed=$(grep -oP '"numPassedTests":\s*\K[0-9]+' "$JSON_FILE" | head -1)
31+
failed=$(grep -oP '"numFailedTests":\s*\K[0-9]+' "$JSON_FILE" | head -1)
32+
skipped=$(grep -oP '"numPendingTests":\s*\K[0-9]+' "$JSON_FILE" | head -1)
33+
34+
# Extract failed test names (basic extraction without jq)
35+
failed_tests_file=$(mktemp)
36+
grep -oP '"fullName":\s*"\K[^"]*' "$JSON_FILE" | while read -r line; do
37+
if echo "$line" | grep -q "failed"; then
38+
echo "$line" >> "$failed_tests_file"
39+
fi
40+
done 2>/dev/null || true
41+
fi
42+
43+
# Default to 0 if values are empty
44+
total_tests=${total_tests:-0}
45+
passed=${passed:-0}
46+
failed=${failed:-0}
47+
skipped=${skipped:-0}
48+
49+
echo "| Status | Count |" >> $GITHUB_STEP_SUMMARY
50+
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
51+
echo "| ✅ Passed | $passed |" >> $GITHUB_STEP_SUMMARY
52+
echo "| ❌ Failed | $failed |" >> $GITHUB_STEP_SUMMARY
53+
echo "| ⏭️ Skipped | $skipped |" >> $GITHUB_STEP_SUMMARY
54+
echo "| **Total** | **$total_tests** |" >> $GITHUB_STEP_SUMMARY
55+
echo "" >> $GITHUB_STEP_SUMMARY
56+
57+
# List failed tests if any
58+
if [ "$failed" -gt 0 ]; then
59+
echo "### ❌ Failed Tests" >> $GITHUB_STEP_SUMMARY
60+
echo "" >> $GITHUB_STEP_SUMMARY
61+
62+
if [ -s "$failed_tests_file" ]; then
63+
while IFS= read -r test; do
64+
echo "- \`$test\`" >> $GITHUB_STEP_SUMMARY
65+
done < "$failed_tests_file"
66+
else
67+
echo "_Unable to parse individual test names_" >> $GITHUB_STEP_SUMMARY
68+
fi
69+
70+
echo "" >> $GITHUB_STEP_SUMMARY
71+
echo "❌ **Tests failed!**" >> $GITHUB_STEP_SUMMARY
72+
rm -f "$failed_tests_file"
73+
exit 1
74+
else
75+
echo "✅ **All tests passed!**" >> $GITHUB_STEP_SUMMARY
76+
fi
77+
78+
rm -f "$failed_tests_file"
79+
else
80+
echo "⚠️ No test results found at: $JSON_FILE" >> $GITHUB_STEP_SUMMARY
81+
exit 1
82+
fi
83+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Generate Test Summary from Pytest JUnit XML Output
5+
# Usage: ./generate-test-summary-pytest.sh <path-to-junit-xml>
6+
7+
XML_FILE="${1:-test-results.xml}"
8+
9+
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
10+
echo "" >> $GITHUB_STEP_SUMMARY
11+
12+
# Parse test results from JUnit XML
13+
if [ -f "$XML_FILE" ]; then
14+
# Extract test counts from XML
15+
# JUnit XML structure: <testsuite tests="N" failures="N" errors="N" skipped="N">
16+
17+
tests=$(grep -oP 'tests="\K[0-9]+' "$XML_FILE" | head -1)
18+
failures=$(grep -oP 'failures="\K[0-9]+' "$XML_FILE" | head -1)
19+
errors=$(grep -oP 'errors="\K[0-9]+' "$XML_FILE" | head -1)
20+
skipped=$(grep -oP 'skipped="\K[0-9]+' "$XML_FILE" | head -1)
21+
22+
# Default to 0 if values are empty
23+
tests=${tests:-0}
24+
failures=${failures:-0}
25+
errors=${errors:-0}
26+
skipped=${skipped:-0}
27+
28+
passed=$((tests - failures - errors - skipped))
29+
30+
echo "| Status | Count |" >> $GITHUB_STEP_SUMMARY
31+
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
32+
echo "| ✅ Passed | $passed |" >> $GITHUB_STEP_SUMMARY
33+
echo "| ❌ Failed | $((failures + errors)) |" >> $GITHUB_STEP_SUMMARY
34+
echo "| ⏭️ Skipped | $skipped |" >> $GITHUB_STEP_SUMMARY
35+
echo "| **Total** | **$tests** |" >> $GITHUB_STEP_SUMMARY
36+
echo "" >> $GITHUB_STEP_SUMMARY
37+
38+
# List failed tests if any
39+
if [ $((failures + errors)) -gt 0 ]; then
40+
echo "### ❌ Failed Tests" >> $GITHUB_STEP_SUMMARY
41+
echo "" >> $GITHUB_STEP_SUMMARY
42+
43+
# Extract failed test names from XML
44+
failed_tests_file=$(mktemp)
45+
46+
# Find testcase elements with failure or error children
47+
grep -oP '<testcase[^>]*classname="[^"]*"[^>]*name="[^"]*"[^>]*>.*?<(failure|error)' "$XML_FILE" | \
48+
grep -oP 'classname="\K[^"]*|name="\K[^"]*' | \
49+
paste -d '.' - - >> "$failed_tests_file" 2>/dev/null || true
50+
51+
if [ -s "$failed_tests_file" ]; then
52+
while IFS= read -r test; do
53+
echo "- \`$test\`" >> $GITHUB_STEP_SUMMARY
54+
done < "$failed_tests_file"
55+
else
56+
echo "_Unable to parse individual test names_" >> $GITHUB_STEP_SUMMARY
57+
fi
58+
59+
echo "" >> $GITHUB_STEP_SUMMARY
60+
echo "❌ **Tests failed!**" >> $GITHUB_STEP_SUMMARY
61+
rm -f "$failed_tests_file"
62+
exit 1
63+
else
64+
echo "✅ **All tests passed!**" >> $GITHUB_STEP_SUMMARY
65+
fi
66+
else
67+
echo "⚠️ No test results found at: $XML_FILE" >> $GITHUB_STEP_SUMMARY
68+
exit 1
69+
fi
70+
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Generate Test Summary from Maven Surefire Reports
5+
# Usage: ./generate-test-summary-surefire.sh <path-to-surefire-reports>
6+
7+
REPORTS_DIR="${1:-target/surefire-reports}"
8+
9+
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
10+
echo "" >> $GITHUB_STEP_SUMMARY
11+
12+
# Parse test results from Surefire reports
13+
if [ -d "$REPORTS_DIR" ]; then
14+
total_tests=0
15+
failures=0
16+
errors=0
17+
skipped=0
18+
failed_tests_file=$(mktemp)
19+
20+
for file in "$REPORTS_DIR"/TEST-*.xml; do
21+
if [ -f "$file" ]; then
22+
# Extract test counts from XML
23+
tests=$(grep -oP 'tests="\K[0-9]+' "$file" | head -1)
24+
fails=$(grep -oP 'failures="\K[0-9]+' "$file" | head -1)
25+
errs=$(grep -oP 'errors="\K[0-9]+' "$file" | head -1)
26+
skip=$(grep -oP 'skipped="\K[0-9]+' "$file" | head -1)
27+
28+
total_tests=$((total_tests + ${tests:-0}))
29+
failures=$((failures + ${fails:-0}))
30+
errors=$((errors + ${errs:-0}))
31+
skipped=$((skipped + ${skip:-0}))
32+
33+
# Extract failed test cases
34+
if [ "${fails:-0}" -gt 0 ] || [ "${errs:-0}" -gt 0 ]; then
35+
classname=$(basename "$file" .xml | sed 's/^TEST-//')
36+
37+
# Find failed testcases (with failure or error elements)
38+
grep -oP '<testcase[^>]*name="[^"]*"[^>]*>.*?<(failure|error)' "$file" | \
39+
grep -oP 'name="\K[^"]*' | while read -r testname; do
40+
echo "$classname.$testname" >> "$failed_tests_file"
41+
done
42+
fi
43+
fi
44+
done
45+
46+
passed=$((total_tests - failures - errors - skipped))
47+
48+
echo "| Status | Count |" >> $GITHUB_STEP_SUMMARY
49+
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
50+
echo "| ✅ Passed | $passed |" >> $GITHUB_STEP_SUMMARY
51+
echo "| ❌ Failed | $((failures + errors)) |" >> $GITHUB_STEP_SUMMARY
52+
echo "| ⏭️ Skipped | $skipped |" >> $GITHUB_STEP_SUMMARY
53+
echo "| **Total** | **$total_tests** |" >> $GITHUB_STEP_SUMMARY
54+
echo "" >> $GITHUB_STEP_SUMMARY
55+
56+
# List failed tests if any
57+
if [ $((failures + errors)) -gt 0 ]; then
58+
echo "### ❌ Failed Tests" >> $GITHUB_STEP_SUMMARY
59+
echo "" >> $GITHUB_STEP_SUMMARY
60+
61+
if [ -s "$failed_tests_file" ]; then
62+
while IFS= read -r test; do
63+
echo "- \`$test\`" >> $GITHUB_STEP_SUMMARY
64+
done < "$failed_tests_file"
65+
else
66+
echo "_Unable to parse individual test names_" >> $GITHUB_STEP_SUMMARY
67+
fi
68+
69+
echo "" >> $GITHUB_STEP_SUMMARY
70+
echo "❌ **Tests failed!**" >> $GITHUB_STEP_SUMMARY
71+
rm -f "$failed_tests_file"
72+
exit 1
73+
else
74+
echo "✅ **All tests passed!**" >> $GITHUB_STEP_SUMMARY
75+
fi
76+
77+
rm -f "$failed_tests_file"
78+
else
79+
echo "⚠️ No test results found at: $REPORTS_DIR" >> $GITHUB_STEP_SUMMARY
80+
exit 1
81+
fi
82+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Run Express Tests
2+
3+
on:
4+
pull_request_target:
5+
branches:
6+
- development
7+
push:
8+
branches:
9+
- development
10+
11+
jobs:
12+
test:
13+
name: Run Express Tests
14+
runs-on: ubuntu-latest
15+
# Require manual approval for fork PRs
16+
environment: testing
17+
18+
defaults:
19+
run:
20+
working-directory: server/express
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v5
25+
with:
26+
ref: ${{ github.event.pull_request.head.sha }}
27+
28+
- name: Set up Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: '20'
32+
33+
- name: Install dependencies
34+
run: npm install
35+
36+
- name: Run tests
37+
run: npm test -- --json --outputFile=test-results.json || true
38+
env:
39+
MONGODB_URI: ${{ secrets.MFLIX_URI }}
40+
41+
- name: Upload test results
42+
uses: actions/upload-artifact@v4
43+
if: always()
44+
with:
45+
name: test-results
46+
path: |
47+
server/express/coverage/
48+
server/express/test-results.json
49+
retention-days: 30
50+
51+
- name: Generate Test Summary
52+
if: always()
53+
working-directory: .
54+
run: |
55+
chmod +x .github/scripts/generate-test-summary-jest.sh
56+
.github/scripts/generate-test-summary-jest.sh server/express/test-results.json
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Run Java Spring Boot Tests
2+
3+
on:
4+
pull_request_target:
5+
branches:
6+
- development
7+
push:
8+
branches:
9+
- development
10+
11+
jobs:
12+
test:
13+
name: Run Java Spring Boot Tests
14+
runs-on: ubuntu-latest
15+
# Require manual approval for fork PRs
16+
environment: testing
17+
18+
defaults:
19+
run:
20+
working-directory: server/java-spring
21+
22+
env:
23+
MONGODB_URI: ${{ secrets.MFLIX_URI }}
24+
ENABLE_SEARCH_TESTS: true
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v5
29+
with:
30+
ref: ${{ github.event.pull_request.head.sha }}
31+
32+
- name: Set up JDK 21
33+
uses: actions/setup-java@v5
34+
with:
35+
java-version: '21'
36+
distribution: 'temurin'
37+
cache: 'maven'
38+
39+
- name: Make mvnw executable
40+
run: chmod +x mvnw
41+
42+
- name: Debug environment variables
43+
run: |
44+
echo "Checking environment variables..."
45+
echo "MONGODB_URI is set: $(if [ -n "$MONGODB_URI" ]; then echo 'YES'; else echo 'NO'; fi)"
46+
echo "ENABLE_SEARCH_TESTS is set: $(if [ -n "$ENABLE_SEARCH_TESTS" ]; then echo 'YES'; else echo 'NO'; fi)"
47+
echo "MONGODB_URI length: ${#MONGODB_URI}"
48+
49+
- name: Run unit tests
50+
run: ./mvnw test
51+
52+
- name: Run integration tests
53+
run: ./mvnw test -Dtest=MongoDBSearchIntegrationTest
54+
continue-on-error: true
55+
56+
- name: Upload test results
57+
uses: actions/upload-artifact@v4
58+
if: always()
59+
with:
60+
name: test-results
61+
path: server/java-spring/target/surefire-reports/
62+
retention-days: 30
63+
64+
- name: Generate Test Summary
65+
if: always()
66+
working-directory: .
67+
run: |
68+
chmod +x .github/scripts/generate-test-summary-surefire.sh
69+
.github/scripts/generate-test-summary-surefire.sh server/java-spring/target/surefire-reports

0 commit comments

Comments
 (0)