Skip to content

Commit d7c6b89

Browse files
authored
Merge pull request #8 from Bibimbap-Team/1-setup-ci
Setup GitHub Actions CI
2 parents 4c13376 + b1f601c commit d7c6b89

File tree

2 files changed

+100
-2
lines changed

2 files changed

+100
-2
lines changed

.github/workflows/rust.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Rust
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
rustfmt:
13+
name: 🗊 Formatting
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Install toolchain
18+
uses: actions-rs/toolchain@v1
19+
with:
20+
profile: minimal
21+
toolchain: nightly
22+
override: true
23+
components: rustfmt
24+
- name: Run cargo fmt
25+
uses: actions-rs/cargo@v1
26+
with:
27+
command: fmt
28+
args: --all -- --check
29+
30+
lint:
31+
name: 🚨 Lint
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v2
35+
- name: Install packages
36+
run: sudo apt-get install xorg-dev libglu1-mesa-dev
37+
- name: Install toolchain
38+
uses: actions-rs/toolchain@v1
39+
with:
40+
toolchain: stable
41+
override: true
42+
components: clippy
43+
- uses: actions-rs/clippy-check@v1
44+
with:
45+
token: ${{ secrets.GITHUB_TOKEN }}
46+
args: --all-features --all-targets -- -D warnings
47+
48+
test:
49+
name: ✅ Test Suite
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v2
53+
- name: Install packages
54+
run: sudo apt-get install xorg-dev libglu1-mesa-dev
55+
- uses: actions-rs/toolchain@v1
56+
with:
57+
toolchain: stable
58+
override: true
59+
- uses: Swatinem/rust-cache@v1
60+
- name: Install cargo-nextest
61+
uses: baptiste0928/cargo-install@v1
62+
with:
63+
crate: cargo-nextest
64+
locked: true
65+
- uses: actions-rs/cargo@v1
66+
with:
67+
command: nextest
68+
args: run --retries 5 --workspace --failure-output final
69+
70+
security_audit:
71+
name: 👮 Audit
72+
runs-on: ubuntu-latest
73+
steps:
74+
- uses: actions/checkout@v2
75+
- name: Cache cargo bin
76+
uses: actions/cache@v1
77+
with:
78+
path: ~/.cargo/bin
79+
key: ${{ runner.os }}-cargo-audit
80+
- uses: actions-rs/audit-check@v1
81+
with:
82+
token: ${{ secrets.GITHUB_TOKEN }}

src/main.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,27 @@
22
extern crate rocket;
33

44
#[get("/")]
5-
fn index() -> &'static str {
5+
fn hello() -> &'static str {
66
"Hello, world!"
77
}
88

99
#[launch]
1010
fn rocket() -> _ {
11-
rocket::build().mount("/", routes![index])
11+
rocket::build().mount("/", routes![hello])
12+
}
13+
14+
#[cfg(test)]
15+
mod test {
16+
use super::rocket;
17+
use rocket::http::Status;
18+
use rocket::local::blocking::Client;
19+
20+
#[test]
21+
fn test_hello() {
22+
let client = Client::tracked(rocket()).expect("valid rocket instance");
23+
let response = client.get(uri!(super::hello)).dispatch();
24+
25+
assert_eq!(response.status(), Status::Ok);
26+
assert_eq!(response.into_string().unwrap(), "Hello, world!");
27+
}
1228
}

0 commit comments

Comments
 (0)