Repository navigation
137 lines (132 loc) · 5.8 KB
/
Copy pathci.yml
File metadata and controls
137 lines (132 loc) · 5.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: CI
on:
# push 只在真正需要集成门禁的分支上触发;feature 分支通过 PR 门禁
# (pull_request) 校验,避免 push 与 pull_request 双重触发导致同一份
# 3-OS 矩阵 + 依赖门禁被重复编译一遍。
push:
branches: [dev, main]
pull_request:
concurrency:
# 同一 PR / 同一分支只保留最新一次运行;连续 push 或改 PR 时取消已 superseded
# 的旧 run,省 runner 时间与缓存写冲突。不同 PR、不同分支之间互不影响。
group: ci-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
rust:
name: Rust (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@1.97.1
with:
components: rustfmt, clippy
targets: wasm32-wasip2
# 缓存 ~/.cargo 注册表与 target/。稳定的 workflow job 名区分 build 与
# dependency-policy 缓存;Rust 环境和 Cargo manifests/lock 哈希负责在
# 工具链或依赖变化时生成新 key,并从同环境的旧依赖缓存渐进恢复。
- name: Cache cargo registry and build artifacts
uses: Swatinem/rust-cache@v2
with:
workspaces: |
. -> target
cache-on-failure: true
add-job-id-key: true
add-rust-environment-hash-key: true
- name: Install Linux system dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libfontconfig1-dev libwayland-dev libxkbcommon-dev libxkbcommon-x11-dev
- name: Enforce LF and UTF-8 (no CRLF/BOM)
shell: bash
run: |
set -euo pipefail
bad=
if git ls-files --eol | grep -Eq '^i/(crlf|mixed)'; then
bad=yes
echo "::error::CRLF/mixed line endings in the git index; run 'git add --renormalize .' and commit." >&2
git ls-files --eol | grep -E '^i/(crlf|mixed)' | sed 's/^/ /'
fi
while IFS= read -r -d '' f; do
if head -c 3 "$f" | od -An -tx1 | grep -q 'ef bb bf'; then
bad=yes
echo "::error::UTF-8 BOM in tracked file: $f" >&2
fi
done < <(git ls-files -z)
test -z "$bad"
- name: Format
run: cargo fmt --all -- --check
- name: Check
run: cargo check --workspace --exclude floatile-clock-wasm --all-targets --locked
- name: Clippy
run: cargo clippy --workspace --exclude floatile-clock-wasm --all-targets --locked -- -D warnings
- name: Rust SDK API docs
if: runner.os == 'Linux'
env:
RUSTDOCFLAGS: -D warnings
run: cargo doc -p floatile-sdk -p floatile-sdk-macros -p floatile-ui-schema --no-deps --locked
- name: Set up TypeScript SDK toolchain
if: runner.os == 'Linux'
uses: actions/setup-node@v7
with:
node-version: '26.8.0'
- name: Set up pnpm
if: runner.os == 'Linux'
uses: pnpm/action-setup@v5
with:
version: '11.3.0'
- name: TypeScript SDK generated contract
if: runner.os == 'Linux'
run: |
pnpm install --dir sdk/typescript --frozen-lockfile
cargo run -p floatile-cli --locked -- schema ui target/floatile-ui-registry.json
node sdk/typescript/scripts/generate-components.mjs target/floatile-ui-registry.json sdk/typescript/src/generated/components.ts --check
pnpm --dir sdk/typescript typecheck
pnpm --dir sdk/typescript test
pnpm --dir sdk/typescript build
- name: Build WASI guest (hermetic integration tests)
# 集成测试读取 target/wasm32-wasip2/debug 下的组件;先构建保证干净
# checkout 上测试不依赖执行顺序或测试内并发构建。
run: cargo build --manifest-path plugins/clock-wasm/Cargo.toml --target wasm32-wasip2 --locked
- name: Test
run: cargo test --workspace --exclude floatile-clock-wasm --all-targets --locked
- name: Release build
run: cargo build --workspace --exclude floatile-clock-wasm --release --locked
- name: WASI guest validate and WIT single-source check
if: runner.os == 'Linux'
run: |
set -euo pipefail
curl -sSfL https://github.com/bytecodealliance/wasm-tools/releases/download/v1.254.0/wasm-tools-1.254.0-x86_64-linux.tar.gz \
| tar xz -C /usr/local/bin --strip-components=1 wasm-tools-1.254.0-x86_64-linux/wasm-tools
wasm-tools validate target/wasm32-wasip2/debug/floatile_clock_wasm.wasm
sdk=$(grep -oP 'ENGINE_API_VERSION: &str = "\K[^"]+' crates/floatile-sdk/src/lib.rs)
api=$(grep -oP 'ENGINE_API_VERSION: &str = "\K[^"]+' crates/floatile-plugin-api/src/lib.rs)
test "$sdk" = "$api"
echo "guest component valid; WIT single-source OK (engineApiVersion=$sdk)"
dependencies:
name: Dependency policy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Cache cargo registry for dependency check
# 此 job 只复用 Cargo registry/git 数据;独立 job key 防止它与 Rust
# build job 竞争同一个不可变缓存,cache-targets: false 避免搬运 target/。
uses: Swatinem/rust-cache@v2
with:
workspaces: |
. -> target
cache-targets: false
cache-bin: false
add-job-id-key: true
add-rust-environment-hash-key: true
- uses: EmbarkStudios/cargo-deny-action@v2
with:
rust-version: "1.97.1"
arguments: --locked
command: check advisories bans sources