Files
navop/.github/workflows/ci.yml
Workflow config file is invalid. Please check your config file: getMatrixes: matrix include must be a list of mappings
胡飞 0b3a5c0a9b build: HTML 预览的 embedded-webview 改为全平台默认关闭
- `main` 与 `crates/ai_chat_view` 的 `default` 都去掉 `embedded-webview`,
  需要时显式 `--features embedded-webview` 打开
- 删除 `script/linux-release-features.sh`:Linux 不再需要专属 feature 列表,
  三个平台发同一种形态,`release.yml` 的 Linux 分支回到默认构建
- 移除 `NAVOP_LINUX_EMBEDDED_WEBVIEW` 开关;Windows 32 位的显式列表
  (默认集减 shell-plugins)同步去掉该 feature,避免 win32 成为唯一的另一种形态
- `ci.yml` 补编 opt-in 形态(`cargo check -p main --features embedded-webview`
  与 `cargo check -p ai_chat_view --features embedded-webview --tests`):
  默认形态由 `cargo test --all` 覆盖,两个半边都得有地方编到
- `test-release-packaging.mjs` 改为锁「没有平台构建打开该 feature」+ opt-in 形态有 CI 覆盖
- 注释同步:`main/Cargo.toml`(原因与降级行为)、`install-linux.sh`、
  `package-linux-gpu-stack.py`、`AGENTS.md`

动机:WebKitGTK 4.1 无法随 Linux 发布包提供(带它的发行版都在 glibc 2.39+ 上、
`WebKitWebProcess` 按编译期路径解析),而只让 Linux 关掉会让三个平台各发一种形态,
需要多测一套、多维护一个平台专属列表。关闭后 HTML 预览弹窗降级为
「无法创建 HTML 预览 webview,已保留源码视图」,「用浏览器打开」「下载 HTML」不受影响。

验证:`cargo check -p main`(默认形态)、`cargo check -p main --features embedded-webview`、
`cargo check -p ai_chat_view --features embedded-webview --tests` 三者均通过;
`node --test script/test-release-packaging.mjs` 29/29;两个 workflow YAML 解析通过。
2026-09-22 17:24:06 +08:00

233 lines
8.1 KiB
YAML

