Skip to content

Commit f25c813

Browse files
authored
Kotlin follow-up + split CI into parallel jobs (#89)
## Summary - Split the monolithic `tests` CI job into parallel per-language jobs to reduce wall-clock time and avoid timeouts - Use `--no-default-features` for the core test job (no language runtimes needed) - Group languages needing no extra setup (C++, Java, Rust) into a matrix job - Create individual jobs for languages requiring specific runtime setup (C#, Dart, Go, Kotlin, OCaml, Python, Solidity, Swift, TypeScript) - Rename `maybe_compile_kotlin` to `compile_kotlin` so tests fail immediately if `kotlinc-native` is not installed instead of silently skipping ## Test plan - [x] `cargo test --locked --no-default-features` passes locally - [x] `cargo test --locked --no-default-features --features kotlin --no-run` compiles - [x] CI passes on all per-language jobs
1 parent 6eab3c5 commit f25c813

11 files changed

Lines changed: 514 additions & 162 deletions

File tree

.github/workflows/main.yml

Lines changed: 224 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ env:
1616
RUST_BACKTRACE: short
1717
RUSTFLAGS: "-D warnings"
1818
RUSTUP_MAX_RETRIES: 10
19-
# https://stackoverflow.com/questions/59119904/process-terminated-couldnt-find-a-valid-icu-package-installed-on-the-system-in
20-
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1
2119

2220
jobs:
2321
lint:
@@ -47,6 +45,7 @@ jobs:
4745
run: |
4846
cargo clippy --locked --workspace --all-features --all-targets
4947
48+
# Core tests: analyzer, test_utils, indent (no language runtimes needed)
5049
tests:
5150
runs-on: ubuntu-latest
5251

@@ -55,6 +54,118 @@ jobs:
5554

5655
- uses: actions-rust-lang/setup-rust-toolchain@v1
5756

57+
- name: Cache Dependencies
58+
uses: Swatinem/rust-cache@v2
59+
60+
- name: Test (dev)
61+
run: cargo test --locked --no-default-features
62+
63+
- name: Test (release)
64+
run: cargo test --locked --release --no-default-features
65+
66+
# Languages that need no extra runtime setup (clang++/javac/cargo available on ubuntu)
67+
test-simple:
68+
runs-on: ubuntu-latest
69+
strategy:
70+
fail-fast: false
71+
matrix:
72+
feature: [cpp, java, rust]
73+
74+
steps:
75+
- uses: actions/checkout@v3
76+
77+
- uses: actions-rust-lang/setup-rust-toolchain@v1
78+
79+
- name: Cache Dependencies
80+
uses: Swatinem/rust-cache@v2
81+
82+
- name: Test (dev) - ${{ matrix.feature }}
83+
run: cargo test --locked --no-default-features --features ${{ matrix.feature }}
84+
85+
- name: Test (release) - ${{ matrix.feature }}
86+
run: cargo test --locked --release --no-default-features --features ${{ matrix.feature }}
87+
88+
test-csharp:
89+
runs-on: ubuntu-latest
90+
91+
env:
92+
# https://stackoverflow.com/questions/59119904/process-terminated-couldnt-find-a-valid-icu-package-installed-on-the-system-in
93+
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1
94+
95+
steps:
96+
- uses: actions/checkout@v3
97+
98+
- uses: actions-rust-lang/setup-rust-toolchain@v1
99+
100+
- name: Cache Dependencies
101+
uses: Swatinem/rust-cache@v2
102+
103+
- name: Setup .NET
104+
uses: actions/setup-dotnet@v4
105+
with:
106+
dotnet-version: '6.0.x'
107+
108+
- name: Test (dev) - csharp
109+
run: cargo test --locked --no-default-features --features csharp
110+
111+
- name: Test (release) - csharp
112+
run: cargo test --locked --release --no-default-features --features csharp
113+
114+
test-dart:
115+
runs-on: ubuntu-latest
116+
117+
steps:
118+
- uses: actions/checkout@v3
119+
120+
- uses: actions-rust-lang/setup-rust-toolchain@v1
121+
122+
- name: Cache Dependencies
123+
uses: Swatinem/rust-cache@v2
124+
125+
- name: Setup Dart
126+
uses: dart-lang/setup-dart@v1
127+
with:
128+
sdk: 3.5.3
129+
130+
- name: Test (dev) - dart
131+
run: cargo test --locked --no-default-features --features dart
132+
133+
- name: Test (release) - dart
134+
run: cargo test --locked --release --no-default-features --features dart
135+
136+
test-golang:
137+
runs-on: ubuntu-latest
138+
139+
steps:
140+
- uses: actions/checkout@v3
141+
142+
- uses: actions-rust-lang/setup-rust-toolchain@v1
143+
144+
- name: Cache Dependencies
145+
uses: Swatinem/rust-cache@v2
146+
147+
- name: Setup Go
148+
uses: actions/setup-go@v3
149+
with:
150+
go-version: '~1.22.0'
151+
152+
- name: Test (dev) - golang
153+
run: cargo test --locked --no-default-features --features golang
154+
155+
- name: Test (release) - golang
156+
run: cargo test --locked --release --no-default-features --features golang
157+
158+
test-kotlin:
159+
runs-on: ubuntu-latest
160+
161+
steps:
162+
- uses: actions/checkout@v3
163+
164+
- uses: actions-rust-lang/setup-rust-toolchain@v1
165+
166+
- name: Cache Dependencies
167+
uses: Swatinem/rust-cache@v2
168+
58169
- name: Ensure Kotlin/Native Directory Exists
59170
run: mkdir -p /home/runner/.kotlin-native
60171
- name: Cache Kotlin/Native
@@ -63,7 +174,7 @@ jobs:
63174
with:
64175
path: /home/runner/.kotlin-native
65176
key: kotlin-native-v2.3.10-linux-x86_64
66-
- name: Setup Additional Languages (kotlin/native)
177+
- name: Setup Kotlin/Native
67178
if: ${{ steps.cache-kotlin-native.outputs.cache-hit != 'true' }}
68179
run: |
69180
KOTLIN_NATIVE_URL="https://github.com/JetBrains/kotlin/releases/download/v2.3.10/kotlin-native-prebuilt-linux-x86_64-2.3.10.tar.gz"
@@ -75,7 +186,84 @@ jobs:
75186
- name: Add Kotlin/Native to PATH
76187
run: echo "/home/runner/.kotlin-native/kotlin-native-prebuilt-linux-x86_64-2.3.10/bin" >> $GITHUB_PATH
77188

78-
- name: Setup Additional Languages (solidity)
189+
- name: Test (dev) - kotlin
190+
run: cargo test --locked --no-default-features --features kotlin
191+
192+
- name: Test (release) - kotlin
193+
run: cargo test --locked --release --no-default-features --features kotlin
194+
195+
test-ocaml:
196+
runs-on: ubuntu-latest
197+
198+
steps:
199+
- uses: actions/checkout@v3
200+
201+
- uses: actions-rust-lang/setup-rust-toolchain@v1
202+
203+
- name: Cache Dependencies
204+
uses: Swatinem/rust-cache@v2
205+
206+
- name: Setup OCaml
207+
uses: ocaml/setup-ocaml@v3
208+
with:
209+
ocaml-compiler: 5.0
210+
opam-disable-sandboxing: true
211+
212+
- name: Setup OCaml packages
213+
run: |
214+
eval $(opam env)
215+
opam install -y stdint uutf ppxlib
216+
217+
- name: Test (dev) - ocaml
218+
run: |
219+
eval $(opam env)
220+
cargo test --locked --no-default-features --features ocaml
221+
222+
- name: Test (release) - ocaml
223+
run: |
224+
eval $(opam env)
225+
cargo test --locked --release --no-default-features --features ocaml
226+
227+
test-python3:
228+
runs-on: ubuntu-latest
229+
230+
steps:
231+
- uses: actions/checkout@v3
232+
233+
- uses: actions-rust-lang/setup-rust-toolchain@v1
234+
235+
- name: Cache Dependencies
236+
uses: Swatinem/rust-cache@v2
237+
238+
- name: Setup Python
239+
uses: actions/setup-python@v4
240+
with:
241+
python-version: '3.9'
242+
243+
- name: Setup Python packages
244+
run: |
245+
python3 -m pip install pyre-check==0.0.59
246+
python3 -m pip install numpy==1.20.1
247+
echo '/github/home/.local/bin' >> $GITHUB_PATH
248+
249+
- name: Test (dev) - python3
250+
run: cargo test --locked --no-default-features --features python3
251+
252+
- name: Test (release) - python3
253+
run: cargo test --locked --release --no-default-features --features python3
254+
255+
test-solidity:
256+
runs-on: ubuntu-latest
257+
258+
steps:
259+
- uses: actions/checkout@v3
260+
261+
- uses: actions-rust-lang/setup-rust-toolchain@v1
262+
263+
- name: Cache Dependencies
264+
uses: Swatinem/rust-cache@v2
265+
266+
- name: Setup Foundry
79267
uses: foundry-rs/[email protected]
80268
- name: Ensure Solc Directory Exists
81269
run: mkdir -p /home/runner/.solc
@@ -93,45 +281,27 @@ jobs:
93281
version: v0.8.25
94282
- name: Add Solc to PATH
95283
run: echo "/home/runner/.solc" >> $GITHUB_PATH
96-
- name: List the content of the Solc cache
97-
run: ls /home/runner/.solc/v0.8.25/solc-static-linux
98-
- name: Create a Solc symbolic link
284+
- name: Create Solc symbolic link
99285
run: ln -sf /home/runner/.solc/v0.8.25/solc-static-linux /home/runner/.solc/solc
100-
- name: Check if Solc is in PATH
101-
run: which solc || echo "Solc not found in PATH"
102286

103-
- name: Setup Additional Languages (python3)
104-
uses: actions/setup-python@v4
105-
with:
106-
python-version: '3.9'
287+
- name: Test (dev) - solidity
288+
run: cargo test --locked --no-default-features --features solidity
107289

108-
- name: Setup Additional Languages (python3 packages)
109-
run: |
110-
python3 -m pip install pyre-check==0.0.59
111-
python3 -m pip install numpy==1.20.1
112-
echo '/github/home/.local/bin' >> $GITHUB_PATH
290+
- name: Test (release) - solidity
291+
run: cargo test --locked --release --no-default-features --features solidity
113292

114-
- name: Setup Additional Languages (.Net)
115-
uses: actions/setup-dotnet@v4
116-
with:
117-
dotnet-version: '6.0.x'
293+
test-swift:
294+
runs-on: ubuntu-latest
118295

119-
- name: Setup Additional Languages (golang)
120-
uses: actions/setup-go@v3
121-
with:
122-
go-version: '~1.22.0'
296+
steps:
297+
- uses: actions/checkout@v3
123298

124-
- name: Setup Additional Languages (deno)
125-
uses: denoland/setup-deno@v1
126-
with:
127-
deno-version: v1.x
299+
- uses: actions-rust-lang/setup-rust-toolchain@v1
128300

129-
- name: Setup Additional Languages (dart)
130-
uses: dart-lang/setup-dart@v1
131-
with:
132-
sdk: 3.5.3
301+
- name: Cache Dependencies
302+
uses: Swatinem/rust-cache@v2
133303

134-
- name: Setup Additional Languages (swift)
304+
- name: Setup Swift
135305
# TODO: Use the release version again once
136306
# https://github.com/swift-actions/setup-swift/pull/680
137307
# is merged
@@ -140,55 +310,30 @@ jobs:
140310
# older swift versions are having gpg issues https://github.com/swift-actions/setup-swift/issues/520
141311
swift-version: "5.10.1"
142312

143-
- name: Setup Additional Languages (ocaml)
144-
uses: ocaml/setup-ocaml@v3
145-
with:
146-
ocaml-compiler: 5.0
147-
opam-disable-sandboxing: true
313+
- name: Test (dev) - swift
314+
run: cargo test --locked --no-default-features --features swift
148315

149-
- name: Setup Additional Languages (ocaml packages)
150-
run: |
151-
eval $(opam env)
152-
opam install -y stdint uutf ppxlib
316+
- name: Test (release) - swift
317+
run: cargo test --locked --release --no-default-features --features swift
153318

154-
- name: Version Information
155-
run: |
156-
rustc --version
157-
cargo --version
158-
rustup --version
159-
python3 --version
160-
pyre --version
161-
clang++ --version
162-
javac -version
163-
go version
164-
dotnet --list-sdks
165-
deno --version
166-
dart --version
167-
swift --version
168-
kotlinc-native -version
169-
eval $(opam env)
170-
ocaml --version
319+
test-typescript:
320+
runs-on: ubuntu-latest
171321

172-
- name: Compile (dev tests)
173-
run: cargo test --no-run --locked
322+
steps:
323+
- uses: actions/checkout@v3
174324

175-
# It's faster to `test` before `build` according to
176-
# https://github.com/rust-lang/rust-analyzer/blob/97b357e41b99ee3d5dd72a1640f6c74e4f4d6b64/.github/workflows/ci.yaml#L55
177-
- name: Compile (dev serde-reflection)
178-
run: cargo build --locked --all-targets
325+
- uses: actions-rust-lang/setup-rust-toolchain@v1
179326

180-
- name: Test (dev)
181-
run: |
182-
eval $(opam env)
183-
cargo test
327+
- name: Cache Dependencies
328+
uses: Swatinem/rust-cache@v2
184329

185-
- name: Compile (release tests)
186-
run: cargo test --no-run --locked --release --all-features
330+
- name: Setup Deno
331+
uses: denoland/setup-deno@v1
332+
with:
333+
deno-version: v1.x
187334

188-
- name: Compile (release serde-reflection)
189-
run: cargo build --locked --release --all-targets --all-features
335+
- name: Test (dev) - typescript
336+
run: cargo test --locked --no-default-features --features typescript
190337

191-
- name: Test (release)
192-
run: |
193-
eval $(opam env)
194-
cargo test --locked --release --all-features
338+
- name: Test (release) - typescript
339+
run: cargo test --locked --release --no-default-features --features typescript

serde-generate-bin/Cargo.toml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ edition = "2021"
1313
rust-version = "1.70"
1414

1515
[dependencies]
16-
serde-generate = { path = "../serde-generate", version = "0.32.0" }
16+
serde-generate = { path = "../serde-generate", version = "0.32.0", default-features = false }
1717
structopt = "0.3.21"
1818
serde-reflection = { path = "../serde-reflection", version = "0.5.2" }
1919
serde_yaml = "0.8.17"
@@ -23,6 +23,21 @@ tempfile = "3.2"
2323
serde = { version = "1.0.126", features = ["derive"] }
2424
serde_bytes = "0.11.5"
2525

26+
[features]
27+
default = ["cpp", "csharp", "dart", "golang", "java", "kotlin", "ocaml", "python3", "rust", "swift", "typescript", "solidity"]
28+
cpp = ["serde-generate/cpp"]
29+
csharp = ["serde-generate/csharp"]
30+
dart = ["serde-generate/dart"]
31+
golang = ["serde-generate/golang"]
32+
java = ["serde-generate/java"]
33+
kotlin = ["serde-generate/kotlin"]
34+
ocaml = ["serde-generate/ocaml"]
35+
python3 = ["serde-generate/python3"]
36+
rust = ["serde-generate/rust"]
37+
solidity = ["serde-generate/solidity"]
38+
swift = ["serde-generate/swift"]
39+
typescript = ["serde-generate/typescript"]
40+
2641
[[bin]]
2742
name = "serdegen"
2843
path = "src/main.rs"

0 commit comments

Comments
 (0)