mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-10-10 22:38:44 +02:00
ci: only run what a change affects, consolidate jobs (#3674)
* ci: only run what a change affects, consolidate jobs - detect affected plugins from changed files and Cargo.lock dependency trees - test/lint Rust per platform in shards instead of one job per plugin - fold check-generated-files into lint-javascript, fmt into a single job - skip fat LTO in integration test builds, single ABI in test-android * ci: run e2e on bumps, use published tauri CLI, PR-safe pnpm cache - trigger e2e on Cargo/pnpm lockfile and manifest changes - install the latest 2.x tauri-cli with cargo-binstall in integration tests - add setup-pnpm action: restore the store everywhere, save only on v2/v3 * fix clippy, ios build * fix bumps [skip ci]
This commit is contained in:
1 parent
974af951a5
commit
9a74a78c71
18 files changed
+600
-630
No files matched your search
+58
-126
@@ -9,20 +9,23 @@ on:
|
||||
branches:
|
||||
- v1
|
||||
- v2
|
||||
paths:
|
||||
paths: &paths
|
||||
- '.github/workflows/lint-rust.yml'
|
||||
- 'plugins/*/src/**'
|
||||
- '!plugins/*/src/api-iife.js'
|
||||
- '**/Cargo.toml'
|
||||
- '.scripts/ci/affected-rust-packages.js'
|
||||
- 'plugins/**'
|
||||
- '!plugins/*/guest-js/**'
|
||||
- '!plugins/*/android/**'
|
||||
- '!plugins/*/*.md'
|
||||
- '!plugins/*/package.json'
|
||||
- '!plugins/*/api-iife.js'
|
||||
- 'Cargo.toml'
|
||||
- 'Cargo.lock'
|
||||
pull_request:
|
||||
branches:
|
||||
- v1
|
||||
- v2
|
||||
paths:
|
||||
- '.github/workflows/lint-rust.yml'
|
||||
- 'plugins/*/src/**'
|
||||
- '!plugins/*/src/api-iife.js'
|
||||
- '**/Cargo.toml'
|
||||
paths: *paths
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
@@ -32,128 +35,35 @@ permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
# Lists the plugins the change affects and splits them in shards, linted one after the other in
|
||||
# a single job per platform; see test-rust.yml for the reasoning.
|
||||
changes:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: read
|
||||
outputs:
|
||||
packages: ${{ steps.filter.outputs.changes }}
|
||||
saver: ${{ steps.saver.outputs.saver }}
|
||||
shards: ${{ steps.affected.outputs.shards }}
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: dorny/paths-filter@v2
|
||||
id: filter
|
||||
with:
|
||||
filters: |
|
||||
tauri-plugin-autostart:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/autostart/**
|
||||
tauri-plugin-cli:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/cli/**
|
||||
tauri-plugin-clipboard-manager:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/clipboard-manager/**
|
||||
tauri-plugin-deep-link:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/deep-link/**
|
||||
tauri-plugin-dialog:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/dialog/**
|
||||
- plugins/fs/**
|
||||
tauri-plugin-fs:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/fs/**
|
||||
tauri-plugin-geolocation:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/geolocation/**
|
||||
tauri-plugin-global-shortcut:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/global-shortcut/**
|
||||
tauri-plugin-opener:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/opener/**
|
||||
tauri-plugin-haptics:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/haptics/**
|
||||
tauri-plugin-http:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/http/**
|
||||
- plugins/fs/**
|
||||
tauri-plugin-localhost:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/localhost/**
|
||||
tauri-plugin-log:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/log/**
|
||||
tauri-plugin-notification:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/notification/**
|
||||
tauri-plugin-os:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/os/**
|
||||
tauri-plugin-persisted-scope:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/persisted-scope/**
|
||||
- plugins/fs/**
|
||||
tauri-plugin-positioner:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/positioner/**
|
||||
tauri-plugin-process:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/process/**
|
||||
tauri-plugin-shell:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/shell/**
|
||||
tauri-plugin-single-instance:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/single-instance/**
|
||||
tauri-plugin-sql:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/sql/**
|
||||
tauri-plugin-store:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/store/**
|
||||
tauri-plugin-stronghold:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/stronghold/**
|
||||
tauri-plugin-updater:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/updater/**
|
||||
tauri-plugin-upload:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/upload/**
|
||||
tauri-plugin-websocket:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- plugins/websocket/**
|
||||
tauri-plugin-window-state:
|
||||
- .github/workflows/lint-rust.yml
|
||||
- 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
|
||||
# a pull request checks out its merge commit, whose first parent is the base branch
|
||||
fetch-depth: 2
|
||||
- id: affected
|
||||
run: node .scripts/ci/affected-rust-packages.js
|
||||
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"
|
||||
BASE: ${{ github.event_name == 'pull_request' && 'HEAD^1' || github.event.before }}
|
||||
ALL: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
GLOBAL_PATHS: .github/workflows/lint-rust.yml
|
||||
|
||||
clippy:
|
||||
name: clippy (${{ matrix.platform.target }}, ${{ matrix.shard.name }})
|
||||
needs: changes
|
||||
if: ${{ needs.changes.outputs.packages != '[]' && needs.changes.outputs.packages != '' }}
|
||||
if: ${{ needs.changes.outputs.shards != '[]' && needs.changes.outputs.shards != '' }}
|
||||
runs-on: ${{ matrix.platform.os }}
|
||||
# a stuck step (e.g. `apt-get` waiting on an unreachable mirror) otherwise runs for 6 hours
|
||||
timeout-minutes: 90
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
package: ${{ fromJSON(needs.changes.outputs.packages) }}
|
||||
shard: ${{ fromJSON(needs.changes.outputs.shards) }}
|
||||
platform:
|
||||
- target: x86_64-pc-windows-msvc
|
||||
os: windows-latest
|
||||
@@ -194,14 +104,36 @@ jobs:
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
# One entry shared by every package job (the default key is per job, not per
|
||||
# matrix entry), only written from `v2`/`v3` and by a single package job; see
|
||||
# test-rust.yml for the reasoning.
|
||||
save-if: ${{ (github.ref == 'refs/heads/v2' || github.ref == 'refs/heads/v3') && matrix.package == needs.changes.outputs.saver }}
|
||||
# One entry per target shared by every shard (the default key is per job and runner
|
||||
# OS, which the Linux and Android jobs, and the macOS and iOS ones, would share), only
|
||||
# written from `v2`/`v3` and by a single shard; see test-rust.yml for the reasoning.
|
||||
key: ${{ matrix.platform.target }}
|
||||
save-if: ${{ (github.ref == 'refs/heads/v2' || github.ref == 'refs/heads/v3') && matrix.shard.save }}
|
||||
|
||||
- name: clippy ${{ matrix.package }}
|
||||
run: ${{ matrix.platform.cargo }} clippy --package ${{ matrix.package }} --target ${{ matrix.platform.target }} --all-targets -- -D warnings
|
||||
# The shard's packages are linted one after the other, and a failing package does not stop
|
||||
# the others: the step fails at the end if any did.
|
||||
- name: clippy ${{ matrix.shard.name }}
|
||||
shell: bash
|
||||
env:
|
||||
PACKAGES: ${{ matrix.shard.packages }}
|
||||
CARGO: ${{ matrix.platform.cargo }}
|
||||
TARGET: ${{ matrix.platform.target }}
|
||||
run: |
|
||||
failed=()
|
||||
for package in $PACKAGES; do
|
||||
echo "::group::clippy $package"
|
||||
if ! $CARGO clippy --package "$package" --target "$TARGET" --all-targets -- -D warnings; then
|
||||
failed+=("$package")
|
||||
# the features of `dialog` cannot all be enabled at once
|
||||
elif [ "$package" != tauri-plugin-dialog ] && ! $CARGO clippy --package "$package" --target "$TARGET" --all-targets --all-features -- -D warnings; then
|
||||
failed+=("$package (--all-features)")
|
||||
fi
|
||||
echo "::endgroup::"
|
||||
done
|
||||
|
||||
- name: clippy ${{ matrix.package }} --all-features
|
||||
if: matrix.package != 'tauri-plugin-dialog'
|
||||
run: ${{ matrix.platform.cargo }} clippy --package ${{ matrix.package }} --target ${{ matrix.platform.target }} --all-targets --all-features -- -D warnings
|
||||
if [ ${#failed[@]} -gt 0 ]; then
|
||||
for package in "${failed[@]}"; do
|
||||
echo "::error title=clippy failed::$package"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
Reference in new issue
Block a user