Skip to content

Commit d14404f

Browse files
authored
Release sample apps
Merge MVP sample apps to `main` to trigger copy utility
2 parents b7eef66 + dde6b3a commit d14404f

155 files changed

Lines changed: 26180 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Git Attributes for docs-sample-apps
2+
# Marks auto-generated files that are committed to version control
3+
# so they're collapsed in GitHub PR diffs and excluded from code review
4+
5+
# Maven Wrapper - Auto-generated by Apache Maven (committed to git)
6+
# See: https://maven.apache.org/wrapper/
7+
server/java-spring/mvnw linguist-generated=true
8+
server/java-spring/mvnw.cmd linguist-generated=true
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Generate Detailed Test Summary from Multiple Jest JSON Output Files
5+
# Shows breakdown by test type (unit vs integration)
6+
# Usage: ./generate-test-summary-jest.sh <unit-json> <integration-json>
7+
8+
UNIT_JSON="${1:-}"
9+
INTEGRATION_JSON="${2:-}"
10+
11+
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
12+
echo "" >> $GITHUB_STEP_SUMMARY
13+
14+
# Function to parse Jest JSON file
15+
parse_json() {
16+
local json_file="$1"
17+
local test_type="$2"
18+
19+
if [ ! -f "$json_file" ]; then
20+
echo "0 0 0 0"
21+
return
22+
fi
23+
24+
if command -v jq &> /dev/null; then
25+
# Use jq if available (preferred)
26+
total_tests=$(jq -r '.numTotalTests // 0' "$json_file")
27+
passed=$(jq -r '.numPassedTests // 0' "$json_file")
28+
failed=$(jq -r '.numFailedTests // 0' "$json_file")
29+
skipped=$(jq -r '.numPendingTests // 0' "$json_file")
30+
else
31+
# Fallback to grep/sed if jq is not available
32+
total_tests=$(grep -oP '"numTotalTests":\s*\K[0-9]+' "$json_file" | head -1)
33+
passed=$(grep -oP '"numPassedTests":\s*\K[0-9]+' "$json_file" | head -1)
34+
failed=$(grep -oP '"numFailedTests":\s*\K[0-9]+' "$json_file" | head -1)
35+
skipped=$(grep -oP '"numPendingTests":\s*\K[0-9]+' "$json_file" | head -1)
36+
fi
37+
38+
# Default to 0 if values are empty
39+
total_tests=${total_tests:-0}
40+
passed=${passed:-0}
41+
failed=${failed:-0}
42+
skipped=${skipped:-0}
43+
44+
echo "$total_tests $passed $failed $skipped"
45+
}
46+
47+
# Parse both files
48+
read -r unit_tests unit_passed unit_failed unit_skipped <<< "$(parse_json "$UNIT_JSON" "Unit")"
49+
read -r int_tests int_passed int_failed int_skipped <<< "$(parse_json "$INTEGRATION_JSON" "Integration")"
50+
51+
# Calculate totals
52+
total_tests=$((unit_tests + int_tests))
53+
total_passed=$((unit_passed + int_passed))
54+
total_failed=$((unit_failed + int_failed))
55+
total_skipped=$((unit_skipped + int_skipped))
56+
57+
# Display detailed breakdown
58+
echo "### Summary by Test Type" >> $GITHUB_STEP_SUMMARY
59+
echo "" >> $GITHUB_STEP_SUMMARY
60+
echo "| Test Type | Passed | Failed | Skipped | Total |" >> $GITHUB_STEP_SUMMARY
61+
echo "|-----------|--------|--------|---------|-------|" >> $GITHUB_STEP_SUMMARY
62+
63+
if [ -f "$UNIT_JSON" ]; then
64+
echo "| 🔧 Unit Tests | $unit_passed | $unit_failed | $unit_skipped | $unit_tests |" >> $GITHUB_STEP_SUMMARY
65+
fi
66+
67+
if [ -f "$INTEGRATION_JSON" ]; then
68+
echo "| 🔗 Integration Tests | $int_passed | $int_failed | $int_skipped | $int_tests |" >> $GITHUB_STEP_SUMMARY
69+
fi
70+
71+
echo "| **Total** | **$total_passed** | **$total_failed** | **$total_skipped** | **$total_tests** |" >> $GITHUB_STEP_SUMMARY
72+
echo "" >> $GITHUB_STEP_SUMMARY
73+
74+
# Overall status
75+
echo "### Overall Status" >> $GITHUB_STEP_SUMMARY
76+
echo "" >> $GITHUB_STEP_SUMMARY
77+
echo "| Status | Count |" >> $GITHUB_STEP_SUMMARY
78+
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
79+
echo "| ✅ Passed | $total_passed |" >> $GITHUB_STEP_SUMMARY
80+
echo "| ❌ Failed | $total_failed |" >> $GITHUB_STEP_SUMMARY
81+
echo "| ⏭️ Skipped | $total_skipped |" >> $GITHUB_STEP_SUMMARY
82+
echo "| **Total** | **$total_tests** |" >> $GITHUB_STEP_SUMMARY
83+
echo "" >> $GITHUB_STEP_SUMMARY
84+
85+
# List failed tests if any
86+
if [ $total_failed -gt 0 ]; then
87+
echo "### ❌ Failed Tests" >> $GITHUB_STEP_SUMMARY
88+
echo "" >> $GITHUB_STEP_SUMMARY
89+
90+
failed_tests_file=$(mktemp)
91+
92+
# Extract failed tests from both files
93+
for json_file in "$UNIT_JSON" "$INTEGRATION_JSON"; do
94+
if [ -f "$json_file" ]; then
95+
if command -v jq &> /dev/null; then
96+
jq -r '.testResults[]? | select(.status == "failed") | .assertionResults[]? | select(.status == "failed") | "\(.ancestorTitles | join(" > ")) > \(.title)"' "$json_file" >> "$failed_tests_file" 2>/dev/null || true
97+
else
98+
# Basic fallback without jq
99+
grep -oP '"fullName":\s*"\K[^"]*' "$json_file" | while read -r line; do
100+
if echo "$line" | grep -q "failed"; then
101+
echo "$line" >> "$failed_tests_file"
102+
fi
103+
done 2>/dev/null || true
104+
fi
105+
fi
106+
done
107+
108+
if [ -s "$failed_tests_file" ]; then
109+
while IFS= read -r test; do
110+
echo "- \`$test\`" >> $GITHUB_STEP_SUMMARY
111+
done < "$failed_tests_file"
112+
else
113+
echo "_Unable to parse individual test names_" >> $GITHUB_STEP_SUMMARY
114+
fi
115+
116+
echo "" >> $GITHUB_STEP_SUMMARY
117+
echo "❌ **Tests failed!**" >> $GITHUB_STEP_SUMMARY
118+
rm -f "$failed_tests_file"
119+
exit 1
120+
else
121+
echo "✅ **All tests passed!**" >> $GITHUB_STEP_SUMMARY
122+
fi
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Generate Detailed Test Summary from Multiple Pytest JUnit XML Output Files
5+
# Shows breakdown by test type (unit vs integration)
6+
# Usage: ./generate-test-summary-pytest-detailed.sh <unit-xml> <integration-xml>
7+
8+
UNIT_XML="${1:-}"
9+
INTEGRATION_XML="${2:-}"
10+
11+
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
12+
echo "" >> $GITHUB_STEP_SUMMARY
13+
14+
# Function to parse XML file
15+
parse_xml() {
16+
local xml_file="$1"
17+
local test_type="$2"
18+
19+
if [ ! -f "$xml_file" ]; then
20+
echo "0 0 0 0 0"
21+
return
22+
fi
23+
24+
tests=$(grep -oP 'tests="\K[0-9]+' "$xml_file" | head -1)
25+
failures=$(grep -oP 'failures="\K[0-9]+' "$xml_file" | head -1)
26+
errors=$(grep -oP 'errors="\K[0-9]+' "$xml_file" | head -1)
27+
skipped=$(grep -oP 'skipped="\K[0-9]+' "$xml_file" | head -1)
28+
29+
tests=${tests:-0}
30+
failures=${failures:-0}
31+
errors=${errors:-0}
32+
skipped=${skipped:-0}
33+
passed=$((tests - failures - errors - skipped))
34+
35+
echo "$tests $failures $errors $skipped $passed"
36+
}
37+
38+
# Parse both files
39+
read -r unit_tests unit_failures unit_errors unit_skipped unit_passed <<< "$(parse_xml "$UNIT_XML" "Unit")"
40+
read -r int_tests int_failures int_errors int_skipped int_passed <<< "$(parse_xml "$INTEGRATION_XML" "Integration")"
41+
42+
# Calculate totals
43+
total_tests=$((unit_tests + int_tests))
44+
total_failures=$((unit_failures + int_failures))
45+
total_errors=$((unit_errors + int_errors))
46+
total_skipped=$((unit_skipped + int_skipped))
47+
total_passed=$((unit_passed + int_passed))
48+
total_failed=$((total_failures + total_errors))
49+
50+
# Display detailed breakdown
51+
echo "### Summary by Test Type" >> $GITHUB_STEP_SUMMARY
52+
echo "" >> $GITHUB_STEP_SUMMARY
53+
echo "| Test Type | Passed | Failed | Skipped | Total |" >> $GITHUB_STEP_SUMMARY
54+
echo "|-----------|--------|--------|---------|-------|" >> $GITHUB_STEP_SUMMARY
55+
56+
if [ -f "$UNIT_XML" ]; then
57+
echo "| 🔧 Unit Tests | $unit_passed | $((unit_failures + unit_errors)) | $unit_skipped | $unit_tests |" >> $GITHUB_STEP_SUMMARY
58+
fi
59+
60+
if [ -f "$INTEGRATION_XML" ]; then
61+
echo "| 🔗 Integration Tests | $int_passed | $((int_failures + int_errors)) | $int_skipped | $int_tests |" >> $GITHUB_STEP_SUMMARY
62+
fi
63+
64+
echo "| **Total** | **$total_passed** | **$total_failed** | **$total_skipped** | **$total_tests** |" >> $GITHUB_STEP_SUMMARY
65+
echo "" >> $GITHUB_STEP_SUMMARY
66+
67+
# Overall status
68+
echo "### Overall Status" >> $GITHUB_STEP_SUMMARY
69+
echo "" >> $GITHUB_STEP_SUMMARY
70+
echo "| Status | Count |" >> $GITHUB_STEP_SUMMARY
71+
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
72+
echo "| ✅ Passed | $total_passed |" >> $GITHUB_STEP_SUMMARY
73+
echo "| ❌ Failed | $total_failed |" >> $GITHUB_STEP_SUMMARY
74+
echo "| ⏭️ Skipped | $total_skipped |" >> $GITHUB_STEP_SUMMARY
75+
echo "| **Total** | **$total_tests** |" >> $GITHUB_STEP_SUMMARY
76+
echo "" >> $GITHUB_STEP_SUMMARY
77+
78+
# List failed tests if any
79+
if [ $total_failed -gt 0 ]; then
80+
echo "### ❌ Failed Tests" >> $GITHUB_STEP_SUMMARY
81+
echo "" >> $GITHUB_STEP_SUMMARY
82+
83+
failed_tests_file=$(mktemp)
84+
85+
# Extract failed tests from both files
86+
for xml_file in "$UNIT_XML" "$INTEGRATION_XML"; do
87+
if [ -f "$xml_file" ]; then
88+
grep -oP '<testcase[^>]*classname="[^"]*"[^>]*name="[^"]*"[^>]*>.*?<(failure|error)' "$xml_file" | \
89+
grep -oP 'classname="\K[^"]*|name="\K[^"]*' | \
90+
paste -d '.' - - >> "$failed_tests_file" 2>/dev/null || true
91+
fi
92+
done
93+
94+
if [ -s "$failed_tests_file" ]; then
95+
while IFS= read -r test; do
96+
echo "- \`$test\`" >> $GITHUB_STEP_SUMMARY
97+
done < "$failed_tests_file"
98+
else
99+
echo "_Unable to parse individual test names_" >> $GITHUB_STEP_SUMMARY
100+
fi
101+
102+
echo "" >> $GITHUB_STEP_SUMMARY
103+
echo "❌ **Tests failed!**" >> $GITHUB_STEP_SUMMARY
104+
rm -f "$failed_tests_file"
105+
exit 1
106+
else
107+
echo "✅ **All tests passed!**" >> $GITHUB_STEP_SUMMARY
108+
fi
109+
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: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Run Express Tests
2+
3+
on:
4+
pull_request_target:
5+
branches:
6+
- development
7+
paths:
8+
- 'server/js-express/**'
9+
push:
10+
branches:
11+
- development
12+
paths:
13+
- 'server/js-express/**'
14+
15+
jobs:
16+
test:
17+
name: Run Express Tests
18+
runs-on: ubuntu-latest
19+
# Require manual approval for fork PRs
20+
environment: testing
21+
22+
defaults:
23+
run:
24+
working-directory: server/js-express
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 Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: '20'
36+
37+
- name: Install dependencies
38+
run: npm install
39+
40+
- name: Run unit tests
41+
run: npm run test:unit -- --json --outputFile=test-results-unit.json || true
42+
env:
43+
MONGODB_URI: ${{ secrets.MFLIX_URI }}
44+
45+
- name: Run integration tests
46+
run: npm run test:integration -- --json --outputFile=test-results-integration.json || true
47+
env:
48+
MONGODB_URI: ${{ secrets.MFLIX_URI }}
49+
ENABLE_SEARCH_TESTS: true
50+
VOYAGE_API_KEY: ${{ secrets.VOYAGE_AI }}
51+
52+
- name: Upload test results
53+
uses: actions/upload-artifact@v4
54+
if: always()
55+
with:
56+
name: test-results
57+
path: |
58+
server/js-express/coverage/
59+
server/js-express/test-results-unit.json
60+
server/js-express/test-results-integration.json
61+
retention-days: 30
62+
63+
- name: Generate Test Summary
64+
if: always()
65+
working-directory: .
66+
run: |
67+
chmod +x .github/scripts/generate-test-summary-jest.sh
68+
.github/scripts/generate-test-summary-jest.sh \
69+
server/js-express/test-results-unit.json \
70+
server/js-express/test-results-integration.json

0 commit comments

Comments
 (0)