From 0da33dea166006498444683b264820482d748de0 Mon Sep 17 00:00:00 2001 From: LegitYew0108 Date: Tue, 7 Oct 2025 01:37:31 +0900 Subject: [PATCH 1/4] ci(controller): add lint and build workflow --- .github/workflows/main.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..1b65ab7 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,37 @@ +name: Rust lint & build + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + lint: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: cd + run: cd controller + - name: Format + run: cargo fmt --all -- --check + - name: Clippy + run: cargo clippy + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: cd + run: cd controller + - name: Build + run: cargo build --verbose + - name: Run tests + run: cargo test --verbose + From abe63c20e1c0ee36cf7bd68194d58f2a374d1fc7 Mon Sep 17 00:00:00 2001 From: LegitYew0108 Date: Tue, 7 Oct 2025 01:47:28 +0900 Subject: [PATCH 2/4] fix(controller): set working dir to ci --- .github/workflows/main.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1b65ab7..d88406a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,10 +14,12 @@ jobs: runs-on: ubuntu-latest + defaults: + run: + working-directory: ./controller + steps: - uses: actions/checkout@v4 - - name: cd - run: cd controller - name: Format run: cargo fmt --all -- --check - name: Clippy @@ -26,10 +28,12 @@ jobs: runs-on: ubuntu-latest + defaults: + run: + working-directory: ./controller + steps: - uses: actions/checkout@v4 - - name: cd - run: cd controller - name: Build run: cargo build --verbose - name: Run tests From 1b9336d0f6b06188cdb215abb9841ebf113c19f5 Mon Sep 17 00:00:00 2001 From: LegitYew0108 Date: Tue, 7 Oct 2025 01:50:08 +0900 Subject: [PATCH 3/4] fix: apply cargo fmt --- controller/src/config.rs | 13 +++++++------ controller/src/main.rs | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/controller/src/config.rs b/controller/src/config.rs index f79a4ad..2175cdc 100644 --- a/controller/src/config.rs +++ b/controller/src/config.rs @@ -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)] @@ -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", @@ -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(), diff --git a/controller/src/main.rs b/controller/src/main.rs index 50250bb..d84270c 100644 --- a/controller/src/main.rs +++ b/controller/src/main.rs @@ -14,5 +14,5 @@ async fn main() { let config = Config::parse(); // デバッグ用 Configを表示する - debug!("{:?}",config); + debug!("{:?}", config); } From 6af764ea482ca1fc833e2f1dbec47b2cfb473854 Mon Sep 17 00:00:00 2001 From: LegitYew0108 <83275150+LegitYew0108@users.noreply.github.com> Date: Tue, 7 Oct 2025 01:51:46 +0900 Subject: [PATCH 4/4] Update .github/workflows/main.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d88406a..e549eb6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,7 +23,7 @@ jobs: - name: Format run: cargo fmt --all -- --check - name: Clippy - run: cargo clippy + run: cargo clippy -- -D warnings build: runs-on: ubuntu-latest