Skip to content

Commit

Permalink
Merge pull request #37 from lexara-prime-ai/dev
Browse files Browse the repository at this point in the history
Updated coverage
  • Loading branch information
irfanghat authored Jul 14, 2024
2 parents feafbe3 + 13aea95 commit 5291c6c
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 90 deletions.
67 changes: 35 additions & 32 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,45 @@ name: Code Coverage

on:
push:
branches: [master]
branches: [ master ]
pull_request:
branches: [master]
branches: [ master ]

jobs:
code-coverage:
runs-on: ubuntu-latest

steps:
- 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
- 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
env:
API_KEY: ${{ secrets.API_KEY }}
run: cargo tarpaulin --out Xml
working-directory: ./rust

- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: ./rust/tarpaulin-report.xml

- name: Publish coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./rust/tarpaulin-report.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
working-directory: ./rust
8 changes: 0 additions & 8 deletions rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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("[email protected]", "100").await;

// The result should be Ok().
assert!(result.is_ok());
}
}
100 changes: 50 additions & 50 deletions rust/src/resource_management/models/static_site.rs
Original file line number Diff line number Diff line change
@@ -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<EnvVar>,
secret_files: Vec<SecretFile>,
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<EnvVar>,
pub secret_files: Vec<SecretFile>,
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<String>,
ignored_paths: Vec<String>,
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct BuildFilter {
pub paths: Vec<String>,
pub ignored_paths: Vec<String>,
}

#[derive(Debug, Deserialize, Serialize)]
struct EnvVar {
key: String,
value: Option<String>,
generate_value: bool,
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct EnvVar {
pub key: String,
pub value: Option<String>,
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<Header>,
publish_path: String,
pull_request_previews_enabled: bool,
routes: Vec<Route>,
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ServiceDetails {
pub build_command: String,
pub headers: Vec<Header>,
pub publish_path: String,
pub pull_request_previews_enabled: bool,
pub routes: Vec<Route>,
}

#[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() {
Expand Down
13 changes: 13 additions & 0 deletions rust/src/state_management/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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("<user>@<email>.com", "100").await;

// The result should be Ok().
assert!(result.is_ok());
}
}

0 comments on commit 5291c6c

Please sign in to comment.