Skip to content

Commit 0aee84b

Browse files
gnachmanclaude
andcommitted
Add GitHub Actions CI for running tests
Set up automated testing on push to master and PRs: - Run ModernTests scheme on macos-15 with Xcode 26.2 - Smart retry logic for flaky ibtoold/asset catalog crashes (known Xcode 26.2 issue on GitHub runners) - Only retry for infrastructure issues, fail fast on real test failures - Upload test results as artifacts for debugging - Fix HTTP server binding in tests for CI environment Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f3b9de1 commit 0aee84b

File tree

2 files changed

+87
-5
lines changed

2 files changed

+87
-5
lines changed

.github/workflows/test.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [master, ci-test]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
test:
11+
runs-on: macos-15
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
submodules: recursive
18+
19+
- name: Select Xcode 26
20+
run: sudo xcode-select -s /Applications/Xcode_26.2.app/Contents/Developer
21+
22+
- name: Show Xcode version
23+
run: xcodebuild -version
24+
25+
- name: Kill orphan Xcode processes
26+
run: |
27+
killall ibtoold 2>/dev/null || true
28+
killall AssetCatalogSimulatorAgent 2>/dev/null || true
29+
30+
- name: Run tests
31+
run: |
32+
# Retry up to 3 times, but only for flaky ibtoold/asset catalog crashes
33+
for attempt in 1 2 3; do
34+
echo "::group::Attempt $attempt of 3"
35+
rm -rf TestResults.xcresult build_output.txt
36+
37+
# Run xcodebuild and capture output
38+
set +e
39+
xcodebuild test \
40+
-project iTerm2.xcodeproj \
41+
-scheme ModernTests \
42+
-parallel-testing-enabled NO \
43+
-resultBundlePath TestResults.xcresult \
44+
CODE_SIGN_IDENTITY="" \
45+
CODE_SIGNING_REQUIRED=NO \
46+
CODE_SIGNING_ALLOWED=NO 2>&1 | tee build_output.txt
47+
exit_code=$?
48+
set -e
49+
echo "::endgroup::"
50+
51+
if [ $exit_code -eq 0 ]; then
52+
echo "Tests passed on attempt $attempt"
53+
exit 0
54+
fi
55+
56+
# Check if this is a flaky ibtoold/asset catalog crash
57+
if grep -q "CompileAssetCatalogVariant failed\|IBPlatformToolFailureException\|The tool closed the connection" build_output.txt; then
58+
echo "::warning::Attempt $attempt failed due to flaky ibtoold crash (known Xcode 26.2 issue)"
59+
if [ $attempt -lt 3 ]; then
60+
echo "Retrying..."
61+
killall ibtoold 2>/dev/null || true
62+
killall AssetCatalogSimulatorAgent 2>/dev/null || true
63+
sleep 5
64+
continue
65+
else
66+
echo "::error::All 3 attempts failed due to flaky ibtoold crashes"
67+
exit 1
68+
fi
69+
else
70+
# Real test failure - don't retry
71+
echo "::error::Tests failed (not a flaky ibtoold issue)"
72+
exit 1
73+
fi
74+
done
75+
76+
- name: Upload test results
77+
uses: actions/upload-artifact@v4
78+
if: always()
79+
with:
80+
name: test-results
81+
path: TestResults.xcresult
82+
retention-days: 7

ModernTests/iTermBrowserPageSaverTestHelper.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -727,14 +727,14 @@ private class iTermTestHTTPServer {
727727
func start() {
728728
let task = Process()
729729
task.executableURL = URL(fileURLWithPath: "/usr/bin/python3")
730-
task.arguments = ["-m", "http.server", String(port)]
730+
task.arguments = ["-m", "http.server", "--bind", "127.0.0.1", String(port)]
731731
task.currentDirectoryURL = documentRoot
732-
732+
733733
try! task.run()
734734
server = task
735-
736-
// Give the server a moment to start
737-
Thread.sleep(forTimeInterval: 0.5)
735+
736+
// Give the server a moment to start (longer for CI environments)
737+
Thread.sleep(forTimeInterval: 1.0)
738738
}
739739

740740
func stop() {

0 commit comments

Comments
 (0)