mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-22 21:30:44 +02:00
* test(docs): run doctest on CI, make sure doctests pass * no_run on dialog doctests [skip ci]
312 lines
11 KiB
YAML
312 lines
11 KiB
YAML
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||
# SPDX-License-Identifier: Apache-2.0
|
||
# SPDX-License-Identifier: MIT
|
||
|
||
name: Test Rust
|
||
|
||
on:
|
||
push:
|
||
branches:
|
||
- v1
|
||
- v2
|
||
paths:
|
||
- '.github/workflows/test-rust.yml'
|
||
- 'plugins/*/src/**'
|
||
- '!plugins/*/src/api-iife.js'
|
||
- '**/Cargo.toml'
|
||
- '**/Cargo.lock'
|
||
pull_request:
|
||
branches:
|
||
- v1
|
||
- v2
|
||
paths:
|
||
- '.github/workflows/test-rust.yml'
|
||
- 'plugins/*/src/**'
|
||
- '!plugins/*/src/api-iife.js'
|
||
- '**/Cargo.toml'
|
||
- '**/Cargo.lock'
|
||
|
||
env:
|
||
CARGO_PROFILE_DEV_DEBUG: 0 # no debuginfo: faster builds and a much smaller target dir to cache
|
||
CROSS_REV: 51f46f296253d8122c927c5bb933e3c4f27cc317
|
||
|
||
concurrency:
|
||
group: ${{ github.workflow }}-${{ github.ref }}
|
||
cancel-in-progress: true
|
||
|
||
permissions:
|
||
contents: read
|
||
|
||
jobs:
|
||
changes:
|
||
runs-on: ubuntu-latest
|
||
permissions:
|
||
pull-requests: read
|
||
outputs:
|
||
packages: ${{ steps.filter.outputs.changes }}
|
||
saver: ${{ steps.saver.outputs.saver }}
|
||
steps:
|
||
- uses: actions/checkout@v7
|
||
- uses: dorny/paths-filter@v2
|
||
id: filter
|
||
with:
|
||
base: v2
|
||
filters: |
|
||
tauri-plugin-autostart:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/autostart/**
|
||
tauri-plugin-cli:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/cli/**
|
||
tauri-plugin-clipboard-manager:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/clipboard-manager/**
|
||
tauri-plugin-deep-link:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/deep-link/**
|
||
tauri-plugin-dialog:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/dialog/**
|
||
- plugins/fs/**
|
||
tauri-plugin-fs:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/fs/**
|
||
tauri-plugin-geolocation:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/geolocation/**
|
||
tauri-plugin-global-shortcut:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/global-shortcut/**
|
||
tauri-plugin-opener:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/opener/**
|
||
tauri-plugin-haptics:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/haptics/**
|
||
tauri-plugin-http:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/http/**
|
||
- plugins/fs/**
|
||
tauri-plugin-localhost:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/localhost/**
|
||
tauri-plugin-log:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/log/**
|
||
tauri-plugin-notification:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/notification/**
|
||
tauri-plugin-os:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/os/**
|
||
tauri-plugin-persisted-scope:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/persisted-scope/**
|
||
- plugins/fs/**
|
||
tauri-plugin-positioner:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/positioner/**
|
||
tauri-plugin-process:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/process/**
|
||
tauri-plugin-shell:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/shell/**
|
||
tauri-plugin-single-instance:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/single-instance/**
|
||
tauri-plugin-sql:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/sql/**
|
||
tauri-plugin-store:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/store/**
|
||
tauri-plugin-stronghold:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/stronghold/**
|
||
tauri-plugin-updater:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/updater/**
|
||
tauri-plugin-upload:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/upload/**
|
||
tauri-plugin-websocket:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/websocket/**
|
||
tauri-plugin-window-state:
|
||
- .github/workflows/test-rust.yml
|
||
- Cargo.toml
|
||
- Cargo.lock
|
||
- plugins/window-state/**
|
||
|
||
# Every package job for a platform restores the same rust-cache entry, and exactly one
|
||
# of them saves it (see the `save-if` of the rust-cache step). Prefer the packages whose
|
||
# dependency tree covers most of the other plugins' dependencies, so the entry is as
|
||
# useful as possible for the packages that did not save it.
|
||
- name: pick the package that saves the cache
|
||
id: saver
|
||
env:
|
||
PACKAGES: ${{ steps.filter.outputs.changes }}
|
||
run: |
|
||
saver="$(jq -rn --argjson packages "${PACKAGES:-[]}" '
|
||
["tauri-plugin-upload", "tauri-plugin-sql", "tauri-plugin-updater", "tauri-plugin-single-instance"]
|
||
| map(select(. as $p | $packages | index($p) != null))
|
||
| first // $packages[0] // empty
|
||
')"
|
||
echo "saver=$saver" >> "$GITHUB_OUTPUT"
|
||
|
||
test:
|
||
needs: changes
|
||
if: ${{ needs.changes.outputs.packages != '[]' && needs.changes.outputs.packages != '' }}
|
||
strategy:
|
||
fail-fast: false
|
||
matrix:
|
||
package: ${{ fromJSON(needs.changes.outputs.packages) }}
|
||
platform:
|
||
- {
|
||
target: x86_64-pc-windows-msvc,
|
||
os: windows-latest,
|
||
runner: 'cargo',
|
||
command: 'test'
|
||
}
|
||
- {
|
||
target: x86_64-unknown-linux-gnu,
|
||
os: ubuntu-22.04,
|
||
runner: 'cargo',
|
||
command: 'test'
|
||
}
|
||
- {
|
||
target: aarch64-apple-darwin,
|
||
os: macos-latest,
|
||
runner: 'cargo',
|
||
command: 'test'
|
||
}
|
||
- {
|
||
target: aarch64-apple-ios,
|
||
os: macos-latest,
|
||
runner: 'cargo',
|
||
command: 'build'
|
||
}
|
||
- {
|
||
target: aarch64-linux-android,
|
||
os: ubuntu-latest,
|
||
runner: 'cross',
|
||
command: 'build'
|
||
}
|
||
|
||
runs-on: ${{ matrix.platform.os }}
|
||
|
||
steps:
|
||
- uses: actions/checkout@v7
|
||
|
||
- name: install webkit2gtk
|
||
if: contains(matrix.platform.target, 'unknown-linux')
|
||
run: |
|
||
sudo apt-get update
|
||
sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev
|
||
|
||
- uses: dtolnay/rust-toolchain@1.77.2
|
||
with:
|
||
targets: ${{ matrix.platform.target }}
|
||
|
||
- uses: Swatinem/rust-cache@v2
|
||
with:
|
||
# One entry per platform, shared by every package job: the plugins share most of
|
||
# their dependency tree (tauri, wry, tao...), and an entry per package and platform
|
||
# (26 × 5 entries of 500-800 MB each) never fits the repository's 10 GB cache limit.
|
||
key: ${{ matrix.platform.target }}
|
||
# Only `v2`/`v3` write to the cache: an entry saved from a pull request lives on its
|
||
# merge ref, where nothing else can restore it, and every write evicts an entry
|
||
# that other runs would have hit (10 GB repository limit, LRU eviction).
|
||
# A single package job saves the shared entry, so the jobs don't race for the key.
|
||
save-if: ${{ (github.ref == 'refs/heads/v2' || github.ref == 'refs/heads/v3') && matrix.package == needs.changes.outputs.saver }}
|
||
|
||
# `cross` is built from a pinned git revision (its latest release predates the Android
|
||
# targets we need). Keep the binary in its own small cache entry (accessed by every run,
|
||
# so it stays hot) instead of rebuilding it from source on every run.
|
||
- name: restore cross
|
||
if: ${{ matrix.platform.runner == 'cross' }}
|
||
id: cross-cache
|
||
uses: actions/cache@v6
|
||
with:
|
||
path: ${{ runner.tool_cache }}/cross
|
||
key: cross-${{ runner.os }}-${{ env.CROSS_REV }}
|
||
|
||
- name: install cross
|
||
if: ${{ matrix.platform.runner == 'cross' && steps.cross-cache.outputs.cache-hit != 'true' }}
|
||
run: cargo +stable install cross --git https://github.com/cross-rs/cross --rev ${{ env.CROSS_REV }} --locked --root ${{ runner.tool_cache }}/cross
|
||
|
||
- name: add cross to PATH
|
||
if: ${{ matrix.platform.runner == 'cross' }}
|
||
run: echo "${{ runner.tool_cache }}/cross/bin" >> $GITHUB_PATH
|
||
|
||
- name: test ${{ matrix.package }}
|
||
if: ${{ matrix.package != 'tauri-plugin-http' && matrix.package != 'tauri-plugin-dialog' }}
|
||
run: ${{ matrix.platform.runner }} ${{ matrix.platform.command }} --package ${{ matrix.package }} --target ${{ matrix.platform.target }} --all-targets --all-features
|
||
|
||
- name: test ${{ matrix.package }}
|
||
if: ${{ matrix.package == 'tauri-plugin-http' || matrix.package == 'tauri-plugin-dialog' }}
|
||
run: ${{ matrix.platform.runner }} ${{ matrix.platform.command }} --package ${{ matrix.package }} --target ${{ matrix.platform.target }} --all-targets
|
||
|
||
# `--all-targets` above does not include doc tests, so they are run separately.
|
||
# Only on the platforms we actually test on, since cargo skips doc tests when cross compiling.
|
||
- name: doc test ${{ matrix.package }}
|
||
if: ${{ matrix.platform.command == 'test' && matrix.package != 'tauri-plugin-http' && matrix.package != 'tauri-plugin-dialog' }}
|
||
run: ${{ matrix.platform.runner }} test --doc --package ${{ matrix.package }} --target ${{ matrix.platform.target }} --all-features
|
||
|
||
- name: doc test ${{ matrix.package }}
|
||
if: ${{ matrix.platform.command == 'test' && (matrix.package == 'tauri-plugin-http' || matrix.package == 'tauri-plugin-dialog') }}
|
||
run: ${{ matrix.platform.runner }} test --doc --package ${{ matrix.package }} --target ${{ matrix.platform.target }}
|