feat(ci): Added CI

This commit is contained in:
Black_Raven committed 2025-12-10 23:38:53 +03:00
1 parent 5362c5fabf
commit 86fb44c129
2 files changed
+28 -45

No files matched your search

+26
View File
@@ -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
+2 -45
View File
@@ -1,48 +1,5 @@
enum MATH { use learning::Str;
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;
}
}
fn main() { fn main() {
let operation: MATH = MATH::ADD; let str: Str = Str::new();
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));
} }