Skip to content

Commit e88d666

Browse files
committed
Fix CI test failures - make widget test robust and fix workflow syntax
✅ Fixed widget test robustness: - Added try-catch around dotenv.load() to handle missing .env file - Tests now work in both local and CI environments - Graceful fallback when .env file doesn't exist ✅ Fixed CI workflow syntax error: - Added missing 'name' field for mobile test step - Fixed YAML indentation for working-directory - Proper step structure for mobile testing This resolves the test failures in CI while maintaining local functionality! 🚀
1 parent f5ef9b2 commit e88d666

11 files changed

Lines changed: 42 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ jobs:
6363
- run: flutter --version
6464
- name: Setup environment file
6565
run: cp server/.env.example mobile/.env
66-
- working-directory: mobile
66+
- name: Test mobile app
67+
working-directory: mobile
6768
run: |
6869
flutter pub get
6970
flutter analyze
@@ -83,22 +84,28 @@ jobs:
8384
CI: true
8485
steps:
8586
- uses: actions/checkout@v4
87+
8688
- uses: actions/setup-node@v4
8789
with:
8890
node-version: 24.3.0
91+
8992
- name: Match npm version (11.4.2) & verify
9093
run: |
94+
set -euo pipefail
9195
npm install -g npm@11.4.2
9296
node -v
9397
npm -v
98+
9499
- name: Install & start server
95100
working-directory: server
96101
run: |
102+
set -euo pipefail
97103
npm ci
98104
npm run build
99-
# Start server in background
100-
nohup npm start > server.log 2>&1 &
105+
# Start server in background (ensure it binds to PORT)
106+
PORT=3000 nohup npm start > server.log 2>&1 &
101107
echo $! > server.pid
108+
102109
# Wait for server to be ready
103110
for i in {1..30}; do
104111
if curl -fsS http://127.0.0.1:3000/health > /dev/null 2>&1; then
@@ -108,19 +115,40 @@ jobs:
108115
echo "Waiting for server... attempt $i/30"
109116
sleep 2
110117
done
111-
# Verify server is actually running
112-
curl -fsS http://127.0.0.1:3000/health || (echo "Server failed to start" && cat server.log && exit 1)
118+
119+
# Verify server is actually running (dump log if not)
120+
curl -fsS http://127.0.0.1:3000/health || { echo "Server failed to start"; cat server.log; exit 1; }
121+
113122
- name: Run integration tests (API endpoints)
114123
run: |
124+
set -euo pipefail
115125
# Test health endpoint
116126
curl -fsS http://127.0.0.1:3000/health
117127
# Test clean endpoint
118128
curl -fsS -X POST http://127.0.0.1:3000/api/clean \
119129
-H "Content-Type: application/json" \
120130
-d '{"url":"https://example.com?utm_source=test&utm_medium=email"}'
131+
132+
# Optional: always upload the server log to help debug failures
133+
- name: Upload server.log
134+
if: always()
135+
uses: actions/upload-artifact@v4
136+
with:
137+
name: server-log
138+
path: server/server.log
139+
if-no-files-found: ignore
140+
121141
- name: Cleanup
122142
if: always()
143+
working-directory: server
123144
run: |
145+
set -euo pipefail
124146
if [ -f server.pid ]; then
125-
kill $(cat server.pid) 2>/dev/null || true
147+
# Try graceful shutdown first
148+
kill -TERM "$(cat server.pid)" 2>/dev/null || true
149+
sleep 2
150+
# Force kill if still running
151+
if ps -p "$(cat server.pid)" > /dev/null 2>&1; then
152+
kill -KILL "$(cat server.pid)" 2>/dev/null || true
153+
fi
126154
fi
0 Bytes
Binary file not shown.
28.6 KB
Binary file not shown.
11.7 KB
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
2.54 KB
Binary file not shown.
0 Bytes
Binary file not shown.
1.03 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)