Skip to content

Commit

Permalink
fix: trying to remove the scripts from git diff
Browse files Browse the repository at this point in the history
Signed-off-by: Abinand P <[email protected]>
  • Loading branch information
Abiji-2020 committed Oct 27, 2024
1 parent 8c4eb1e commit 209ab9e
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
112 changes: 48 additions & 64 deletions crates/proof-of-sql/src/base/math/decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,12 @@ mod scale_adjust_test {

let target_scale = 5;

assert!(
try_convert_intermediate_decimal_to_scalar::<TestScalar>(
&decimal,
Precision::new(u8::try_from(decimal.precision()).unwrap_or(u8::MAX)).unwrap(),
target_scale
)
.is_err()
);
assert!(try_convert_intermediate_decimal_to_scalar::<TestScalar>(
&decimal,
Precision::new(u8::try_from(decimal.precision()).unwrap_or(u8::MAX)).unwrap(),
target_scale
)
.is_err());
}

#[test]
Expand Down Expand Up @@ -254,94 +252,80 @@ mod scale_adjust_test {
.parse()
.unwrap();
let target_scale = 6; // now precision exceeds maximum
assert!(
try_convert_intermediate_decimal_to_scalar::<TestScalar>(
&decimal,
Precision::new(u8::try_from(decimal.precision()).unwrap_or(u8::MAX),).unwrap(),
target_scale
)
.is_err()
);
assert!(try_convert_intermediate_decimal_to_scalar::<TestScalar>(
&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 =
"99999999999999999999999999999999999999999999999999999999999999999999999999.0"
.parse()
.unwrap();
let target_scale = 1;
assert!(
try_convert_intermediate_decimal_to_scalar::<TestScalar>(
&decimal,
Precision::new(MAX_SUPPORTED_PRECISION).unwrap(),
target_scale
)
.is_ok()
);
assert!(try_convert_intermediate_decimal_to_scalar::<TestScalar>(
&decimal,
Precision::new(MAX_SUPPORTED_PRECISION).unwrap(),
target_scale
)
.is_ok());

// scaling larger than max will fail
let decimal =
"999999999999999999999999999999999999999999999999999999999999999999999999999.0"
.parse()
.unwrap();
let target_scale = 1;
assert!(
try_convert_intermediate_decimal_to_scalar::<TestScalar>(
&decimal,
Precision::new(MAX_SUPPORTED_PRECISION).unwrap(),
target_scale
)
.is_err()
);
assert!(try_convert_intermediate_decimal_to_scalar::<TestScalar>(
&decimal,
Precision::new(MAX_SUPPORTED_PRECISION).unwrap(),
target_scale
)
.is_err());

// smallest possible decimal value we can support (either signed/unsigned)
let decimal =
"0.000000000000000000000000000000000000000000000000000000000000000000000000001"
.parse()
.unwrap();
let target_scale = MAX_SUPPORTED_PRECISION as i8;
assert!(
try_convert_intermediate_decimal_to_scalar::<TestScalar>(
&decimal,
Precision::new(u8::try_from(decimal.precision()).unwrap_or(u8::MAX),).unwrap(),
target_scale
)
.is_ok()
);
assert!(try_convert_intermediate_decimal_to_scalar::<TestScalar>(
&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::<TestScalar>(
&decimal,
Precision::new(MAX_SUPPORTED_PRECISION).unwrap(),
target_scale
)
.is_ok()
);
assert!(try_convert_intermediate_decimal_to_scalar::<TestScalar>(
&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::<TestScalar>(
&decimal,
Precision::new(u8::try_from(decimal.precision()).unwrap_or(u8::MAX),).unwrap(),
target_scale
)
.is_err()
);
assert!(try_convert_intermediate_decimal_to_scalar::<TestScalar>(
&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::<TestScalar>(
&decimal,
Precision::new(MAX_SUPPORTED_PRECISION).unwrap(),
target_scale
)
.is_ok()
);
assert!(try_convert_intermediate_decimal_to_scalar::<TestScalar>(
&decimal,
Precision::new(MAX_SUPPORTED_PRECISION).unwrap(),
target_scale
)
.is_ok());
}
}
126 changes: 63 additions & 63 deletions scripts/run_ci_checks.sh
Original file line number Diff line number Diff line change
@@ -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
#!/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

0 comments on commit 209ab9e

Please sign in to comment.