Repository navigation
204 lines (167 loc) · 5.96 KB
/
Copy pathrust.yml
File metadata and controls
204 lines (167 loc) · 5.96 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
name: Rust CI
on:
push:
paths:
- '**/*.rs'
- 'Cargo.toml'
- 'Cargo.lock'
- 'rust-toolchain.toml'
- 'frontend-panel/package.json'
- 'frontend-panel/generated/openapi.json'
- 'frontend-panel/src/services/api.generated.ts'
- 'scripts/coverage-summary.mjs'
- '.github/workflows/rust.yml'
branches: [master]
pull_request:
paths:
- '**/*.rs'
- 'Cargo.toml'
- 'Cargo.lock'
- 'rust-toolchain.toml'
- 'frontend-panel/package.json'
- 'frontend-panel/generated/openapi.json'
- 'frontend-panel/src/services/api.generated.ts'
- 'scripts/coverage-summary.mjs'
- '.github/workflows/rust.yml'
branches: [master, develop]
concurrency:
group: rust-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
# CI runners perform one clean build per job. Incremental artifacts consume
# substantial disk without providing the local edit-compile feedback benefit.
CARGO_INCREMENTAL: "0"
# The local dev profile favors maximum parallel code generation. CI runners
# have fewer cores, so keep test artifacts smaller and cheaper to link.
CARGO_PROFILE_TEST_CODEGEN_UNITS: "16"
CARGO_PROFILE_TEST_DEBUG: "0"
permissions:
contents: read
jobs:
format-and-clippy:
name: Format and Clippy
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v6
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Format check
run: cargo fmt -- --check
- name: Install media processing dependencies
run: sudo apt-get update && sudo apt-get install -y libvips-tools ffmpeg
- name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2
with:
shared-key: clippy-v1
- name: Clippy
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
openapi-sdk-drift:
name: OpenAPI and generated SDK drift
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v6
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install media processing dependencies
run: sudo apt-get update && sudo apt-get install -y libvips-tools ffmpeg
- name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2
with:
shared-key: openapi-v1
- name: Generate OpenAPI specification
run: cargo test --features openapi --test generate_openapi
- name: Setup bun
uses: oven-sh/setup-bun@v2
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
- name: Install frontend dependencies
working-directory: frontend-panel
run: bun install --frozen-lockfile
- name: Generate TypeScript SDK
working-directory: frontend-panel
run: bun run generate-api
- name: Verify generated files are up to date
run: |
git diff --exit-code -- \
frontend-panel/generated/openapi.json \
frontend-panel/src/services/api.generated.ts
coverage:
name: Tests and coverage
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- uses: actions/checkout@v6
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Install media processing dependencies
run: sudo apt-get update && sudo apt-get install -y libvips-tools ffmpeg
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov
- name: Prepare coverage output directory
run: mkdir -p coverage/rust
- name: Setup bun
uses: oven-sh/setup-bun@v2
- name: Run tests with coverage
run: cargo llvm-cov --workspace --no-fail-fast --lcov --output-path coverage/rust/lcov.info
- name: Generate HTML coverage report
if: success()
run: cargo llvm-cov report --html --output-dir coverage/rust/html
- name: Publish coverage summary
if: always() && hashFiles('coverage/rust/lcov.info') != ''
run: bun scripts/coverage-summary.mjs "Rust" coverage/rust/lcov.info
- name: Upload coverage reports to Codecov
if: always() && hashFiles('coverage/rust/lcov.info') != ''
uses: codecov/codecov-action@v7
with:
files: coverage/rust/lcov.info
flags: rust
name: rust-backend
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
- name: Upload coverage artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: rust-coverage
if-no-files-found: ignore
path: coverage/rust
integration-backends:
name: Integration tests (${{ matrix.backend }})
runs-on: ubuntu-latest
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
backend: [postgres, mysql]
env:
ASTER_TEST_DATABASE_BACKEND: ${{ matrix.backend }}
# 复用 testcontainers 容器,测试间共享 Postgres/MySQL 实例
TESTCONTAINERS_REUSE_ENABLED: "true"
steps:
- uses: actions/checkout@v6
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install media processing dependencies
run: sudo apt-get update && sudo apt-get install -y libvips-tools ffmpeg
- name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2
with:
shared-key: integration-v2
# testcontainers 使用的 Docker 在 ubuntu-latest 上预装
- name: Verify Docker availability
run: docker version
# 只跑集成测试(tests/ 下的),单元测试已在 coverage job 中覆盖
- name: Run integration tests against ${{ matrix.backend }}
run: cargo test --tests --no-fail-fast