Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup GitHub Actions CI #8

Merged
merged 3 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Rust

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
rustfmt:
name: 🗊 Formatting
utilForever marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

lint:
name: 🚨 Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install packages
run: sudo apt-get install xorg-dev libglu1-mesa-dev
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --all-targets -- -D warnings

test:
name: ✅ Test Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install packages
run: sudo apt-get install xorg-dev libglu1-mesa-dev
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v1
- name: Install cargo-nextest
uses: baptiste0928/cargo-install@v1
with:
crate: cargo-nextest
locked: true
- uses: actions-rs/cargo@v1
with:
command: nextest
args: run --retries 5 --workspace --failure-output final

security_audit:
name: 👮 Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache cargo bin
uses: actions/cache@v1
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-audit
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
20 changes: 18 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,27 @@
extern crate rocket;

#[get("/")]
fn index() -> &'static str {
fn hello() -> &'static str {
"Hello, world!"
}

#[launch]
fn rocket() -> _ {
rocket::build().mount("/", routes![index])
rocket::build().mount("/", routes![hello])
}

#[cfg(test)]
mod test {
use super::rocket;
use rocket::local::blocking::Client;
use rocket::http::Status;

#[test]
fn test_hello() {
let client = Client::tracked(rocket()).expect("valid rocket instance");
let response = client.get(uri!(super::hello)).dispatch();

assert_eq!(response.status(), Status::Ok);
assert_eq!(response.into_string().unwrap(), "Hello, world!");
}
}
Loading