跳到內容
Tauri

持續整合

利用 Linux 和一些程式建立虛擬顯示器,可以在您的 CI 上使用 WebDriver 測試。以下範例使用我們先前一起建立的 WebdriverIO 範例和 GitHub Actions。

這表示以下假設

  1. Tauri 應用程式位於儲存庫根目錄中,並且在運行 cargo build --release 時建置二進制檔案。
  2. WebDriverIO 測試運行器位於 webdriver/webdriverio 目錄中,並且在該目錄中使用 yarn test 時運行。

以下是在 .github/workflows/webdriver.yml 的已註解 GitHub Actions 工作流程檔案

# run this action when the repository is pushed to
on: [push]
# the name of our workflow
name: WebDriver
jobs:
# a single job named test
test:
# the display name of the test job
name: WebDriverIO Test Runner
# we want to run on the latest linux environment
runs-on: ubuntu-22.04
# the steps our job runs **in order**
steps:
# checkout the code on the workflow runner
- uses: actions/checkout@v4
# install system dependencies that Tauri needs to compile on Linux.
# note the extra dependencies for `tauri-driver` to run which are: `webkit2gtk-driver` and `xvfb`
- name: Tauri dependencies
run: |
sudo apt update && sudo apt install -y \
libwebkit2gtk-4.1-dev \
build-essential \
curl \
wget \
file \
libxdo-dev \
libssl-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
webkit2gtk-driver \
xvfb
- name: Setup rust-toolchain stable
id: rust-toolchain
uses: dtolnay/rust-toolchain@stable
# we run our rust tests before the webdriver tests to avoid testing a broken application
- name: Cargo test
run: cargo test
# build a release build of our application to be used during our WebdriverIO tests
- name: Cargo build
run: cargo build --release
# install the latest stable node version at the time of writing
- name: Node 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
# install our Node.js dependencies with Yarn
- name: Yarn install
run: yarn install --frozen-lockfile
working-directory: webdriver/webdriverio
# install the latest version of `tauri-driver`.
# note: the tauri-driver version is independent of any other Tauri versions
- name: Install tauri-driver
run: cargo install tauri-driver --locked
# run the WebdriverIO test suite.
# we run it through `xvfb-run` (the dependency we installed earlier) to have a fake
# display server which allows our application to run headless without any changes to the code
- name: WebdriverIO
run: xvfb-run yarn test
working-directory: webdriver/webdriverio

© 2025 Tauri 貢獻者。CC-BY / MIT