-
Notifications
You must be signed in to change notification settings - Fork 7
146 lines (127 loc) · 4.65 KB
/
Copy pathtest.yml
File metadata and controls
146 lines (127 loc) · 4.65 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: Tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0 # Faster CI builds
jobs:
lint:
name: Lint
runs-on: ubuntu_large_x64
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt, clippy
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Run cargo fmt
run: cargo fmt --all -- --check
- name: Run cargo clippy
run: cargo clippy --all-targets --all-features -- -D warnings
test:
name: Test Suite
runs-on: ubuntu_large_x64
environment: Cloud API test env
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: platform_api
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--shm-size=256mb
ports:
- 5432:5432
steps:
- uses: actions/checkout@v6
- name: Increase PostgreSQL max connections
run: |
# 16 parallel tests * 4 pool connections = 64, but allow headroom for spikes.
docker exec ${{ job.services.postgres.id }} \
psql -U postgres -c "ALTER SYSTEM SET max_connections = 150;"
docker restart ${{ job.services.postgres.id }}
for i in $(seq 1 30); do
docker exec ${{ job.services.postgres.id }} pg_isready -U postgres && break
sleep 1
done
if ! docker exec ${{ job.services.postgres.id }} pg_isready -U postgres; then
echo "PostgreSQL did not become ready after restart within 30 seconds" >&2
exit 1
fi
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- name: Run unit tests
run: cargo nextest run --lib --bins
env:
POSTGRES_PRIMARY_APP_ID: ${{ secrets.POSTGRES_PRIMARY_APP_ID }}
DATABASE_HOST: localhost
DATABASE_PORT: 5432
DATABASE_NAME: platform_api
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres
DATABASE_MAX_CONNECTIONS: 5
DATABASE_TLS_ENABLED: "false"
MODEL_DISCOVERY_SERVER_URL: ${{ secrets.MODEL_DISCOVERY_SERVER_URL }}
MODEL_DISCOVERY_API_KEY: ${{ secrets.MODEL_DISCOVERY_API_KEY }}
AUTH_ADMIN_DOMAINS: ${{ secrets.AUTH_ADMIN_DOMAINS }}
AUTH_ENCODING_KEY: ${{ secrets.AUTH_ENCODING_KEY }}
BRAVE_SEARCH_PRO_API_KEY: ${{ secrets.BRAVE_SEARCH_PRO_API_KEY }}
DEV: "true"
# All e2e tests are compiled into a single binary (tests/e2e_all/) for faster linking.
# Isolation comes from UUID-scoped orgs/workspaces/keys, not separate databases.
- name: Run integration tests
run: cargo nextest run --test e2e_all
env:
POSTGRES_PRIMARY_APP_ID: ${{ secrets.POSTGRES_PRIMARY_APP_ID }}
DATABASE_HOST: localhost
DATABASE_PORT: 5432
DATABASE_NAME: platform_api
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres
DATABASE_MAX_CONNECTIONS: 5
DATABASE_TLS_ENABLED: "false"
MODEL_DISCOVERY_SERVER_URL: ${{ secrets.MODEL_DISCOVERY_SERVER_URL }}
MODEL_DISCOVERY_API_KEY: ${{ secrets.MODEL_DISCOVERY_API_KEY }}
AUTH_ENCODING_KEY: ${{ secrets.AUTH_ENCODING_KEY }}
AUTH_ADMIN_DOMAINS: ${{ secrets.AUTH_ADMIN_DOMAINS }}
BRAVE_SEARCH_PRO_API_KEY: ${{ secrets.BRAVE_SEARCH_PRO_API_KEY }}
TEST_DATABASE_NAME: platform_api_e2e
RUST_LOG: debug
DEV: "true"
- name: Run vLLM integration tests
run: cargo test --test integration_tests -- --nocapture
env:
VLLM_BASE_URL: ${{ secrets.VLLM_BASE_URL }}
VLLM_API_KEY: ${{ secrets.VLLM_API_KEY }}
# Only build release on main branch, not on PRs
- name: Build release
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: cargo build --release
env:
POSTGRES_PRIMARY_APP_ID: ${{ secrets.POSTGRES_PRIMARY_APP_ID }}
DATABASE_HOST: localhost
DATABASE_PORT: 5432
DATABASE_NAME: platform_api
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres
MODEL_DISCOVERY_SERVER_URL: ${{ secrets.MODEL_DISCOVERY_SERVER_URL }}
AUTH_ENCODING_KEY: ${{ secrets.AUTH_ENCODING_KEY }}