Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
41 changes: 41 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Rust lint & build

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always

jobs:
lint:

runs-on: ubuntu-latest

defaults:
run:
working-directory: ./controller

steps:
- uses: actions/checkout@v4
- name: Format
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy -- -D warnings
build:

runs-on: ubuntu-latest

defaults:
run:
working-directory: ./controller

steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose

13 changes: 7 additions & 6 deletions controller/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use clap::{Parser, ValueEnum};

#[derive(Debug, Parser, PartialEq)]
pub struct Config{
pub struct Config {
#[arg(long, env)]
pub github_repository_url: String,
#[arg(long, env)]
Expand All @@ -23,16 +23,16 @@ pub struct Config{
}

#[derive(Debug, Clone, ValueEnum, PartialEq)]
pub enum ServerType{
pub enum ServerType {
Paper,
Velocity,
}

#[cfg(test)]
mod test{
mod test {
use super::*;
#[test]
fn parse_arguments(){
fn parse_arguments() {
let configs = Config::try_parse_from(&[
"mdcs-controller",
"--github-repository-url",
Expand All @@ -53,11 +53,12 @@ mod test{
"./start.sh",
"--stop-command",
"./stop.sh",
]).unwrap();
])
.unwrap();

assert_eq!(
configs,
Config{
Config {
github_repository_url: "https://github.com/example_user/example_repo".to_string(),
github_username: "example_user".to_string(),
github_password: "example_password".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion controller/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ async fn main() {
let config = Config::parse();

// デバッグ用 Configを表示する
debug!("{:?}",config);
debug!("{:?}", config);
}