name: CI
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
inputs:
platform:
description: "Run all platforms or only one platform"
required: true
type: choice
default: all
options:
- all
- linux
- windows
- macos
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
SCCACHE_IDLE_TIMEOUT: "7200"
jobs:
prepare:
name: Prepare CI matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Resolve requested platforms
id: matrix
env:
REQUESTED_PLATFORM: ${{ inputs.platform }}
run: |
set -euo pipefail
platform="${REQUESTED_PLATFORM:-all}"
linux='{"target":"x86_64-unknown-linux-gnu","run_on":"ubuntu-latest","platform":"linux"}'
windows='{"target":"x86_64-pc-windows-msvc","run_on":"windows-2022","platform":"windows"}'
macos='{"target":"aarch64-apple-darwin","run_on":"macos-latest","platform":"macos"}'
case "$platform" in
all) matrix="[$macos,$linux,$windows]" ;;
linux) matrix="[$linux]" ;;
windows) matrix="[$windows]" ;;
macos) matrix="[$macos]" ;;
*) echo "::error::Unsupported platform: $platform"; exit 1 ;;
esac
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
# 发布 PR 只改 CHANGELOG + 版本号,跑全平台测试没有意义:这一层只做分类,
# 并在判定为发布改动时就地校验 changelog 与版本号;其余 PR 照旧跑全量测试。
classify:
name: Classify changes
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
outputs:
release_only: ${{ steps.check.outputs.release_only }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Classify and validate release-only changes
id: check
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: python3 script/release_pr.py check
test:
name: Test (${{ matrix.platform }}, ${{ matrix.target }})
needs: [prepare, classify]
if: ${{ needs.classify.outputs.release_only != 'true' }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.prepare.outputs.matrix) }}
runs-on: ${{ matrix.run_on }}
steps:
- uses: actions/checkout@v7
- name: Install NASM
if: ${{ matrix.platform == 'windows' }}
shell: pwsh
run: |
choco install nasm --no-progress --yes
$nasmDir = Join-Path $env:ProgramFiles "NASM"
$nasmExe = Join-Path $nasmDir "nasm.exe"
if (-not (Test-Path -LiteralPath $nasmExe -PathType Leaf)) {
throw "NASM executable was not found at '$nasmExe'"
}
$env:Path = "$nasmDir;$env:Path"
$nasmDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
nasm -v
- name: Test release packaging
if: ${{ matrix.run_on == 'ubuntu-latest' }}
run: node --test script/test-release-packaging.mjs
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
cache: false
# sccache 只是构建加速器:GitHub Release CDN 偶发 504 会让下载安装失败,
# 此时必须退化成无缓存构建,而不是让整个测试 job 失败。
- name: Setup sccache
id: sccache
uses: mozilla-actions/sccache-action@v0.0.10
continue-on-error: true
- name: Initialize sccache
shell: bash
run: |
set -euo pipefail
if [ "${{ steps.sccache.outcome }}" != "success" ]; then
echo "::warning::sccache 安装失败,本次构建退化为无编译器缓存"
echo "RUSTC_WRAPPER=" >> "$GITHUB_ENV"
exit 0
fi
sccache --start-server
sccache --zero-stats
sccache --show-stats
- name: Restore shared Cargo inputs
uses: actions/cache@v6
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: navop-cargo-inputs-v1-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
navop-cargo-inputs-v1-${{ runner.os }}-
release-cargo-inputs-${{ runner.os }}-${{ matrix.target }}-
- name: Install system dependencies
if: ${{ matrix.platform != 'windows' }}
run: script/bootstrap
- name: Install lrzsz on Linux
if: ${{ matrix.platform == 'linux' }}
run: sudo apt-get update && sudo apt-get install -y lrzsz
- name: Install lrzsz on macOS
if: ${{ matrix.platform == 'macos' }}
run: brew list lrzsz >/dev/null 2>&1 || brew install lrzsz
- name: Install wasm-tools
run: cargo install wasm-tools --locked --version 1.251.0
- name: Test Linux
if: ${{ matrix.platform == 'linux' }}
run: |
cargo test --all
# 默认构建(三平台一致)不带 `embedded-webview`:它的宿主 WebView 在 Linux 上
# 无法随发布包提供(原因见 main/Cargo.toml)。`cargo test --all` 编的正是这个
# 默认形态,所以「显式打开该 feature」的那一半反而没有地方会编到 —— 在这里补一次
# check,免得它悄悄腐烂到有人真要用时才发现。
# 本步骤依赖 `script/install-linux.sh` 装上的 webkit2gtk-4.1 开发包。
- name: Check the opt-in embedded webview feature
if: ${{ matrix.platform == 'linux' }}
run: |
set -euo pipefail
cargo check -p ai_chat_view --features embedded-webview --tests
cargo check -p main --features embedded-webview
- name: Test Windows
if: ${{ matrix.platform == 'windows' }}
shell: pwsh
run: ./script/test-windows.ps1
- name: Test MacOS
if: ${{ matrix.platform == 'macos' }}
run: |
cargo test --all
- name: Show sccache statistics
if: always()
shell: bash
run: sccache --show-stats || true
windows-rdp-probe:
name: Windows RDP probe (${{ matrix.target }})
needs: [classify]
if: >-
${{
(inputs.platform == '' ||
inputs.platform == 'all' ||
inputs.platform == 'windows') &&
needs.classify.outputs.release_only != 'true'
}}
runs-on: windows-2022
env:
RUSTC_WRAPPER: ""
strategy:
fail-fast: false
matrix:
target:
- x86_64-pc-windows-msvc
- i686-pc-windows-msvc
steps:
- uses: actions/checkout@v7
- name: Install NASM
shell: pwsh
run: |
choco install nasm --no-progress --yes
$nasmDir = Join-Path $env:ProgramFiles "NASM"
$nasmExe = Join-Path $nasmDir "nasm.exe"
if (-not (Test-Path -LiteralPath $nasmExe -PathType Leaf)) {
throw "NASM executable was not found at '$nasmExe'"
}
$env:Path = "$nasmDir;$env:Path"
$nasmDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
nasm -v
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
cache: false
- name: Build ATL/MSVC probe
shell: pwsh
run: >-
./script/build-windows-rdp-probe.ps1
-Target "${{ matrix.target }}"
ci-gate:
name: CI gate
needs: [prepare, classify, test, windows-rdp-probe]
if: always()
runs-on: ubuntu-latest
steps:
- name: Fail if any CI job failed
run: |
if [ "${{ contains(needs.*.result, 'failure') }}" = "true" ] || [ "${{ contains(needs.*.result, 'cancelled') }}" = "true" ]; then
echo "::error::One or more CI jobs failed"
exit 1
fi