Skip to content

Commit 18d8218

Browse files
committed
ci: check rust
1 parent 1d1b1b9 commit 18d8218

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

.github/workflows/check.yaml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ on:
44
push:
55
paths:
66
- .github/workflows/check.yaml
7+
- crates/**
78
- frontend/**
9+
- Cargo.lock
810

911
jobs:
10-
check:
12+
check-frontend:
1113
runs-on: ubuntu-latest
1214
steps:
1315
- uses: actions/checkout@v4
@@ -23,3 +25,35 @@ jobs:
2325

2426
- name: check format
2527
run: cd frontend && yarn format:check
28+
29+
check-rust:
30+
runs-on: ubuntu-latest
31+
env:
32+
SERVER_HOST: http://localhost
33+
SERVER_PORT: "3000"
34+
DB_PATH: db.redb
35+
WEB_ORIGIN: http://localhost:8080
36+
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- uses: actions-rust-lang/setup-rust-toolchain@v1
41+
with:
42+
components: clippy,rustfmt
43+
- uses: Swatinem/rust-cache@v2
44+
45+
- uses: DeterminateSystems/nix-installer-action@main
46+
- uses: DeterminateSystems/magic-nix-cache-action@main
47+
48+
- name: install tools
49+
run: |
50+
nix profile add "nixpkgs#just" && just -V
51+
nix profile add "nixpkgs#cargo-nextest" && cargo nextest -V
52+
53+
- name: check
54+
run: |
55+
touch .env
56+
just check
57+
58+
- name: test
59+
run: just test

crates/companion-app/build.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
use std::path::PathBuf;
2+
13
fn main() {
2-
println!("cargo::rerun-if-changed=../../.env");
4+
let envs = ["SERVER_HOST", "SERVER_PORT", "DB_PATH", "WEB_ORIGIN"];
5+
if PathBuf::from("../../.env").exists() {
6+
println!("cargo::rerun-if-changed=../../.env");
7+
}
8+
for env in envs {
9+
println!("cargo::rerun-if-env-changed={env}");
10+
if let Ok(value) = std::env::var(env) {
11+
println!("cargo::rustc-env={env}={value}");
12+
}
13+
}
314
}

crates/server/build.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
use std::path::PathBuf;
22

33
fn main() {
4+
let envs = ["SERVER_HOST", "SERVER_PORT", "DB_PATH", "WEB_ORIGIN"];
45
if PathBuf::from("../../.env").exists() {
56
println!("cargo::rerun-if-changed=../../.env");
67
}
8+
for env in envs {
9+
println!("cargo::rerun-if-env-changed={env}");
10+
if let Ok(value) = std::env::var(env) {
11+
println!("cargo::rustc-env={env}={value}");
12+
}
13+
}
714
}

0 commit comments

Comments
 (0)