Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 125 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
product_matrix: ${{ steps.products.outputs.product_matrix }}

steps:
- name: Resolve requested platforms
Expand All @@ -54,6 +55,38 @@ jobs:
esac
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"

# 产品检查是「一个产品 × 一个目标」一条,矩阵项比测试矩阵多得多,
# 所以单独按 REQUESTED_PLATFORM 裁剪,让 workflow_dispatch 选单个平台时
# 只跑该平台的三条。
- name: Resolve product check matrix
id: products
env:
REQUESTED_PLATFORM: ${{ inputs.platform }}
run: |
set -euo pipefail
platform="${REQUESTED_PLATFORM:-all}"
navop_linux='{"product":"navop","target":"x86_64-unknown-linux-gnu","run_on":"ubuntu-latest","platform":"linux","args":""}'
navop_macos='{"product":"navop","target":"aarch64-apple-darwin","run_on":"macos-latest","platform":"macos","args":""}'
navop_win_x64='{"product":"navop","target":"x86_64-pc-windows-msvc","run_on":"windows-2022","platform":"windows","args":"--features windows-native-rdp"}'
navop_win_x86='{"product":"navop","target":"i686-pc-windows-msvc","run_on":"windows-2022","platform":"windows","args":"--no-default-features --features wasm-components,windows-native-rdp"}'
shell_linux='{"product":"navop-shell","target":"x86_64-unknown-linux-gnu","run_on":"ubuntu-latest","platform":"linux","args":""}'
shell_macos='{"product":"navop-shell","target":"aarch64-apple-darwin","run_on":"macos-latest","platform":"macos","args":""}'
shell_win='{"product":"navop-shell","target":"x86_64-pc-windows-msvc","run_on":"windows-2022","platform":"windows","args":""}'
data_linux='{"product":"navop-data","target":"x86_64-unknown-linux-gnu","run_on":"ubuntu-latest","platform":"linux","args":""}'
data_macos='{"product":"navop-data","target":"aarch64-apple-darwin","run_on":"macos-latest","platform":"macos","args":""}'
data_win='{"product":"navop-data","target":"x86_64-pc-windows-msvc","run_on":"windows-2022","platform":"windows","args":""}'
linux="[$navop_linux,$shell_linux,$data_linux]"
macos="[$navop_macos,$shell_macos,$data_macos]"
windows="[$navop_win_x64,$navop_win_x86,$shell_win,$data_win]"
case "$platform" in
all) product_matrix="[$navop_linux,$navop_macos,$navop_win_x64,$navop_win_x86,$shell_linux,$shell_macos,$shell_win,$data_linux,$data_macos,$data_win]" ;;
linux) product_matrix="$linux" ;;
windows) product_matrix="$windows" ;;
macos) product_matrix="$macos" ;;
*) echo "::error::Unsupported platform: $platform"; exit 1 ;;
esac
echo "product_matrix=$product_matrix" >> "$GITHUB_OUTPUT"

# 发布 PR 只改 CHANGELOG + 版本号,跑全平台测试没有意义:这一层只做分类,
# 并在判定为发布改动时就地校验 changelog 与版本号;其余 PR 照旧跑全量测试。
classify:
Expand Down Expand Up @@ -174,6 +207,97 @@ jobs:
shell: bash
run: sccache --show-stats || true

# 发版矩阵(.github/workflows/release.yml)是「一个产品 × 一个目标」各自编译:
# 每个 job 只带自己那一个产品,extension-runtime 之类共享 crate 的 feature 就按
# 该产品的特性集求值。而 `cargo test --all` 会把整个 workspace 的特性合并求值,
# 于是「某个产品单独构建时这段代码没有调用者 / 这个 feature 不存在」这类问题
# 只有在发版时才炸:beta.1 的 `navop ... does not contain these features`、
# beta.2 的 navop-data 未门控终端视图、beta.3 的 install_flow 死代码都是这一类。
#
# 这里按发版矩阵逐产品、逐目标编译一次,参数抄自 release.yml 的构建步骤
# (独立产品不传 feature;navop 的 win32 是「默认集减去 shell-plugins」)。
# 只把 `cargo build --release` 换成 `cargo check`:feature 门控、未使用导入、
# 死代码在 check 阶段就会带着 `-D warnings` 报错,代价比完整构建小一个量级。
# 覆盖 linux x64 / macOS arm64 / Windows x64(+ navop 的 win32)这几个
# 真正出过问题的形态;macOS x64 与 linux arm64 只是同一份代码换目标,暂不重复。
product-check:
name: Build shape (${{ matrix.product }} / ${{ matrix.target }})
needs: [prepare, classify]
if: ${{ needs.classify.outputs.release_only != 'true' }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.prepare.outputs.product_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: Configure MSVC environment
if: ${{ matrix.platform == 'windows' }}
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ contains(matrix.target, 'i686') && 'x86' || 'x64' }}
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
cache: false
- name: Setup sccache
id: sccache
uses: mozilla-actions/[email protected]
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 --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
# Windows 必须走 PowerShell:Git Bash 的 PATH 里 `link.exe` 是 GNU coreutils 的
# `link`,会把 MSVC 的链接器盖掉(报 `/usr/bin/link: extra operand`)。
# `shell:` 不支持 matrix 上下文(GitHub 报 Unrecognized named-value: 'matrix'),
# 所以按平台拆成两步,各自写死 shell。
- name: Check the product build shape (Windows)
if: ${{ matrix.platform == 'windows' }}
shell: pwsh
run: cargo check --locked -p ${{ matrix.product }} --target ${{ matrix.target }} ${{ matrix.args }}
- name: Check the product build shape
if: ${{ matrix.platform != 'windows' }}
shell: bash
run: |
set -euo pipefail
cargo check --locked -p ${{ matrix.product }} --target ${{ matrix.target }} ${{ matrix.args }}

windows-rdp-probe:
name: Windows RDP probe (${{ matrix.target }})
needs: [classify]
Expand Down Expand Up @@ -220,7 +344,7 @@ jobs:

ci-gate:
name: CI gate
needs: [prepare, classify, test, windows-rdp-probe]
needs: [prepare, classify, test, product-check, windows-rdp-probe]
if: always()
runs-on: ubuntu-latest
steps:
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,12 @@ jobs:
;;
all)
if [ -n "$standalone_matrix" ]; then
# 两个 JSON 数组拼成一个:去掉各自方括号后以逗号相连。
# 条目本身是不含空格的单行 JSON,全局替换空格安全。
combined="$(printf '%s %s' "$full_matrix" "$standalone_matrix" | tr -d '][' | tr ' ' ',')"
matrix="[${combined}]"
# 两个 JSON 数组拼成一个:各去掉一层方括号后以逗号相连。
# 不能用 `tr ' ' ','` 拼接:`bundle_name` 里带空格("Navop Shell"),
# 那样会把空格也换成逗号,macOS 产物目录变成 `Navop,Shell.app`,
# 后续 `tar` 找不到包。方括号用参数展开去掉,其余字节原样保留。
combined="${full_matrix%]},${standalone_matrix#\[}"
matrix="$combined"
else
matrix="$full_matrix"
fi
Expand Down
Loading
Loading