Repository navigation
193 lines (171 loc) · 7.92 KB
/
Copy pathtest-api-e2e.yml
File metadata and controls
193 lines (171 loc) · 7.92 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
# Copyright 2019-2024 Tauri Programme within The Commons Conservancy
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: MIT
name: test `@tauri-apps/api` e2e
on:
workflow_dispatch:
# run before publishing, see covector-version-or-publish.yml
workflow_call:
push:
branches:
- dev
pull_request:
paths:
- '.github/workflows/test-api-e2e.yml'
- 'packages/api/**'
- 'packages/api-e2e/**'
- 'examples/api/**'
env:
RUST_BACKTRACE: 1
CARGO_PROFILE_DEV_DEBUG: 0 # keeps the target folder small for better cache efficiency
# Incremental artifacts are dropped from the cache anyway and only slow the builds down.
CARGO_INCREMENTAL: 0
concurrency:
# `github.workflow` is the caller's name in a `workflow_call` run, so the suffix keeps the
# desktop and mobile suites from sharing (and cancelling) one group there.
group: ${{ github.workflow }}-api-e2e-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
test:
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- { name: Linux, os: ubuntu-latest }
- { name: Windows, os: windows-latest }
- { name: macOS, os: macos-latest }
env:
# macOS has no native WebDriver for WKWebView, so the app is driven through the
# CrabNebula Webdriver (tauri-plugin-automation + test-runner-backend), which
# authenticates with this key. Pull requests from forks do not get it, and the macOS
# job then has nothing to test: the steps below skip the builds there rather than
# occupy a macOS runner for them.
HAS_CN_API_KEY: ${{ secrets.TAURI_E2E_CN_API_KEY != '' }}
steps:
- uses: actions/checkout@v7
- name: install Rust 1.90
# The MSRV, as the other jobs building the CLI use. The compiler version is part of
# the rust-cache key, so a floating `stable` would also invalidate the entry below on
# every Rust release.
uses: dtolnay/rust-toolchain@1.90
- run: npm i -g --force corepack
- name: setup node
if: runner.os != 'macOS' || env.HAS_CN_API_KEY == 'true'
uses: actions/setup-node@v7
with:
node-version: 'lts/*'
cache: 'pnpm'
- name: install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
webkit2gtk-driver \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
xvfb \
fluxbox
# WebKitGTK reads the color scheme and tao the theme from the desktop portal when a
# window is created. On the runner that portal is registered with D-Bus but never
# comes up (there is no desktop session for it), so both calls only return on their
# timeouts, 25s and 5s: about 30s per app start, and every spec starts the app.
# Without a service file the name is unknown and both calls fail at once.
sudo rm -f /usr/share/dbus-1/services/org.freedesktop.portal.Desktop.service
- name: install msedgedriver (Windows)
if: runner.os == 'Windows'
# The driver has to match the WebView2 runtime, which registers its version with
# EdgeUpdate under the client id below. This is what msedgedriver-tool does, minus
# compiling the tool from source on every run (a minute).
run: |
$ProgressPreference = 'SilentlyContinue'
$client = 'Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}'
$version = @(
"HKLM:\SOFTWARE\WOW6432Node\$client",
"HKLM:\SOFTWARE\$client",
"HKCU:\SOFTWARE\WOW6432Node\$client",
"HKCU:\SOFTWARE\$client"
) | ForEach-Object { (Get-ItemProperty -Path $_ -ErrorAction SilentlyContinue).pv } | Where-Object { $_ } | Select-Object -First 1
if (-not $version) { throw 'no WebView2 runtime found in the registry' }
$dir = Join-Path $env:RUNNER_TEMP 'msedgedriver'
New-Item -ItemType Directory -Force -Path $dir | Out-Null
Invoke-WebRequest "https://msedgedriver.microsoft.com/$version/edgedriver_win64.zip" -OutFile "$dir\edgedriver.zip"
Expand-Archive "$dir\edgedriver.zip" -DestinationPath $dir -Force
Write-Host "WebView2 $version; $(& "$dir\msedgedriver.exe" --version)"
$dir >> $env:GITHUB_PATH
- uses: Swatinem/rust-cache@v2
if: runner.os != 'macOS' || env.HAS_CN_API_KEY == 'true'
with:
# The dependencies of the CLI and of the example app, both in the dev profile.
# Only `dev` writes the entry: one saved from a pull request lives on its merge
# ref, where nothing else can restore it, and every write evicts a `dev` entry
# that other runs would have hit (10 GB repository limit, LRU eviction). Pull
# requests restore the `dev` entry, so they get everything but the workspace
# crates for free.
shared-key: api-e2e
save-if: ${{ github.ref == 'refs/heads/dev' }}
# A flaky spec on `dev` must not throw the build away.
cache-on-failure: true
- name: install dependencies
if: runner.os != 'macOS' || env.HAS_CN_API_KEY == 'true'
run: pnpm i --frozen-lockfile
- name: build @tauri-apps/api
if: runner.os != 'macOS' || env.HAS_CN_API_KEY == 'true'
run: pnpm build:api
- name: build @tauri-apps/cli
if: runner.os != 'macOS' || env.HAS_CN_API_KEY == 'true'
# Debug profile: the suite builds the example app with `tauri build --debug` anyway, and
# a debug CLI reuses the cached dependencies instead of a from-scratch LTO build.
run: pnpm build:cli:debug
- name: run e2e tests (Linux)
if: runner.os == 'Linux'
timeout-minutes: 45
# A real window manager (fluxbox) is started so that window-state tests
# (minimize/maximize/fullscreen/position) behave.
env:
E2E_SPEC_RETRIES: '1'
run: |
xvfb-run --auto-servernum -- bash -c '
fluxbox >/dev/null 2>&1 &
sleep 1
pnpm test:api-e2e
'
- name: run e2e tests (Windows)
if: runner.os == 'Windows'
timeout-minutes: 45
shell: pwsh
# msedgedriver hands the app the `--remote-debugging-port` it attaches to through
# `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS`, and WebView2 ignores that variable in an
# elevated process, which is what the runner gives us. gsudo runs the suite at medium
# integrity instead, and the workspace is opened up so the de-elevated process can use it.
# See https://github.com/tauri-apps/wry/issues/1782 and
# https://github.com/MicrosoftEdge/WebView2Feedback/issues/5645.
env:
E2E_SPEC_RETRIES: '1'
run: |
winget install gerardog.gsudo --accept-source-agreements --accept-package-agreements
icacls "$env:GITHUB_WORKSPACE" /grant "Everyone:(OI)(CI)F"
sudo --integrity Medium pnpm test:api-e2e
- name: run e2e tests (macOS)
if: runner.os == 'macOS' && env.HAS_CN_API_KEY == 'true'
timeout-minutes: 45
env:
CN_API_KEY: ${{ secrets.TAURI_E2E_CN_API_KEY }}
E2E_SPEC_RETRIES: '1'
# wdio.conf enables the CrabNebula Webdriver automatically on darwin and builds
# the `.app` bundle it needs.
run: pnpm test:api-e2e
- name: collect app crash reports (macOS)
if: runner.os == 'macOS' && failure()
run: .scripts/ci/collect-macos-crash-reports.sh "$RUNNER_TEMP/crash-reports"
- name: upload app crash reports (macOS)
if: runner.os == 'macOS' && failure()
uses: actions/upload-artifact@v7
with:
name: macos-crash-reports
path: ${{ runner.temp }}/crash-reports
if-no-files-found: ignore