-
-
Notifications
You must be signed in to change notification settings - Fork 0
305 lines (274 loc) · 12.5 KB
/
_ci-e2e-tauri.reusable.yml
File metadata and controls
305 lines (274 loc) · 12.5 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
name: Tauri E2E Tests
description: 'Runs Tauri end-to-end tests across different scenarios and test types'
permissions:
contents: read
on:
workflow_call:
# Make this a reusable workflow, no value needed
# https://docs.github.com/en/actions/using-workflows/reusing-workflows
inputs:
os:
description: 'Operating system to run tests on'
required: true
type: string
node-version:
description: 'Node.js version to use for testing'
required: true
type: string
build-command:
description: 'Build command for test applications (build or build:mac-universal)'
type: string
default: 'build'
scenario:
description: 'Test scenario (tauri-basic)'
required: true
type: string
test-type:
description: 'Test type (standard, multiremote, standalone)'
type: string
default: 'standard'
build_id:
description: 'Build ID from the build job'
type: string
required: false
artifact_size:
description: 'Size of the build artifact in bytes'
type: string
required: false
cache_key:
description: 'Cache key to use for downloading package artifacts'
type: string
required: false
tauri_cache_key:
description: 'Cache key to use for downloading Tauri app binaries'
type: string
required: false
env:
TURBO_TELEMETRY_DISABLED: 1
TURBO_DAEMON: false
jobs:
# This job runs Tauri E2E tests for a specific combination of:
# - Operating system (Linux, Windows, macOS)
# - Test scenario (tauri-basic)
# - Test type (standard, multiremote, standalone)
# Note: macOS tests are skipped due to WKWebView limitations
e2e-tauri:
name: Tauri E2E Tests
runs-on: ${{ inputs.os }}
# Skip Tauri E2E tests on macOS due to WKWebView WebDriver limitations
if: inputs.os != 'macos-latest' && inputs.os != 'macos-15-intel'
strategy:
# Continue with other tests even if one fails
fail-fast: false
steps:
# Standard checkout with SSH key for private repositories
- name: 👷 Checkout Repository
uses: actions/checkout@v6
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
# Set up Node.js and PNPM using the reusable action
- name: 🛠️ Setup Development Environment
uses: ./.github/workflows/actions/setup-workspace
with:
node-version: ${{ inputs.node-version }}
# Install Tauri runtime dependencies on Linux (apps are pre-built, only need runtime libs)
# Minimum requirements per Tauri docs: libwebkit2gtk-4.1-0, libgtk-3-0, libappindicator3-1
# Additional libraries may be pulled in as transitive dependencies
- name: 🔧 Fix ARM64 Package Sources (Linux)
if: runner.os == 'Linux' && runner.arch == 'ARM64'
shell: bash
run: |
echo "Fixing ARM64 package sources for Ubuntu..."
# Add proper arm64 sources for jammy
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe multiverse" | sudo tee /etc/apt/sources.list.d/arm64-jammy.list > /dev/null
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/arm64-jammy.list > /dev/null
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/arm64-jammy.list > /dev/null
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/arm64-jammy.list > /dev/null
# Ensure default sources only use amd64
sudo sed -i -e 's/^deb http/deb [arch=amd64] http/' /etc/apt/sources.list
sudo sed -i -e 's/^deb mirror/deb [arch=amd64] mirror/' /etc/apt/sources.list
sudo apt-get update
- name: 🦀 Install Tauri Runtime Dependencies (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
echo "Installing Tauri runtime dependencies for Linux..."
# Only add archive.ubuntu.com for amd64, arm64 sources are handled above
if [ "$(uname -m)" != "aarch64" ]; then
echo "deb http://archive.ubuntu.com/ubuntu jammy main universe" | sudo tee -a /etc/apt/sources.list > /dev/null
fi
sudo apt-get update
sudo apt-get --fix-broken install -y || true
# Install required packages - use t64 variant to avoid migration conflicts
# Remove conflicting libgtk-3-0 if present
# sudo apt-get remove -y libgtk-3-0 2>/dev/null || true
sudo apt-get install -y \
libwebkit2gtk-4.1-0 \
libgtk-3-0t64 \
libayatana-appindicator3-1
# Install Rust toolchain for auto-installing tauri-driver
# The @wdio/tauri-service will automatically install tauri-driver via cargo if not found
- name: 🦀 Setup Rust (for tauri-driver auto-install)
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: 🌐 Install WebKit WebDriver (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
echo "Installing WebKit WebDriver for Linux..."
sudo apt-get install -y webkit2gtk-driver
# Verify installation
which WebKitWebDriver || echo "WebKitWebDriver not found in PATH"
WebKitWebDriver --version || echo "WebKitWebDriver version check failed"
# Download the pre-built packages from the build job
# This ensures all tests use the same build artifacts
- name: 📦 Download Package Build Artifacts
uses: ./.github/workflows/actions/download-archive
with:
name: wdio-desktop-mobile
path: wdio-desktop-mobile-build
filename: artifact.zip
cache_key_prefix: wdio-desktop-build
exact_cache_key: ${{ inputs.cache_key || github.run_id && format('{0}-{1}-{2}-{3}{4}', 'Linux', 'wdio-desktop-build', 'wdio-desktop-mobile', github.run_id, github.run_attempt > 1 && format('-rerun{0}', github.run_attempt) || '') || '' }}
# Download the pre-built Tauri E2E app binary from the OS-specific build job
# This is much faster than rebuilding Tauri apps for each test type
# Extract to repository root so files end up in fixtures/e2e-apps/tauri/src-tauri/target/
- name: 📦 Download Tauri E2E App Binary
uses: ./.github/workflows/actions/download-archive
with:
name: tauri-e2e-app-${{ runner.os }}
path: tauri-e2e-app-${{ runner.os }}
filename: artifact.zip
cache_key_prefix: tauri-e2e-app
exact_cache_key: ${{ inputs.tauri_cache_key }}
# Verify Tauri binaries were extracted correctly
- name: ✅ Verify Tauri Binaries
shell: bash
run: |
echo "Checking for Tauri binaries in fixtures/e2e-apps/tauri/src-tauri/target/"
if [ ! -d "fixtures/e2e-apps/tauri" ]; then
echo "::error::fixtures/e2e-apps/tauri directory not found!"
exit 1
fi
# Find all target directories
TARGET_DIRS=$(find fixtures/e2e-apps/tauri -name "target" -type d 2>/dev/null || true)
if [ -z "$TARGET_DIRS" ]; then
echo "::error::No target directories found! Binaries were not extracted correctly."
echo "Directory contents:"
ls -la fixtures/e2e-apps/tauri/ || true
ls -la fixtures/e2e-apps/tauri/src-tauri/ || true
exit 1
fi
echo "✅ Found target directories:"
echo "$TARGET_DIRS"
# Verify binaries exist
BINARY_COUNT=0
for target_dir in $TARGET_DIRS; do
if [ "${{ runner.os }}" = "Windows" ]; then
if [ -f "$target_dir/release/*.exe" ] || compgen -G "$target_dir/release/*.exe" > /dev/null; then
BINARY_COUNT=$((BINARY_COUNT + 1))
echo " ✅ Found Windows binary in $target_dir/release/"
fi
else
# Check for executable files on Linux/Mac
if find "$target_dir/release" -maxdepth 1 -type f -executable 2>/dev/null | grep -q .; then
BINARY_COUNT=$((BINARY_COUNT + 1))
echo " ✅ Found binary in $target_dir/release/"
fi
fi
done
if [ "$BINARY_COUNT" -eq 0 ]; then
echo "::error::No binaries found in target directories!"
exit 1
fi
echo "✅ Verification complete: Found $BINARY_COUNT app(s) with binaries"
# Display build information if available
- name: 📊 Show Build Information
if: inputs.build_id != '' && inputs.artifact_size != ''
shell: bash
run: |
echo "::notice::Package build: ID=${{ inputs.build_id }}, Size=${{ inputs.artifact_size }} bytes"
echo "::notice::Tauri binaries: Using pre-built binaries for ${{ runner.os }}"
# Dynamically generate the Tauri test commands to run
# Uses 'tauri-basic' naming convention to align with Electron's 'builder/forge/script' naming
- name: 🪄 Generate Tauri Test Execution Plan
id: gen-test
uses: actions/github-script@v8
with:
result-encoding: string
script: |
const generateTauriTestCommand = (scenario, testType) => {
return scenario
.split(',')
.map((s) => {
const scenario = s.trim();
// Use 'tauri-basic' as the app name (single Tauri app variant)
const baseCommand = `test:e2e:tauri-basic`;
return testType !== 'standard'
? `${baseCommand}:${testType}`
: baseCommand;
})
.join(' ');
};
return generateTauriTestCommand('${{ inputs.scenario }}', '${{ inputs.test-type }}');
# Run the Tauri E2E tests directly with pnpm (bypasses Turbo's dependsOn)
# On Linux, wrap with xvfb-run so LAUNCHER (where tauri-driver runs) has display access
# tauri-driver launches apps during session creation, needs display in launcher context
# This skips rebuilding Tauri apps since we downloaded pre-built binaries
- name: 🧪 Execute Tauri E2E Tests
shell: bash
working-directory: e2e
env:
# Enable Rust backtraces for debugging Tauri/GTK issues
RUST_BACKTRACE: '1'
# Disable AT-SPI accessibility bus warnings
NO_AT_BRIDGE: '1'
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
# Use 16-bit color depth to avoid pixbuf issues with GTK/WebKit
xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x16" \
pnpm run ${{ steps.gen-test.outputs.result }}
else
pnpm run ${{ steps.gen-test.outputs.result }}
fi
# Show Rust debug logs
- name: 🔍 Show Rust Debug Logs
if: always()
shell: bash
run: |
echo "=== Rust Debug Log ==="
if [ -f /tmp/tauri-debug.log ]; then
cat /tmp/tauri-debug.log
else
echo "No Rust debug log found at /tmp/tauri-debug.log"
fi
echo ""
echo "=== Tauri App Process Info ==="
ps aux | grep tauri || echo "No tauri processes found"
echo ""
echo "=== System Logs (last 50 lines) ==="
journalctl --no-pager -n 50 || echo "No system logs available"
# Show comprehensive debug information on failure
- name: 🐛 Debug Information
if: always()
shell: bash
run: pnpm run ci:e2e:logs
# Upload logs as artifacts for later analysis
# This helps debug issues without cluttering the GitHub Actions console
- name: 📦 Upload Test Logs
if: always()
continue-on-error: true
uses: actions/upload-artifact@v6
with:
name: e2e-tauri-logs-${{ inputs.os }}-${{ inputs.scenario }}-${{ inputs.test-type }}
path: e2e/logs/**/*.log
retention-days: 90
if-no-files-found: warn
# Provide an interactive debugging session on failure
# This allows manual investigation of the environment
- name: 🐛 Debug Build on Failure
if: failure()
uses: goosewobbler/vscode-server-action@v1.3.0
with:
timeout: '300000'