Repository navigation
146 lines (138 loc) · 4.39 KB
/
Copy pathci.yml
File metadata and controls
146 lines (138 loc) · 4.39 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
138
139
140
141
142
143
144
145
146
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
- uses: Swatinem/rust-cache@v2
with:
key: xtask
- name: Scan conventions
run: cargo xtask check rules
- name: Lint shell scripts
run: shellcheck scripts/*.sh deploy/plugin-stats/*.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
plugin-stats:
name: Plugin statistics service
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: integration-only
MYSQL_DATABASE: toolforge_stats_test
ports: ["3306:3306"]
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -pintegration-only"
--health-interval=5s --health-timeout=5s --health-retries=20
defaults:
run:
working-directory: apps/server
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6
with:
# setup-go v6 exports GOTOOLCHAIN=local, so pin the exact version
# go.mod requires; '1.26.x' may resolve to an older patch.
go-version: '1.26.10'
cache-dependency-path: apps/server/go.sum
- name: Format, vet and test against MySQL
env:
TEST_MYSQL_DSN: root:integration-only@tcp(127.0.0.1:3306)/toolforge_stats_test?parseTime=true
run: |
test -z "$(gofmt -l .)"
go vet ./...
go test -race ./...
go build ./cmd/plugin-stats
- name: Check dependency vulnerabilities
run: go run golang.org/x/vuln/cmd/govulncheck@v1.1.4 ./...
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