From 209ab9ef1bd0d62eaae6d5445234b6a35c221ef0 Mon Sep 17 00:00:00 2001 From: Abinand P Date: Sun, 20 Oct 2024 10:01:19 +0530 Subject: [PATCH] fix: trying to remove the scripts from git diff Signed-off-by: Abinand P --- .../src/base/commitment/table_commitment.rs | 2 +- crates/proof-of-sql/src/base/math/decimal.rs | 112 +++++++--------- scripts/run_ci_checks.sh | 126 +++++++++--------- 3 files changed, 112 insertions(+), 128 deletions(-) diff --git a/crates/proof-of-sql/src/base/commitment/table_commitment.rs b/crates/proof-of-sql/src/base/commitment/table_commitment.rs index f250ebe91..8de64aa1e 100644 --- a/crates/proof-of-sql/src/base/commitment/table_commitment.rs +++ b/crates/proof-of-sql/src/base/commitment/table_commitment.rs @@ -383,7 +383,7 @@ mod tests { use crate::{ base::{ commitment::naive_commitment::NaiveCommitment, - database::{owned_table_utility::*, OwnedColumn}, + database::{owned_table_utility::*, Column, OwnedColumn}, map::IndexMap, scalar::test_scalar::TestScalar, }, diff --git a/crates/proof-of-sql/src/base/math/decimal.rs b/crates/proof-of-sql/src/base/math/decimal.rs index ca2280db3..c1dff7545 100644 --- a/crates/proof-of-sql/src/base/math/decimal.rs +++ b/crates/proof-of-sql/src/base/math/decimal.rs @@ -181,14 +181,12 @@ mod scale_adjust_test { let target_scale = 5; - assert!( - try_convert_intermediate_decimal_to_scalar::( - &decimal, - Precision::new(u8::try_from(decimal.precision()).unwrap_or(u8::MAX)).unwrap(), - target_scale - ) - .is_err() - ); + assert!(try_convert_intermediate_decimal_to_scalar::( + &decimal, + Precision::new(u8::try_from(decimal.precision()).unwrap_or(u8::MAX)).unwrap(), + target_scale + ) + .is_err()); } #[test] @@ -254,14 +252,12 @@ mod scale_adjust_test { .parse() .unwrap(); let target_scale = 6; // now precision exceeds maximum - assert!( - try_convert_intermediate_decimal_to_scalar::( - &decimal, - Precision::new(u8::try_from(decimal.precision()).unwrap_or(u8::MAX),).unwrap(), - target_scale - ) - .is_err() - ); + assert!(try_convert_intermediate_decimal_to_scalar::( + &decimal, + Precision::new(u8::try_from(decimal.precision()).unwrap_or(u8::MAX),).unwrap(), + target_scale + ) + .is_err()); // maximum decimal value we can support let decimal = @@ -269,14 +265,12 @@ mod scale_adjust_test { .parse() .unwrap(); let target_scale = 1; - assert!( - try_convert_intermediate_decimal_to_scalar::( - &decimal, - Precision::new(MAX_SUPPORTED_PRECISION).unwrap(), - target_scale - ) - .is_ok() - ); + assert!(try_convert_intermediate_decimal_to_scalar::( + &decimal, + Precision::new(MAX_SUPPORTED_PRECISION).unwrap(), + target_scale + ) + .is_ok()); // scaling larger than max will fail let decimal = @@ -284,14 +278,12 @@ mod scale_adjust_test { .parse() .unwrap(); let target_scale = 1; - assert!( - try_convert_intermediate_decimal_to_scalar::( - &decimal, - Precision::new(MAX_SUPPORTED_PRECISION).unwrap(), - target_scale - ) - .is_err() - ); + assert!(try_convert_intermediate_decimal_to_scalar::( + &decimal, + Precision::new(MAX_SUPPORTED_PRECISION).unwrap(), + target_scale + ) + .is_err()); // smallest possible decimal value we can support (either signed/unsigned) let decimal = @@ -299,49 +291,41 @@ mod scale_adjust_test { .parse() .unwrap(); let target_scale = MAX_SUPPORTED_PRECISION as i8; - assert!( - try_convert_intermediate_decimal_to_scalar::( - &decimal, - Precision::new(u8::try_from(decimal.precision()).unwrap_or(u8::MAX),).unwrap(), - target_scale - ) - .is_ok() - ); + assert!(try_convert_intermediate_decimal_to_scalar::( + &decimal, + Precision::new(u8::try_from(decimal.precision()).unwrap_or(u8::MAX),).unwrap(), + target_scale + ) + .is_ok()); // this is ok because it can be scaled to 75 precision let decimal = "0.1".parse().unwrap(); let target_scale = MAX_SUPPORTED_PRECISION as i8; - assert!( - try_convert_intermediate_decimal_to_scalar::( - &decimal, - Precision::new(MAX_SUPPORTED_PRECISION).unwrap(), - target_scale - ) - .is_ok() - ); + assert!(try_convert_intermediate_decimal_to_scalar::( + &decimal, + Precision::new(MAX_SUPPORTED_PRECISION).unwrap(), + target_scale + ) + .is_ok()); // this exceeds max precision let decimal = "1.0".parse().unwrap(); let target_scale = 75; - assert!( - try_convert_intermediate_decimal_to_scalar::( - &decimal, - Precision::new(u8::try_from(decimal.precision()).unwrap_or(u8::MAX),).unwrap(), - target_scale - ) - .is_err() - ); + assert!(try_convert_intermediate_decimal_to_scalar::( + &decimal, + Precision::new(u8::try_from(decimal.precision()).unwrap_or(u8::MAX),).unwrap(), + target_scale + ) + .is_err()); // but this is ok let decimal = "1.0".parse().unwrap(); let target_scale = 74; - assert!( - try_convert_intermediate_decimal_to_scalar::( - &decimal, - Precision::new(MAX_SUPPORTED_PRECISION).unwrap(), - target_scale - ) - .is_ok() - ); + assert!(try_convert_intermediate_decimal_to_scalar::( + &decimal, + Precision::new(MAX_SUPPORTED_PRECISION).unwrap(), + target_scale + ) + .is_ok()); } } diff --git a/scripts/run_ci_checks.sh b/scripts/run_ci_checks.sh index 6d1db5c35..a6855447a 100755 --- a/scripts/run_ci_checks.sh +++ b/scripts/run_ci_checks.sh @@ -1,63 +1,63 @@ -#!/bin/bash - -# Exit immediately if a command exits with a non-zero status -set -e - -# Display a help text -[ "$1" = "-h" -o "$1" = "--help" ] && echo "Runs all CI checks (excluding tests and udeps)." && exit - -# The path to the YAML file that defines the CI workflows -YAML_FILE=".github/workflows/lint-and-test.yml" - -# Initialize the directory we're searching from (current directory) -current_dir=$(pwd) - -# Traverse upwards to find the root directory, assuming it exists somewhere above -while [[ ! -f "$current_dir/sxt-proof-of-sql/.github/workflows/lint-and-test.yml" ]]; do - # Move up one directory - current_dir=$(dirname "$current_dir") - - # If we reach the root directory (i.e., /), stop to prevent an infinite loop - if [[ "$current_dir" == "/" ]]; then - echo "Could not find file." - exit 1 - fi -done - -# Check if the YAML file exists -if [ ! -f "$YAML_FILE" ]; then - echo "YAML file $YAML_FILE does not exist." - exit 1 -fi - -# Extract all lines that contain 'cargo' commands from the YAML file, -# excluding ones with '--ignored', 'test', 'rustup', or 'udeps' -cargo_commands=$(grep -E '^\s*run:.*cargo' "$YAML_FILE" | grep -v -- '--ignored' | grep -v 'test' | grep -v 'rustup' | grep -v 'udeps' | sed -E 's/^\s*run:\s*//') - -if [ -z "$cargo_commands" ]; then - echo "No cargo commands (other than tests) found in the YAML file." - exit 1 -fi - -# Run each cargo command, ignoring tests which should be handled separately -echo "Extracted cargo commands (excluding test commands, --ignored tests, and udeps):" -echo "$cargo_commands" -echo "=========================" - -# Execute the commands -failed_tests=0 -while IFS= read -r cmd; do - echo "Running command: $cmd" - if ! eval "$cmd"; then - echo "Error: Command failed - $cmd" - echo "Stopping execution." - failed_tests=$((failed_tests + 1)) - fi -done <<< "$cargo_commands" - -# Print the results -if [ "$failed_tests" -gt 0 ]; then - echo "Error: $failed_tests CI checks (excluding tests and udeps) have FAILED." -else - echo "All CI checks (excluding tests and udeps) have completed successfully." -fi \ No newline at end of file +#!/bin/bash + +# Exit immediately if a command exits with a non-zero status +set -e + +# Display a help text +[ "$1" = "-h" -o "$1" = "--help" ] && echo "Runs all CI checks (excluding tests and udeps)." && exit + +# The path to the YAML file that defines the CI workflows +YAML_FILE=".github/workflows/lint-and-test.yml" + +# Initialize the directory we're searching from (current directory) +current_dir=$(pwd) + +# Traverse upwards to find the root directory, assuming it exists somewhere above +while [[ ! -f "$current_dir/sxt-proof-of-sql/.github/workflows/lint-and-test.yml" ]]; do + # Move up one directory + current_dir=$(dirname "$current_dir") + + # If we reach the root directory (i.e., /), stop to prevent an infinite loop + if [[ "$current_dir" == "/" ]]; then + echo "Could not find file." + exit 1 + fi +done + +# Check if the YAML file exists +if [ ! -f "$YAML_FILE" ]; then + echo "YAML file $YAML_FILE does not exist." + exit 1 +fi + +# Extract all lines that contain 'cargo' commands from the YAML file, +# excluding ones with '--ignored', 'test', 'rustup', or 'udeps' +cargo_commands=$(grep -E '^\s*run:.*cargo' "$YAML_FILE" | grep -v -- '--ignored' | grep -v 'test' | grep -v 'rustup' | grep -v 'udeps' | sed -E 's/^\s*run:\s*//') + +if [ -z "$cargo_commands" ]; then + echo "No cargo commands (other than tests) found in the YAML file." + exit 1 +fi + +# Run each cargo command, ignoring tests which should be handled separately +echo "Extracted cargo commands (excluding test commands, --ignored tests, and udeps):" +echo "$cargo_commands" +echo "=========================" + +# Execute the commands +failed_tests=0 +while IFS= read -r cmd; do + echo "Running command: $cmd" + if ! eval "$cmd"; then + echo "Error: Command failed - $cmd" + echo "Stopping execution." + failed_tests=$((failed_tests + 1)) + fi +done <<< "$cargo_commands" + +# Print the results +if [ "$failed_tests" -gt 0 ]; then + echo "Error: $failed_tests CI checks (excluding tests and udeps) have FAILED." +else + echo "All CI checks (excluding tests and udeps) have completed successfully." +fi