From 726dff1d69e5eff7c6e0378cedd2041f23452ac1 Mon Sep 17 00:00:00 2001 From: lexara-prime-ai Date: Sun, 14 Jul 2024 20:34:46 +0000 Subject: [PATCH 01/10] Updated coverage --- .github/workflows/code-coverage.yml | 72 ++++++++++++++++++----------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 05fc31e..1582b5a 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -14,30 +14,48 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - name: Install toolchain - id: toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - target: x86_64-unknown-linux-musl - override: true - components: llvm-tools-preview - - - name: Download grcov - run: | - mkdir -p "${HOME}/.local/bin" - curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.10/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin" - echo "$HOME/.local/bin" >> $GITHUB_PATH - working-directory: ./rust - - - - name: Run xtask coverage - uses: actions-rs/cargo@v1 - with: - command: xtask - args: coverage - - - name: Upload to codecov.io - uses: codecov/codecov-action@v3 - with: - files: coverage/*.lcov \ No newline at end of file + - name: Set up Rust toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + components: llvm-tools-preview + + - name: Install grcov + run: cargo install grcov + working-directory: ./rust + + - name: Install x86_64-unknown-linux-gnu target + run: rustup target add x86_64-unknown-linux-gnu + working-directory: ./rust + + - name: Set up coverage configuration + run: | + mkdir -p .cargo + echo "[build]" > .cargo/config.toml + echo 'rustflags = ["-Zinstrument-coverage","-Ccodegen-units=1","-Cinline-threshold=0","-Clink-dead-code","-Coverflow-checks=off","-Zno-profiler-runtime"]' >> .cargo/config.toml + echo "[unstable]" >> .cargo/config.toml + echo 'build-std = ["std"]' >> .cargo/config.toml + working-directory: ./rust + + - name: Run tests with coverage + env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: "-Zinstrument-coverage" + LLVM_PROFILE_FILE: "coverage-%p-%m.profraw" + run: cargo test --target x86_64-unknown-linux-gnu + working-directory: ./rust + + - name: Generate coverage report + run: | + grcov . -s . -t html --llvm --branch --ignore-not-existing -o ./coverage + mkdir -p coverage-report + cp -r ./coverage/* coverage-report/ + working-directory: ./rust + + - name: Upload coverage report + uses: actions/upload-artifact@v2 + with: + name: coverage-report + path: coverage-report \ No newline at end of file From b804c784aed6131d1a58386384beb7983325eeee Mon Sep 17 00:00:00 2001 From: lexara-prime-ai Date: Sun, 14 Jul 2024 20:52:23 +0000 Subject: [PATCH 02/10] Updated coverage --- .github/workflows/code-coverage.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 1582b5a..ca84e67 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -22,6 +22,10 @@ jobs: override: true components: llvm-tools-preview + - name: Update nightly toolchain + run: rustup update nightly + working-directory: ./rust + - name: Install grcov run: cargo install grcov working-directory: ./rust @@ -58,4 +62,4 @@ jobs: uses: actions/upload-artifact@v2 with: name: coverage-report - path: coverage-report \ No newline at end of file + path: coverage-report From 610ab86eb48124bf2d468237d62f2cd49238daa2 Mon Sep 17 00:00:00 2001 From: lexara-prime-ai Date: Sun, 14 Jul 2024 20:55:29 +0000 Subject: [PATCH 03/10] Updated coverage --- .github/workflows/code-coverage.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index ca84e67..3737d2f 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -18,21 +18,15 @@ jobs: uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly + toolchain: nightly-2021-03-24 # Replace with a specific nightly date that works override: true components: llvm-tools-preview - - name: Update nightly toolchain - run: rustup update nightly - working-directory: ./rust - - name: Install grcov run: cargo install grcov - working-directory: ./rust - name: Install x86_64-unknown-linux-gnu target run: rustup target add x86_64-unknown-linux-gnu - working-directory: ./rust - name: Set up coverage configuration run: | @@ -41,7 +35,6 @@ jobs: echo 'rustflags = ["-Zinstrument-coverage","-Ccodegen-units=1","-Cinline-threshold=0","-Clink-dead-code","-Coverflow-checks=off","-Zno-profiler-runtime"]' >> .cargo/config.toml echo "[unstable]" >> .cargo/config.toml echo 'build-std = ["std"]' >> .cargo/config.toml - working-directory: ./rust - name: Run tests with coverage env: @@ -49,14 +42,12 @@ jobs: RUSTFLAGS: "-Zinstrument-coverage" LLVM_PROFILE_FILE: "coverage-%p-%m.profraw" run: cargo test --target x86_64-unknown-linux-gnu - working-directory: ./rust - name: Generate coverage report run: | grcov . -s . -t html --llvm --branch --ignore-not-existing -o ./coverage mkdir -p coverage-report cp -r ./coverage/* coverage-report/ - working-directory: ./rust - name: Upload coverage report uses: actions/upload-artifact@v2 From c8aecda979e720b9febde1cc34a910d1d2980489 Mon Sep 17 00:00:00 2001 From: lexara-prime-ai Date: Sun, 14 Jul 2024 21:02:26 +0000 Subject: [PATCH 04/10] Updated coverage --- .github/workflows/code-coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 3737d2f..119f753 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install grcov - run: cargo install grcov + run: cargo install grcov --version 0.8.17 # Specify a working version - name: Install x86_64-unknown-linux-gnu target run: rustup target add x86_64-unknown-linux-gnu From cd1f007d0eb21b5bc6ac3e4b6d2e936daa9610a2 Mon Sep 17 00:00:00 2001 From: lexara-prime-ai Date: Sun, 14 Jul 2024 21:08:47 +0000 Subject: [PATCH 05/10] Updated coverage --- .github/workflows/code-coverage.yml | 56 ----------------------------- 1 file changed, 56 deletions(-) delete mode 100644 .github/workflows/code-coverage.yml diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml deleted file mode 100644 index 119f753..0000000 --- a/.github/workflows/code-coverage.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: Code Coverage - -on: - push: - branches: [master] - pull_request: - branches: [master] - -jobs: - code-coverage: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Rust toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly-2021-03-24 # Replace with a specific nightly date that works - override: true - components: llvm-tools-preview - - - name: Install grcov - run: cargo install grcov --version 0.8.17 # Specify a working version - - - name: Install x86_64-unknown-linux-gnu target - run: rustup target add x86_64-unknown-linux-gnu - - - name: Set up coverage configuration - run: | - mkdir -p .cargo - echo "[build]" > .cargo/config.toml - echo 'rustflags = ["-Zinstrument-coverage","-Ccodegen-units=1","-Cinline-threshold=0","-Clink-dead-code","-Coverflow-checks=off","-Zno-profiler-runtime"]' >> .cargo/config.toml - echo "[unstable]" >> .cargo/config.toml - echo 'build-std = ["std"]' >> .cargo/config.toml - - - name: Run tests with coverage - env: - CARGO_INCREMENTAL: 0 - RUSTFLAGS: "-Zinstrument-coverage" - LLVM_PROFILE_FILE: "coverage-%p-%m.profraw" - run: cargo test --target x86_64-unknown-linux-gnu - - - name: Generate coverage report - run: | - grcov . -s . -t html --llvm --branch --ignore-not-existing -o ./coverage - mkdir -p coverage-report - cp -r ./coverage/* coverage-report/ - - - name: Upload coverage report - uses: actions/upload-artifact@v2 - with: - name: coverage-report - path: coverage-report From be740777b6a3cef7a460d1d331a72ad43f6554fb Mon Sep 17 00:00:00 2001 From: lexara-prime-ai Date: Sun, 14 Jul 2024 21:58:50 +0000 Subject: [PATCH 06/10] Added code-coverage ci --- .github/workflows/code-coverage.yml | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/code-coverage.yml diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml new file mode 100644 index 0000000..fa1de71 --- /dev/null +++ b/.github/workflows/code-coverage.yml @@ -0,0 +1,43 @@ +name: Code Coverage + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + code-coverage: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Install Tarpaulin + run: cargo install cargo-tarpaulin + working-directory: ./rust + + - name: Run tests with coverage + run: cargo tarpaulin --out Xml + working-directory: ./rust + + - name: Upload coverage report + uses: actions/upload-artifact@v3 + with: + name: coverage-report + path: ./tarpaulin-report.xml + + - name: Publish coverage to Codecov + uses: codecov/codecov-action@v3 + with: + files: ./tarpaulin-report.xml + flags: unittests + name: codecov-umbrella + fail_ci_if_error: true \ No newline at end of file From 80302f08a7a7cbe554ab7244955f06c4a6d22546 Mon Sep 17 00:00:00 2001 From: lexara-prime-ai Date: Sun, 14 Jul 2024 21:59:08 +0000 Subject: [PATCH 07/10] Added code-coverage ci --- .github/workflows/code-coverage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index fa1de71..f4aa017 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -2,9 +2,9 @@ name: Code Coverage on: push: - branches: [ main ] + branches: [ master ] pull_request: - branches: [ main ] + branches: [ master ] jobs: code-coverage: From 324d59d6f90c3d3768e0ec3c269633a5000f475e Mon Sep 17 00:00:00 2001 From: lexara-prime-ai Date: Sun, 14 Jul 2024 22:09:06 +0000 Subject: [PATCH 08/10] Moved to state module. --- rust/src/main.rs | 8 -------- rust/src/state_management/state.rs | 13 +++++++++++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/rust/src/main.rs b/rust/src/main.rs index 1a96392..7468d2b 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -118,12 +118,4 @@ mod regression_tests { let services = result.unwrap(); assert!(!services.is_empty()); } - - #[tokio::test] - async fn test_list_authorized_users() { - let result = Owner::list_authorized_users("irfanghat@gmail.com", "100").await; - - // The result should be Ok(). - assert!(result.is_ok()); - } } diff --git a/rust/src/state_management/state.rs b/rust/src/state_management/state.rs index 272d9b8..c8db086 100644 --- a/rust/src/state_management/state.rs +++ b/rust/src/state_management/state.rs @@ -89,3 +89,16 @@ impl Owner { } } } + +#[cfg(test)] +mod state_tests { + use super::*; + + #[tokio::test] + async fn test_list_authorized_users() { + let result = Owner::list_authorized_users("@.com", "100").await; + + // The result should be Ok(). + assert!(result.is_ok()); + } +} From 39e59fe8180c641293db1682a9863bc00a4b5e9a Mon Sep 17 00:00:00 2001 From: lexara-prime-ai Date: Sun, 14 Jul 2024 22:19:18 +0000 Subject: [PATCH 09/10] Updated variables config. --- .github/workflows/code-coverage.yml | 2 + .../resource_management/models/static_site.rs | 100 +++++++++--------- 2 files changed, 52 insertions(+), 50 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index f4aa017..7e88d86 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -25,6 +25,8 @@ jobs: working-directory: ./rust - name: Run tests with coverage + env: + API_KEY: ${{ secrets.API_KEY }} run: cargo tarpaulin --out Xml working-directory: ./rust diff --git a/rust/src/resource_management/models/static_site.rs b/rust/src/resource_management/models/static_site.rs index 514c4b9..e372aee 100644 --- a/rust/src/resource_management/models/static_site.rs +++ b/rust/src/resource_management/models/static_site.rs @@ -1,70 +1,70 @@ use serde::{Deserialize, Serialize}; -#[derive(Debug, Deserialize, Serialize)] -struct StaticSite { +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct StaticSite { #[serde(rename = "type")] - type_: String, - name: String, - owner_id: String, - repo: String, - auto_deploy: bool, - branch: String, - image: Image, - build_filter: BuildFilter, - root_dir: String, - env_vars: Vec, - secret_files: Vec, - service_details: ServiceDetails, + pub type_: String, + pub name: String, + pub owner_id: String, + pub repo: String, + pub auto_deploy: bool, + pub branch: String, + pub image: Image, + pub build_filter: BuildFilter, + pub root_dir: String, + pub env_vars: Vec, + pub secret_files: Vec, + pub service_details: ServiceDetails, } -#[derive(Debug, Deserialize, Serialize)] -struct Image { - owner_id: String, - registry_credential_id: String, - image_path: String, +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct Image { + pub owner_id: String, + pub registry_credential_id: String, + pub image_path: String, } -#[derive(Debug, Deserialize, Serialize)] -struct BuildFilter { - paths: Vec, - ignored_paths: Vec, +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct BuildFilter { + pub paths: Vec, + pub ignored_paths: Vec, } -#[derive(Debug, Deserialize, Serialize)] -struct EnvVar { - key: String, - value: Option, - generate_value: bool, +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct EnvVar { + pub key: String, + pub value: Option, + pub generate_value: bool, } -#[derive(Debug, Deserialize, Serialize)] -struct SecretFile { - name: String, - content: String, +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct SecretFile { + pub name: String, + pub content: String, } -#[derive(Debug, Deserialize, Serialize)] -struct ServiceDetails { - build_command: String, - headers: Vec
, - publish_path: String, - pull_request_previews_enabled: bool, - routes: Vec, +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct ServiceDetails { + pub build_command: String, + pub headers: Vec
, + pub publish_path: String, + pub pull_request_previews_enabled: bool, + pub routes: Vec, } -#[derive(Debug, Deserialize, Serialize)] -struct Header { - path: String, - name: String, - value: String, +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct Header { + pub path: String, + pub name: String, + pub value: String, } -#[derive(Debug, Deserialize, Serialize)] -struct Route { - type_: String, - source: String, - destination: String, - priority: u32, +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct Route { + pub type_: String, + pub source: String, + pub destination: String, + pub priority: u32, } // fn main() { From 13aea956152a78c72559495da4a297e4c5234491 Mon Sep 17 00:00:00 2001 From: lexara-prime-ai Date: Sun, 14 Jul 2024 22:25:33 +0000 Subject: [PATCH 10/10] Updated root path --- .github/workflows/code-coverage.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 7e88d86..c31555a 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -34,12 +34,13 @@ jobs: uses: actions/upload-artifact@v3 with: name: coverage-report - path: ./tarpaulin-report.xml + path: ./rust/tarpaulin-report.xml - name: Publish coverage to Codecov uses: codecov/codecov-action@v3 with: - files: ./tarpaulin-report.xml + files: ./rust/tarpaulin-report.xml flags: unittests name: codecov-umbrella - fail_ci_if_error: true \ No newline at end of file + fail_ci_if_error: true + working-directory: ./rust \ No newline at end of file