Skip to content

Commit 47145a2

Browse files
committed
Build and run the backend unit tests in CI
1 parent b0c0ba9 commit 47145a2

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,17 +189,27 @@ jobs:
189189
args: "--manifest-path ui/Cargo.toml --all -- --check"
190190
- name: Build backend
191191
run: |-
192-
mkdir -p ui/target; docker run --rm -v $PWD/ui:/ui -v ~/.cargo/git:/home/rust/.cargo/git -v ~/.cargo/registry:/home/rust/.cargo/registry --workdir /ui ekidd/rust-musl-builder:stable bash -c '
192+
mkdir -p ui/target; docker run --rm -v $PWD/ui:/ui -v ~/.cargo/git:/home/rust/.cargo/git -v ~/.cargo/registry:/home/rust/.cargo/registry --workdir /ui ekidd/rust-musl-builder:stable bash -c $'
193193
sudo chown -R rust:rust /home/rust/.cargo /ui/target;
194-
cargo build --locked --target=x86_64-unknown-linux-musl --release
194+
195+
# Unit tests
196+
cargo test --locked --target=x86_64-unknown-linux-musl --no-run;
197+
test_bin=$(find target/x86_64-unknown-linux-musl/debug/deps/ -type f -perm -a=x);
198+
mv "${test_bin}" target/unit_tests;
199+
200+
# Primary binary
201+
cargo build --locked --target=x86_64-unknown-linux-musl --release;
202+
mv target/x86_64-unknown-linux-musl/release/ui target/ui;
195203
'
196204
- name: Restore permissions
197205
run: sudo chown -R runner:docker ~/.cargo/ ui/target
198206
- name: Save backend artifact
199207
uses: actions/upload-artifact@v2
200208
with:
201209
name: backend
202-
path: ui/target/x86_64-unknown-linux-musl/release/ui
210+
path: |
211+
ui/target/ui
212+
ui/target/unit_tests
203213
build_frontend:
204214
name: Build frontend
205215
runs-on: ubuntu-latest
@@ -293,6 +303,8 @@ jobs:
293303
with:
294304
name: frontend
295305
path: tests/server/build/
306+
- name: Run unit tests
307+
run: chmod +x ./server/unit_tests && ./server/unit_tests
296308
- name: Run tests
297309
env:
298310
PLAYGROUND_UI_ROOT: server/build/

ci/workflows.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,17 @@ workflows:
296296
-v ~/.cargo/registry:/home/rust/.cargo/registry
297297
--workdir /ui
298298
ekidd/rust-musl-builder:stable
299-
bash -c '
299+
bash -c $'
300300
sudo chown -R rust:rust /home/rust/.cargo /ui/target;
301-
cargo build --locked --target=x86_64-unknown-linux-musl --release
301+
302+
# Unit tests
303+
cargo test --locked --target=x86_64-unknown-linux-musl --no-run;
304+
test_bin=$(find target/x86_64-unknown-linux-musl/debug/deps/ -type f -perm -a=x);
305+
mv "${test_bin}" target/unit_tests;
306+
307+
# Primary binary
308+
cargo build --locked --target=x86_64-unknown-linux-musl --release;
309+
mv target/x86_64-unknown-linux-musl/release/ui target/ui;
302310
'
303311
304312
- name: "Restore permissions"
@@ -309,7 +317,9 @@ workflows:
309317
uses: actions/upload-artifact@v2
310318
with:
311319
name: backend
312-
path: ui/target/x86_64-unknown-linux-musl/release/ui
320+
path: |
321+
ui/target/ui
322+
ui/target/unit_tests
313323
314324
build_frontend:
315325
name: "Build frontend"
@@ -413,6 +423,10 @@ workflows:
413423
name: frontend
414424
path: tests/server/build/
415425

426+
- name: "Run unit tests"
427+
run: |-
428+
chmod +x ./server/unit_tests && ./server/unit_tests
429+
416430
- name: "Run tests"
417431
env:
418432
PLAYGROUND_UI_ROOT: server/build/

ui/src/sandbox.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ mod test {
16341634
let sb = Sandbox::new().await.expect("Unable to create sandbox");
16351635
let resp = sb.execute(&req).await.expect("Unable to execute code");
16361636

1637-
assert!(resp.stderr.contains("Killed"));
1637+
assert!(resp.stderr.contains("Killed"), "was: {}", resp.stderr);
16381638
}
16391639

16401640
#[tokio::test]
@@ -1655,7 +1655,7 @@ mod test {
16551655
let sb = Sandbox::new().await.expect("Unable to create sandbox");
16561656
let resp = sb.execute(&req).await.expect("Unable to execute code");
16571657

1658-
assert!(resp.stderr.contains("Killed"));
1658+
assert!(resp.stderr.contains("Killed"), "was: {}", resp.stderr);
16591659
}
16601660

16611661
#[tokio::test]

0 commit comments

Comments
 (0)