Repository navigation
122 lines (115 loc) · 3.77 KB
/
Copy pathci.yml
File metadata and controls
122 lines (115 loc) · 3.77 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
name: CI
on:
pull_request:
push:
branches: [main, dev]
workflow_dispatch:
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
rules:
name: Convention rules
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
# 插件 manifest 检查以最近的 v* 标签为基准
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
with:
# 插件版本检查按插件后端的 WASM 目标解析依赖(cargo tree)
targets: wasm32-wasip2
- uses: Swatinem/rust-cache@v2
with:
key: xtask
- name: Scan conventions
run: cargo xtask check rules
# 已发布的在线插件改了输入却没有递增版本,合入 dev 后发布必然失败:在 PR 里就报出来。
# 基准是 merge-base,只看本 PR 带来的改动;修复方式见失败输出(手动改版本或 --fix)
- name: Published plugins bump their version
if: github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ github.token }}
BASE_REF: ${{ github.base_ref }}
run: cargo xtask plugin versions --base "$(git merge-base "origin/$BASE_REF" HEAD)"
- name: Lint shell scripts
run: shellcheck scripts/*.sh
rust:
name: Rust (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v7
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
# tf-wasm 的测试会把夹具插件编译为 WASM 组件
targets: wasm32-wasip2
- uses: Swatinem/rust-cache@v2
- name: rustfmt, clippy and tests
run: cargo xtask check rust
web:
name: Web
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v7
with:
node-version: 22
cache: pnpm
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: xtask
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Typecheck and build
run: cargo xtask check web
bundle:
name: Bundle (${{ matrix.os }})
# 完整打包较慢,只在合入主干分支或手动触发时运行
if: github.event_name != 'pull_request'
needs: [rules, rust, web]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v7
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v7
with:
node-version: 22
cache: pnpm
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build application
run: pnpm build --no-bundle
- name: Report binary size
shell: bash
run: |
for f in target/release/toolforge target/release/toolforge.exe; do
[ -f "$f" ] && echo "### Binary size: $(du -h "$f" | cut -f1)" >> "$GITHUB_STEP_SUMMARY"
done
true