-
Notifications
You must be signed in to change notification settings - Fork 1
219 lines (185 loc) · 6.38 KB
/
Copy pathci.yml
File metadata and controls
219 lines (185 loc) · 6.38 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
name: UET Research Corpus CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
# ==================== Rust Backend ====================
rust-check:
name: Rust Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Detect Rust workspace
id: rust-workspace
run: |
if [ -f Cargo.toml ]; then
echo "present=true" >> "$GITHUB_OUTPUT"
else
echo "present=false" >> "$GITHUB_OUTPUT"
echo "No root Cargo.toml found; skipping Rust checks for this corpus-only checkout."
fi
- name: Install Rust
if: steps.rust-workspace.outputs.present == 'true'
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Cache cargo
if: steps.rust-workspace.outputs.present == 'true'
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Check formatting
if: steps.rust-workspace.outputs.present == 'true'
run: cargo fmt --all -- --check
- name: Clippy
if: steps.rust-workspace.outputs.present == 'true'
run: cargo clippy --workspace --all-targets -- -D warnings
continue-on-error: true
- name: Build
if: steps.rust-workspace.outputs.present == 'true'
run: cargo build --release --workspace
# ==================== Next.js Frontend ====================
web-check:
name: Next.js Check
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./uet_web
steps:
- uses: actions/checkout@v4
- name: Detect Next.js app
id: next-app
working-directory: .
run: |
if [ -f uet_web/package-lock.json ]; then
echo "present=true" >> "$GITHUB_OUTPUT"
else
echo "present=false" >> "$GITHUB_OUTPUT"
echo "No uet_web/package-lock.json found; skipping Next.js checks for this corpus-only checkout."
fi
- name: Setup Node.js
if: steps.next-app.outputs.present == 'true'
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: './uet_web/package-lock.json'
- name: Install dependencies
if: steps.next-app.outputs.present == 'true'
run: npm ci --legacy-peer-deps
- name: Lint
if: steps.next-app.outputs.present == 'true'
run: npm run lint
continue-on-error: true
- name: Build
if: steps.next-app.outputs.present == 'true'
run: npm run build
env:
NEXT_TELEMETRY_DISABLED: 1
DATABASE_URL: "postgresql://fake:fake@localhost:5432/fake"
# ==================== Optional Python Service Checks ====================
python-test:
name: Python Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
- name: Run optional Python agent tests
run: |
if find services_and_experiments/uet_agents -type f \( -name 'test_*.py' -o -name '*_test.py' \) | grep -q .; then
pytest services_and_experiments/uet_agents/ -v --tb=short
else
echo "No service tests found; skipping optional agent checks."
fi
# ==================== Docker Build ====================
docker-build:
name: Docker Build
runs-on: ubuntu-latest
needs: [rust-check, web-check]
if: vars.UET_PLATFORM_DEPLOY == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Detect Dockerfiles
id: dockerfiles
run: |
if [ -f Dockerfile.api ] || [ -f Dockerfile.web ] || [ -f Dockerfile.agents ]; then
echo "present=true" >> "$GITHUB_OUTPUT"
else
echo "present=false" >> "$GITHUB_OUTPUT"
echo "No platform Dockerfiles found; skipping Docker image builds for this corpus-only checkout."
fi
- name: Set up Docker Buildx
if: steps.dockerfiles.outputs.present == 'true'
uses: docker/setup-buildx-action@v3
- name: Build API image
if: steps.dockerfiles.outputs.present == 'true' && hashFiles('Dockerfile.api') != ''
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.api
push: false
tags: uet_api:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build Web image
if: steps.dockerfiles.outputs.present == 'true' && hashFiles('Dockerfile.web') != ''
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.web
push: false
tags: uet_web:${{ github.sha }}
build-args: |
DATABASE_URL=postgresql://fake:fake@localhost:5432/fake
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build Agent image
if: steps.dockerfiles.outputs.present == 'true' && hashFiles('Dockerfile.agents') != ''
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.agents
push: false
tags: uet_agents:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
# ==================== Optional future-platform deployment ====================
deploy:
name: Deploy to Railway
runs-on: ubuntu-latest
needs: [docker-build]
if: vars.UET_PLATFORM_DEPLOY == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Install Railway CLI
run: npm install -g @railway/cli
- name: Deploy API
run: railway up --service uet-api
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_API_TOKEN }}
continue-on-error: true
- name: Deploy Web
run: railway up --service uet-web
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_WEB_TOKEN }}
continue-on-error: true