Skip to content

Commit 93dae5f

Browse files
authored
ci: speed up test workflow with parallel jobs and merged test binary (#523)
* ci: speed up test workflow by parallelizing jobs and merging test binaries Split the single sequential CI job into parallel lint + test jobs, and merge 41 separate e2e integration test binaries into a single binary. This eliminates ~40 redundant link steps and overlaps clippy with test execution. Expected improvement: ~6min → ~4min wall time. * rename test module to general to avoid conflict with built-in test crate
1 parent 77eeb99 commit 93dae5f

44 files changed

Lines changed: 147 additions & 139 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,34 @@ env:
1212
CARGO_INCREMENTAL: 0 # Faster CI builds
1313

1414
jobs:
15+
lint:
16+
name: Lint
17+
runs-on: ubuntu_large_x64
18+
19+
steps:
20+
- uses: actions/checkout@v6
21+
22+
- name: Install Rust
23+
uses: actions-rust-lang/setup-rust-toolchain@v1
24+
with:
25+
components: rustfmt, clippy
26+
27+
- name: Cache Rust dependencies
28+
uses: swatinem/rust-cache@v2
29+
with:
30+
cache-on-failure: true
31+
32+
- name: Run cargo fmt
33+
run: cargo fmt --all -- --check
34+
35+
- name: Run cargo clippy
36+
run: cargo clippy --all-targets --all-features -- -D warnings
37+
1538
test:
1639
name: Test Suite
1740
runs-on: ubuntu_large_x64
1841
environment: Cloud API test env
19-
42+
2043
services:
2144
postgres:
2245
image: postgres:15
@@ -50,11 +73,9 @@ jobs:
5073
echo "PostgreSQL did not become ready after restart within 30 seconds" >&2
5174
exit 1
5275
fi
53-
76+
5477
- name: Install Rust
5578
uses: actions-rust-lang/setup-rust-toolchain@v1
56-
with:
57-
components: rustfmt, clippy
5879

5980
- name: Cache Rust dependencies
6081
uses: swatinem/rust-cache@v2
@@ -64,12 +85,6 @@ jobs:
6485
- name: Install cargo-nextest
6586
uses: taiki-e/install-action@nextest
6687

67-
- name: Run cargo fmt
68-
run: cargo fmt --all -- --check
69-
70-
- name: Run cargo clippy
71-
run: cargo clippy --all-targets --all-features -- -D warnings
72-
7388
- name: Run unit tests
7489
run: cargo nextest run --lib --bins
7590
env:
@@ -88,10 +103,10 @@ jobs:
88103
BRAVE_SEARCH_PRO_API_KEY: ${{ secrets.BRAVE_SEARCH_PRO_API_KEY }}
89104
DEV: "true"
90105

91-
# All e2e tests share a single database (bootstrapped once with migrations).
106+
# All e2e tests are compiled into a single binary (tests/e2e_all/) for faster linking.
92107
# Isolation comes from UUID-scoped orgs/workspaces/keys, not separate databases.
93108
- name: Run integration tests
94-
run: cargo nextest run -p api --tests
109+
run: cargo nextest run --test e2e_all
95110
env:
96111
POSTGRES_PRIMARY_APP_ID: ${{ secrets.POSTGRES_PRIMARY_APP_ID }}
97112
DATABASE_HOST: localhost
@@ -115,7 +130,7 @@ jobs:
115130
env:
116131
VLLM_BASE_URL: ${{ secrets.VLLM_BASE_URL }}
117132
VLLM_API_KEY: ${{ secrets.VLLM_API_KEY }}
118-
133+
119134
# Only build release on main branch, not on PRs
120135
- name: Build release
121136
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

crates/api/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,7 @@ ed25519-dalek = { version = "2.1", features = ["rand_core"] }
6969
rand = "0.10"
7070
services = { path = "../services", features = ["test-mocks"] }
7171
async-trait = "0.1"
72+
73+
[[test]]
74+
name = "e2e_all"
75+
path = "tests/e2e_all/main.rs"

crates/api/tests/e2e_admin_analytics.rs renamed to crates/api/tests/e2e_all/admin_analytics.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// E2E tests for admin analytics endpoints
2-
mod common;
32

4-
use common::*;
3+
use crate::common::*;
54
use services::admin::{OrganizationMetrics, PlatformMetrics, TimeSeriesMetrics};
65

76
// ============================================

crates/api/tests/e2e_admin_list_models.rs renamed to crates/api/tests/e2e_all/admin_list_models.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// E2E tests for admin list models endpoint
2-
mod common;
32

3+
use crate::common::*;
44
use api::models::{AdminModelListResponse, BatchUpdateModelApiRequest};
5-
use common::*;
65

76
// ============================================
87
// List Models Tests

crates/api/tests/e2e_admin_services.rs renamed to crates/api/tests/e2e_all/admin_services.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
//! E2E tests for admin platform services CRUD (POST/PATCH /v1/admin/services)
22
//! and public services (GET /v1/services, GET /v1/services/{service_name}).
33
4-
mod common;
5-
4+
use crate::common::*;
65
use api::models::{CreateServiceRequest, ServiceResponse, UpdateServiceRequest};
7-
use common::*;
86
use services::service_usage::ports::ServiceUnit;
97

108
/// Create, get by name (public), update (display/cost), get again, disable (PATCH is_active false),
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
mod common;
2-
3-
use common::*;
1+
use crate::common::*;
42

53
// ============================================
64
// API Key Creation and Management Tests
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
//! - With mocks (default, for CI pipeline): `cargo test --test e2e_audio_image`
55
//! - With real providers (for dev testing): `USE_REAL_PROVIDERS=true cargo test --test e2e_audio_image`
66
7-
mod common;
8-
9-
use common::*;
7+
use crate::common::*;
108

119
/// Test audio input in chat completions (sending audio data to the model)
1210
#[tokio::test]

crates/api/tests/e2e_audio_transcriptions.rs renamed to crates/api/tests/e2e_all/audio_transcriptions.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
//! - Concurrent request limiting
1313
//! - Parameter validation
1414
15-
mod common;
16-
15+
use crate::common::*;
1716
use api::models::BatchUpdateModelApiRequest;
18-
use common::*;
1917

2018
/// Helper to create mock audio file bytes
2119
fn create_mock_audio_file(size_kb: usize) -> Vec<u8> {
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
mod common;
2-
3-
use common::*;
1+
use crate::common::*;
42

53
// ============================================
64
// Refresh Token and Access Token Tests

crates/api/tests/e2e_billing_and_models.rs renamed to crates/api/tests/e2e_all/billing_and_models.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Import common test utilities
2-
mod common;
32

4-
use common::*;
3+
use crate::common::*;
54

65
#[tokio::test]
76
async fn test_billing_costs_happy_path() {

0 commit comments

Comments
 (0)