Repository navigation
262 lines (260 loc) · 10.7 KB
/
Copy pathci.yml
File metadata and controls
262 lines (260 loc) · 10.7 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
test-hotspot-jdk-ci:
if: github.repository == 'dynamic-datasource/dynamic-datasource-samples'
name: Test CI - JDK ${{ matrix.java-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
matrix:
os: [ 'ubuntu-latest' ]
java-version: [ '17', '21', '25', '27' ]
steps:
- uses: actions/checkout@v7
- name: Setup java
uses: actions/setup-java@v6
with:
distribution: 'temurin'
java-version: ${{ matrix.java-version }}
cache: 'maven'
- name: Build all test with Maven
run: ./mvnw -T1C -e clean test
test-minimum-hotspot-jdk-ci:
if: github.repository == 'dynamic-datasource/dynamic-datasource-samples'
name: Test CI - JDK ${{ matrix.java-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
matrix:
os: [ 'ubuntu-latest' ]
java-version: [ '8' ]
steps:
- uses: actions/checkout@v7
- name: Setup java
uses: actions/setup-java@v6
with:
distribution: 'temurin'
java-version: ${{ matrix.java-version }}
cache: 'maven'
- name: Build spring-boot-2 samples with Maven
run: ./mvnw -am -pl spring-boot-2/shardingsphere-jdbc-4.x-spring-sample,spring-boot-2/shardingsphere-jdbc-5.x-spring-sample -T1C -B -e clean test
test-native-ci:
if: github.repository == 'dynamic-datasource/dynamic-datasource-samples'
name: Native Test CI - GraalVM ${{ matrix.module }} on ubuntu-latest
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
# 每个模块单独一个 job,按历史耗时从长到短排列,并发受限排队时先起慢的。
module:
- spring-boot-4/shardingsphere-jdbc-5.x-core-sample
- spring-boot-4/config-nacos-sample
- spring-boot-4/tx-local-sample
- spring-boot-4/config-consul-sample
- spring-boot-4/add-remove-datasource-sample
- spring-boot-4/mybatis-sample
- spring-boot-4/load-datasource-from-jdbc-sample
- spring-boot-4/quartz-sample
- spring-boot-4/spel-sample
- spring-boot-4/druid-sample
- spring-boot-4/jdbc-template-sample
- spring-boot-4/name-pattern-sample
- spring-boot-3/springboot3-sample
- spring-boot-4/mybatisplus3-sample
steps:
- uses: actions/checkout@v7
- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
version: '25.3.4.1'
distribution: 'graalvm-community'
cache: 'maven'
# 各模块的 native / nativeTest 配置由 spring-boot-3 / spring-boot-4 父模块统一管理,
# 子模块声明插件即 opt-in。本地可用 `mvn -Pnative package` 构建 native image,
# 用 `mvn -PnativeTest test` 在 native image 中运行测试。CI 覆盖的模块清单即上方的
# `matrix.module`;测试镜像在建 native image 时启用 quick build(`quickBuild`),
# 依赖 Testcontainers 的模块使用 runner 自带的 Docker。以下模块未纳入该任务:
# beetlsql-sample 依赖的 BeetlSQL 不支持 AOT 值序列化;
# tx-seata-sample 依赖的 Seata 在 AOT 处理阶段就会构造 GlobalTransactionScanner
# 并要求 Seata Server 可达,且其应用上下文在 AOT 类型预判定阶段存在 null Advisor
# 问题,故暂不纳入。
- name: Native test with Maven
run: ./mvnw -B -e -PnativeTest clean test -pl "${{ matrix.module }}"
# polyglot/:三个 web 示例通过各自语言的 FFI 调用 dynamic-datasource 的 GraalVM native 共享库 libdynamicds.so。
# 与本地开发一样,各示例的构建(build.rs、hatch_build.py、npm 的 pretest)会先用 GraalVM 构建共享库;
# 测试先用 H2,再用各自语言的 Testcontainers 启动 PostgreSQL。dynamic-datasource-ffi 的 JVM 单测已由 Test CI 覆盖,
# 格式检查与 lint 在 Lint & Format CI 中完成。
polyglot-rust-ci:
if: github.repository == 'dynamic-datasource/dynamic-datasource-samples'
name: Polyglot CI - rust-axum-sample
runs-on: ubuntu-latest
timeout-minutes: 30
env:
DD_LOG_LEVEL: warn
defaults:
run:
working-directory: polyglot/rust-axum-sample
steps:
- uses: actions/checkout@v7
- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
version: '25.3.4.1'
distribution: 'graalvm-community'
cache: 'maven'
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: polyglot/rust-axum-sample
- name: Test with H2 and PostgreSQL
run: cargo test --locked
polyglot-python-ci:
if: github.repository == 'dynamic-datasource/dynamic-datasource-samples'
name: Polyglot CI - python-fastapi-sample
runs-on: ubuntu-latest
timeout-minutes: 30
env:
DD_LOG_LEVEL: warn
defaults:
run:
working-directory: polyglot/python-fastapi-sample
steps:
- uses: actions/checkout@v7
- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
version: '25.3.4.1'
distribution: 'graalvm-community'
cache: 'maven'
# setup-uv 从 v8 起不再发布 v8、v9 这样的浮动大版本 tag,只能写完整版本号
- name: Setup uv
uses: astral-sh/setup-uv@v10.3.0
with:
enable-cache: true
cache-dependency-glob: polyglot/python-fastapi-sample/uv.lock
- name: Test with H2 and PostgreSQL
run: uv run --locked pytest -q
polyglot-typescript-ci:
if: github.repository == 'dynamic-datasource/dynamic-datasource-samples'
name: Polyglot CI - typescript-hono-sample
runs-on: ubuntu-latest
timeout-minutes: 30
env:
DD_LOG_LEVEL: warn
defaults:
run:
working-directory: polyglot/typescript-hono-sample
steps:
- uses: actions/checkout@v7
- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
version: '25.3.4.1'
distribution: 'graalvm-community'
cache: 'maven'
# node:ffi 从 Node.js 26.9 起默认开启
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: '26'
cache: 'npm'
cache-dependency-path: polyglot/typescript-hono-sample/package-lock.json
- name: Test with H2 and PostgreSQL
run: |
npm ci --no-audit --no-fund
npm test
# .devcontainer/:给本机没有 GraalVM、Rust、uv、Node.js 的贡献者用的开发容器。
# 在容器里执行 CONTRIBUTING.md 为 polyglot/ 写的验证命令,确保容器能构建,文档里的验证方式在容器里确实可用。
# 容器自带 Docker 引擎(docker-in-docker),Testcontainers 用的是它,而不是 runner 的 Docker。
# 用默认的 vscode 用户:action 会把它的 uid 改成与 runner 用户一致,rootless Docker 才需要 DEVCONTAINER_USER=root。
devcontainer-ci:
if: github.repository == 'dynamic-datasource/dynamic-datasource-samples'
name: Dev Container CI
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- name: Verify in Dev Container
uses: devcontainers/ci@v0.3
with:
# push 的默认值是 filter,没有 imageName 时 push 事件上会报 imageName is required;不推送镜像就写 never
push: never
# runCmd 用 `bash -c` 执行,不带 -e,需要自己 set -e
runCmd: |
set -ex
export DD_LOG_LEVEL=warn
java -version
native-image --version
rustc --version
uv --version
node --version
docker version
./mvnw -B -e -pl polyglot/dynamic-datasource-ffi test
(cd polyglot/rust-axum-sample && cargo fmt --check && cargo clippy --all-targets -- -D warnings && cargo test)
(cd polyglot/python-fastapi-sample && uv run ruff format --check . && uv run ruff check . && uv run pytest)
(cd polyglot/typescript-hono-sample && npm ci && npm run format:check && npm run typecheck && npm test)
lint-format-ci:
if: github.repository == 'dynamic-datasource/dynamic-datasource-samples'
name: Lint & Format CI
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v7
- name: Setup java
uses: actions/setup-java@v6
with:
distribution: 'temurin'
# Checkstyle 14 与 google-java-format 1.30+ 都要求 JDK 21+;polyglot/ 只在 JDK 25+ 上参与构建,
# 用 25 才能把它也检查到。
java-version: '25'
cache: 'maven'
- name: Check format with Spotless
run: ./mvnw -B -e spotless:check
# 同时检查 polyglot/ 下除 JSON、Markdown、lock 文件外所有文件的 license 头(见 polyglot/pom.xml)
- name: Check license header with License Maven Plugin
run: ./mvnw -B -e license:check
- name: Check lint with Checkstyle
run: ./mvnw -B -e checkstyle:check
# polyglot/ 的三个语言示例:格式检查与 lint 都用不到 libdynamicds(cargo clippy 只做检查,不链接),
# 这里也没有 GraalVM,各示例的构建只打印警告,不会构建共享库
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
workspaces: polyglot/rust-axum-sample
- name: Check format and lint of rust-axum-sample
working-directory: polyglot/rust-axum-sample
run: |
cargo fmt --check
cargo clippy --all-targets --locked -- -D warnings
- name: Setup uv
uses: astral-sh/setup-uv@v10.3.0
with:
enable-cache: true
cache-dependency-glob: polyglot/python-fastapi-sample/uv.lock
- name: Check format and lint of python-fastapi-sample
working-directory: polyglot/python-fastapi-sample
run: |
uv run --locked ruff format --check .
uv run --locked ruff check .
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: '26'
cache: 'npm'
cache-dependency-path: polyglot/typescript-hono-sample/package-lock.json
- name: Check format and types of typescript-hono-sample
working-directory: polyglot/typescript-hono-sample
run: |
npm ci --no-audit --no-fund
npm run format:check
npm run typecheck