-
Notifications
You must be signed in to change notification settings - Fork 4
217 lines (190 loc) · 7.43 KB
/
test.yml
File metadata and controls
217 lines (190 loc) · 7.43 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
name: Test
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
test:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Free Disk Space (Ubuntu)
if: matrix.os == 'ubuntu-latest'
uses: jlumbroso/free-disk-space@main
with:
# Remove large packages we don't need
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: false
- name: Install OpenSSL for Windows
if: matrix.os == 'windows-latest'
run: |
vcpkg install openssl:x64-windows-static-md
echo "OPENSSL_DIR=C:/vcpkg/installed/x64-windows-static-md" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "OPENSSL_ROOT_DIR=C:/vcpkg/installed/x64-windows-static-md" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "OPENSSL_INCLUDE_DIR=C:/vcpkg/installed/x64-windows-static-md/include" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "OPENSSL_LIB_DIR=C:/vcpkg/installed/x64-windows-static-md/lib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "VCPKG_ROOT=C:/vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- name: Ensure cargo in PATH (Windows)
if: matrix.os == 'windows-latest'
run: echo "$HOME/.cargo/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Cache cargo registry
uses: actions/cache@v5
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache cargo index
uses: actions/cache@v5
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-index-
- name: Cache cargo build
uses: actions/cache@v5
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-target-
- name: Install SQLx CLI
run: cargo install sqlx-cli --no-default-features --features sqlite
- name: Setup database
run: |
sqlx database setup --source torc-server/migrations
env:
DATABASE_URL: sqlite:db/sqlite/dev.db
- name: Build test binaries (only necessary packages)
run: cargo build --all-features -p torc
env:
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
- name: Run tests (Windows - limited test set)
if: matrix.os == 'windows-latest'
run: cargo nextest run --all-features -E 'test(test_many_jobs_parameterized)'
env:
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0
OPENSSL_DIR: C:/vcpkg/installed/x64-windows-static-md
OPENSSL_ROOT_DIR: C:/vcpkg/installed/x64-windows-static-md
OPENSSL_INCLUDE_DIR: C:/vcpkg/installed/x64-windows-static-md/include
OPENSSL_LIB_DIR: C:/vcpkg/installed/x64-windows-static-md/lib
VCPKG_ROOT: C:/vcpkg
- name: Run tests (Unix - full test suite)
if: matrix.os != 'windows-latest'
run: cargo nextest run --all-features
env:
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0
# Clean up intermediate build artifacts to free disk space for Julia
# Keep only the binaries needed to run the server
- name: Clean up build artifacts
if: matrix.os == 'ubuntu-latest'
run: |
echo "Disk space before cleanup:"
df -h .
# Remove intermediate build artifacts but keep binaries
rm -rf target/debug/deps
rm -rf target/debug/incremental
rm -rf target/debug/build
rm -rf target/debug/.fingerprint
rm -rf target/debug/examples
# Clean up the entire cargo registry cache (will be restored next time)
rm -rf ~/.cargo/registry/cache
rm -rf ~/.cargo/registry/index
rm -rf ~/.cargo/git/db
echo "Disk space after cleanup:"
df -h .
# Python and Julia client tests (Unix only for now)
- name: Setup Python
if: matrix.os == 'ubuntu-latest'
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install Python client dependencies
if: matrix.os == 'ubuntu-latest'
run: |
cd python_client
pip install -e .[dev]
# Disable because no one is using Julia
#- name: Setup Julia
# if: matrix.os == 'ubuntu-latest'
# uses: julia-actions/setup-julia@v2
# with:
# version: '1.12'
#- name: Install Julia dependencies
# if: matrix.os == 'ubuntu-latest'
# run: |
# julia --project=julia_client/Torc -e 'using Pkg; Pkg.instantiate(); using Torc'
# julia --project=julia_client/Torc/test -e 'using Pkg; Pkg.develop(path="julia_client/Torc"); Pkg.instantiate()'
- name: Start torc server
if: matrix.os == 'ubuntu-latest'
run: |
export DATABASE_URL=sqlite:db/sqlite/dev.db
./target/debug/torc-server run > server.log 2>&1 &
SERVER_PID=$!
echo "Server started with PID $SERVER_PID"
# Wait for server to be ready
for i in {1..30}; do
if curl -s http://localhost:8080/torc-service/v1/ping > /dev/null 2>&1; then
echo "Server is ready"
break
fi
echo "Waiting for server... ($i/30)"
sleep 1
done
# Show server log if it failed to start
if ! curl -s http://localhost:8080/torc-service/v1/ping > /dev/null 2>&1; then
echo "Server failed to start. Log:"
cat server.log
exit 1
fi
- name: Run Python client tests
if: matrix.os == 'ubuntu-latest'
run: |
cd python_client
pytest tests/ -v
env:
TORC_API_URL: http://localhost:8080/torc-service/v1
#- name: Run Julia client tests
# if: matrix.os == 'ubuntu-latest'
# run: |
# julia --project=julia_client/Torc -e "import Pkg; Pkg.test()"
# env:
# TORC_API_URL: http://localhost:8080/torc-service/v1
# PATH: ${{ github.workspace }}/target/debug:$PATH
# - name: Install cargo-llvm-cov
# if: matrix.os == 'ubuntu-latest'
# run: cargo install cargo-llvm-cov
# - name: Generate coverage
# if: matrix.os == 'ubuntu-latest'
# run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info -- --test-threads 1
# env:
# RUST_BACKTRACE: 1
# DATABASE_URL: sqlite:db/sqlite/dev.db
# - name: Upload coverage to Codecov
# if: matrix.os == 'ubuntu-latest'
# uses: codecov/codecov-action@v4
# with:
# files: lcov.info
# fail_ci_if_error: false