From f5afc584cbd7bbbded69a5eba64352588d4c9494 Mon Sep 17 00:00:00 2001 From: CHIKAMATSU Naohiro Date: Sat, 20 Jul 2024 13:49:44 +0900 Subject: [PATCH 1/2] Add build workflow --- .github/workflows/build.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..da90854 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,20 @@ +name: Rust Build + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Build + run: cargo build --verbose From 45d9d76e979b1b14df764471e73bf79288a169eb Mon Sep 17 00:00:00 2001 From: CHIKAMATSU Naohiro Date: Sat, 20 Jul 2024 14:57:02 +0900 Subject: [PATCH 2/2] Add workflows --- .github/workflows/build.yml | 2 +- .github/workflows/test.yml | 20 +++++++++++ src/calculations.rs | 70 ++++++++++++++++++++++++++++++++++++- 3 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index da90854..286188e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Rust Build +name: Build on: push: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..c2599cf --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,20 @@ +name: Unit tests + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Build + run: cargo build --verbose diff --git a/src/calculations.rs b/src/calculations.rs index 6368de6..e4639bc 100644 --- a/src/calculations.rs +++ b/src/calculations.rs @@ -28,7 +28,9 @@ impl Investment { /// # Example /// /// ``` - /// let matches = clap::App::new("investment") + /// use cic::calculations::Investment; + /// + /// let matches = clap::Command::new("investment") /// .arg(clap::Arg::new("principal").default_value("0")) /// .arg(clap::Arg::new("contribution").default_value("1")) /// .arg(clap::Arg::new("rate").default_value("5")) @@ -66,6 +68,9 @@ impl Investment { /// # Example /// /// ``` + /// use cic::calculations::YearlySummary; + /// use cic::calculations::Investment; + /// /// let investment = Investment { /// principal: 1000.0, /// contribution: 100.0, @@ -133,6 +138,9 @@ pub struct YearlySummary { /// # Example /// /// ```no_run +/// use cic::calculations::plot_summary; +/// use cic::calculations::YearlySummary; +/// /// let summary = vec![ /// YearlySummary { year: 1, principal: 1000.0, annual_contribution: 1200.0, total_contribution: 1200.0, annual_interest: 50.0, total_interest: 50.0, total_amount: 2150.0 }, /// // Add more summaries here @@ -198,3 +206,63 @@ pub fn plot_summary(summary: &[YearlySummary]) -> Result<(), Box