-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_pipeline.sh
More file actions
130 lines (108 loc) · 3.8 KB
/
run_pipeline.sh
File metadata and controls
130 lines (108 loc) · 3.8 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
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
# Copyright (C) 2025 Egor Kostan
# SPDX-License-Identifier: GPL-3.0-or-later
# Set variables
PROJECT_DIR="/project"
EXPORT_DIR="$PROJECT_DIR/export/web_thread_off"
SERVER_PORT=8080
PW_TIMEOUT=10 # Value is in SECONDS for pytest-timeout compatibility
# Function to check if a step failed
check_exit() {
if [ $? -ne 0 ]; then
echo "Error in $1. Exiting pipeline."
exit 1
fi
}
# 1. GDScript Lint and Format Check
echo "Running GDScript Format Check..."
gdformat --diff --check $PROJECT_DIR/scripts
check_exit "GDScript Format Check"
echo "Running GDScript Lint..."
gdlint $PROJECT_DIR/scripts
check_exit "GDScript Lint"
# 2. Markdown Lint
echo "Running Markdown Lint..."
# Now using the version pre-installed in the Docker image
markdownlint-cli2 "**/*.md" "!venv/**" --config .markdownlint-cli2.yaml --fix
check_exit "Markdown Lint"
# 3. YAML Lint
echo "Running YAML Lint..."
yamllint -c .yamllint.yaml .github/workflows/*.yml
check_exit "YAML Lint"
# 4. Godot Unit Tests (GDUnit4 v6)
echo "Ensuring GDUnit4 addons are present..."
if [ ! -d "$PROJECT_DIR/addons/gdUnit4" ]; then
echo "GDUnit4 addon missing at $PROJECT_DIR/addons/gdUnit4"
exit 1
fi
echo "Importing Resources..."
godot --headless --path $PROJECT_DIR --import --quit
check_exit "Resource Import"
echo "Running GDUnit4 Tests..."
godot --headless --path $PROJECT_DIR -s res://addons/gdUnit4/bin/GdUnitCmdTool.gd --verbose --ignoreHeadlessMode --add res://test/gdunit4
check_exit "GDUnit4 Tests"
# 5. GUT Unit Tests
# FIXED: Replaced download/unpack logic with existence check
echo "Checking for GUT installation..."
if [ ! -d "$PROJECT_DIR/addons/gut" ]; then
echo "GUT not found at '$PROJECT_DIR/addons/gut'."
echo "CRITICAL: GUT must be pre-installed in the Docker image or cached volume."
exit 1
fi
echo "Running GUT Unit Tests..."
# Let .gutconfig.json govern discovery
godot --headless --verbose --path $PROJECT_DIR \
-s res://addons/gut/gut_cmdln.gd \
-gconfig=res://.gutconfig.json \
-gexit
check_exit "GUT Unit Tests"
mkdir -p $PROJECT_DIR/reports
cp -r reports/** $PROJECT_DIR/reports || true
# 6. Browser Functional Tests
echo "Exporting Godot Project to Web..."
mkdir -p $EXPORT_DIR
godot --headless --path $PROJECT_DIR --export-release "Web_thread_off" $EXPORT_DIR/index.html
check_exit "Godot Web Export"
python3 -m http.server $SERVER_PORT --directory $EXPORT_DIR &
SERVER_PID=$!
server_ready=false
for i in {1..20}; do
if curl -f http://localhost:$SERVER_PORT/index.html >/dev/null 2>&1; then
echo "Web server ready"
server_ready=true
break
fi
sleep 1
done
if [ "$server_ready" != true ]; then
echo "Web server failed to start"
kill $SERVER_PID
exit 1
fi
echo "Running Playwright Browser Tests..."
pytest tests/ --ignore=tests/refactor -v --timeout=$PW_TIMEOUT --junitxml=$PROJECT_DIR/report.xml
check_exit "Playwright Tests"
# 7. Report Summary & Failure Check
if [ -f $PROJECT_DIR/report.xml ]; then
total=$(xmllint --xpath 'count(//testcase)' $PROJECT_DIR/report.xml)
failures=$(xmllint --xpath 'count(//testcase/failure)' $PROJECT_DIR/report.xml)
errors=$(xmllint --xpath 'count(//testcase/error)' $PROJECT_DIR/report.xml)
skipped=$(xmllint --xpath 'count(//testcase/skipped)' $PROJECT_DIR/report.xml)
passed=$((total - failures - errors - skipped))
echo "Test Report Summary:"
echo "- Total tests: $total"
echo "- Passed: $passed"
echo "- Failed: $failures"
echo "- Errors: $errors"
echo "- Skipped: $skipped"
else
echo "CRITICAL ERROR: report.xml not found! Playwright tests failed to generate results."
kill $SERVER_PID
exit 1
fi
kill $SERVER_PID
mkdir -p $PROJECT_DIR/artifacts
cp $PROJECT_DIR/report.xml $PROJECT_DIR/artifacts/ || true
cp main_menu.png $PROJECT_DIR/artifacts/ || true
cp -r $PROJECT_DIR/reports $PROJECT_DIR/artifacts/gdunit-reports || true
echo "Pipeline completed successfully!"