From 86fb44c12955faf976df935e0c35158a21325275 Mon Sep 17 00:00:00 2001 From: Kirill Date: Wed, 10 Dec 2025 22:29:56 +0300 Subject: [PATCH] feat(ci): Added CI --- .forgejo/workflows/demo.yaml | 26 ++++++++++++++++++++ src/main.rs | 47 ++---------------------------------- 2 files changed, 28 insertions(+), 45 deletions(-) create mode 100644 .forgejo/workflows/demo.yaml diff --git a/.forgejo/workflows/demo.yaml b/.forgejo/workflows/demo.yaml new file mode 100644 index 0000000..6989cb6 --- /dev/null +++ b/.forgejo/workflows/demo.yaml @@ -0,0 +1,26 @@ +name: Rust CI +on: [push, pull_request] + +jobs: + build-and-test: + runs-on: docker + + container: + image: rust:alpine + + steps: + - name: Install Git + run: apk add --no-cache git + + - name: Checkout code + env: + REPO_TOKEN: ${{ secrets.CHECKOUT_TOKEN }} + run: | + git clone https://oauth2:${{ env.REPO_TOKEN }}@git.rustprogersteam.ru/${{ github.repository }}.git . + git checkout ${{ github.sha }} + + - name: Build + run: cargo build --verbose + + - name: Test + run: cargo test --verbose diff --git a/src/main.rs b/src/main.rs index d6e144d..122e2f9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,48 +1,5 @@ -enum MATH { - ADD, - SUB, - MUL, - DEV, -} - -struct Math { - a: i32, - b: i32, -} - -impl Math { - fn init(a: i32, b: i32) -> Math { - return Math { a, b }; - } - - fn calculate(&self, operation: MATH) -> i32 { - match operation { - MATH::ADD => return self.a + self.b, - MATH::SUB => return self.a - self.b, - MATH::MUL => return self.a * self.b, - MATH::DEV => { - if self.b == 0 { - return 0; - } else { - return self.a / self.b; - } - } - } - } - - fn reinit(&mut self, a: i32, b: i32) { - self.a = a; - self.b = b; - } -} +use learning::Str; fn main() { - let operation: MATH = MATH::ADD; - let mut calculator: Math = Math::init(10, 4); - - print!("ans: {}\n", calculator.calculate(operation)); - - calculator.reinit(32, 2); - - println!("ans after reinit: {}", calculator.calculate(MATH::DEV)); + let str: Str = Str::new(); }