Skip to content

Commit 3ec5c34

Browse files
Enable CI workflow
Enable CI workflow that performs code formatting checks using `cargo fmt`, clippy linting, run tests and try building the project. Fix reported clippy lints.
1 parent 4361c59 commit 3ec5c34

File tree

5 files changed

+47
-7
lines changed

5 files changed

+47
-7
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Test and build
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v5
13+
- uses: actions-rust-lang/setup-rust-toolchain@v1
14+
with:
15+
toolchain: stable
16+
- name: Run the test suite
17+
run: cargo test --all-features
18+
19+
lint:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v5
23+
- uses: actions-rust-lang/setup-rust-toolchain@v1
24+
with:
25+
toolchain: stable
26+
components: clippy, rustfmt
27+
- name: Run clippy linter
28+
run: cargo clippy --all-targets
29+
- name: Run formatter
30+
run: cargo fmt --check
31+
32+
build:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v5
36+
- uses: actions-rust-lang/setup-rust-toolchain@v1
37+
with:
38+
toolchain: stable
39+
- name: Run the build
40+
run: cargo build

src/web/route/enroll.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ pub async fn get(
5050
flash_messages.error("Provided enroll token is invalid.");
5151
Ok(core_web::redirect("/login"))
5252
}
53-
TokenState::Error => Err(core_web::internal_server_error()),
53+
TokenState::Error => Err(core_web::internal_server_error().into()),
5454
},
5555
Err(err) => {
5656
tracing::error!("Failed to fetch session state: {err}");
5757

58-
Err(core_web::internal_server_error())
58+
Err(core_web::internal_server_error().into())
5959
}
6060
}
6161
}

src/web/route/login.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub async fn get(
2727
Err(err) => {
2828
tracing::error!("Failed to render the login page: {err}");
2929

30-
Err(core_web::internal_server_error())
30+
Err(core_web::internal_server_error().into())
3131
}
3232
}
3333
}

src/web/route/worlds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub async fn get(
6868
Err(err) => {
6969
tracing::error!("Failed to load worlds: {err}");
7070

71-
Err(web::internal_server_error())
71+
Err(web::internal_server_error().into())
7272
}
7373
}
7474
}

src/web/template/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ pub fn render_template<N: AsRef<str>, C: serde::Serialize>(
5656
templates: &handlebars::Handlebars,
5757
name: N,
5858
data: &Content<C>,
59-
) -> Result<String, error::InternalError<&'static str>> {
59+
) -> Result<String, error::Error> {
6060
match templates.render(name.as_ref(), data) {
6161
Ok(content) => Ok(content),
6262
Err(err) => {
6363
tracing::error!("Failed to render Handlebar template: {err}");
6464

65-
Err(web::internal_server_error())
65+
Err(web::internal_server_error().into())
6666
}
6767
}
6868
}
@@ -71,7 +71,7 @@ pub fn render_response<N: AsRef<str>, C: serde::Serialize>(
7171
templates: &handlebars::Handlebars,
7272
name: N,
7373
data: &Content<C>,
74-
) -> Result<actix_web::HttpResponse, error::InternalError<&'static str>> {
74+
) -> Result<actix_web::HttpResponse, error::Error> {
7575
render_template(templates, name, data).map(|content| {
7676
actix_web::HttpResponse::Ok()
7777
.content_type(header::ContentType::html())

0 commit comments

Comments
 (0)