-
-
Notifications
You must be signed in to change notification settings - Fork 10
117 lines (102 loc) · 3.66 KB
/
scripts-test.yml
File metadata and controls
117 lines (102 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# ______ ______ _____ _ _
# | ____| ____| /\ / ____| (_) | |
# | |__ | |__ / \ | (___ ___ ____ _ ____ | |_
# | __| | __| / /\ \ \___ \ / __| __| | _ \| __|
# | | | |____ / ____ \ ____) | (__| | | | |_) | |
# |_| |______/_/ \_\_____/ \___|_| |_| __/| |
# | | | |
# |_| | |_
# Website: https://feascript.com/ \__|
#
name: Run FEAScript Examples
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
run-examples:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
fail-fast: false # Continue testing other versions even if one fails
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Run FEAScript examples
run: |
echo "=========================================="
echo "Running FEAScript examples with Node.js ${{ matrix.node-version }}"
echo "=========================================="
# Counter for tracking test results
PASSED=0
FAILED=0
TOTAL=0
# Array to store failed examples
FAILED_EXAMPLES=()
# Find all .js files in examples directory
for file in $(find examples -name "*.js" -type f | sort); do
TOTAL=$((TOTAL + 1))
LOG_FILE="${file%.js}.log"
echo ""
echo "▶ Running: $file"
echo "----------------------------------------"
# Run the example and capture output to log file
if timeout 300 node "$file" > "$LOG_FILE" 2>&1; then
echo "✓ PASSED: $file"
PASSED=$((PASSED + 1))
# Show a preview of the output
echo "Output preview:"
head -n 5 "$LOG_FILE" | sed 's/^/ /'
if [ $(wc -l < "$LOG_FILE") -gt 5 ]; then
echo " ... (see $LOG_FILE for full output)"
fi
else
EXIT_CODE=$?
echo "✗ FAILED: $file (exit code: $EXIT_CODE)"
FAILED=$((FAILED + 1))
FAILED_EXAMPLES+=("$file")
# Show error output for failed tests
echo "Error output:"
tail -n 20 "$LOG_FILE" | sed 's/^/ /'
fi
echo "----------------------------------------"
done
# Print summary
echo ""
echo "=========================================="
echo "Test Summary"
echo "=========================================="
echo "Total examples run: $TOTAL"
echo "Passed: $PASSED"
echo "Failed: $FAILED"
echo ""
# If there are failures, list them
if [ $FAILED -gt 0 ]; then
echo "Failed examples:"
for failed in "${FAILED_EXAMPLES[@]}"; do
echo " - $failed"
done
echo ""
exit 1
else
echo "All examples passed successfully! ✓"
fi
- name: Upload test results on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-results-node-${{ matrix.node-version }}
path: |
examples/**/*.log
examples/**/*.out
retention-days: 7
if-no-files-found: ignore