Skip to content

Commit

Permalink
ci tests
Browse files Browse the repository at this point in the history
  • Loading branch information
perfplay committed Aug 25, 2024
1 parent a6a9c4a commit 3515272
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 3 deletions.
25 changes: 25 additions & 0 deletions .ci/build_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

cd ../

run_build() {
build_type=$1
build_dir=$2

echo "Building with BUILD_TYPE=$build_type..."

make -B build BUILD_TYPE="$build_type" BUILD_DIR="$build_dir"

if [ $? -ne 0 ]; then
echo "Error: Build failed for BUILD_TYPE=$build_type."
exit 1
else
echo "Success: Build completed successfully for BUILD_TYPE=$build_type."
fi
}

run_build Debug build-debug
run_build Release build

echo "All build tests completed successfully."
exit 0
24 changes: 24 additions & 0 deletions .ci/cargo_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

export HEADER_FILE="/dev/null"
export CBINDGEN_CONFIG="../../cbindgen.toml"

CRATES_DIR="../crates"

for dir in "$CRATES_DIR"/*; do
if [ -d "$dir" ]; then
echo "Entering directory: $dir"
cd "$dir" || exit

cargo test

if [ $? -ne 0 ]; then
echo "Error: cargo test failed in $dir"
exit 1
fi

cd - || exit
fi
done

echo "All tests completed successfully."
38 changes: 38 additions & 0 deletions .ci/check_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os

required_structure = {
'install': {
'include': {
'arkworks': ['arkworks.h'],
'bandersnatch_vrfs': ['bandersnatch_vrfs.h'],
'schnorrkel': ['schnorrkel.h']
},
'lib': {
'cmake': {
'arkworks': ['arkworksConfig.cmake'],
'bandersnatch_vrfs': ['bandersnatch_vrfsConfig.cmake'],
'schnorrkel': ['schnorrkelConfig.cmake']
},
'': ['libarkworks_crust.a', 'libbandersnatch_vrfs_crust.a', 'libschnorrkel_crust.a']
}
}
}

def check_structure(base_path, structure):
for folder, contents in structure.items():
current_path = os.path.join(base_path, folder)

if isinstance(contents, dict):
if not os.path.isdir(current_path):
print(f"Missing directory: {current_path}")
else:
check_structure(current_path, contents)
else:
for file in contents:
file_path = os.path.join(base_path, folder, file)
if not os.path.isfile(file_path):
print(f"Missing file: {file_path}")

base_path = '../'

check_structure(base_path, required_structure)
34 changes: 34 additions & 0 deletions .ci/run_all_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

scripts=("build_test.sh" "check_files.py" "cargo_tests.sh")

error_found=0

for script in "${scripts[@]}"; do
echo "Running $script..."

if [[ "$script" == *.py ]]; then
python3 "$script"
elif [[ "$script" == *.sh ]]; then
bash "$script"
else
echo "Unknown file type for script: $script"
error_found=1
continue
fi

if [ $? -ne 0 ]; then
echo "Error: $script failed."
error_found=1
else
echo "Success: $script completed successfully."
fi
done

if [ $error_found -ne 0 ]; then
echo "One or more scripts failed."
exit 1
else
echo "All scripts ran successfully."
exit 0
fi
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
target
/build
/generated
/install
/.idea
/build-*

**/Cargo.lock
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
BUILD_DIR ?= build
BUILD_TYPE ?= Release

BUILD_THREADS := $$(nproc 2>/dev/null || sysctl -n hw.ncpu)


build:
if [ "$$(uname)" = "Darwin" ]; then \
export SDKROOT=$$(xcrun --sdk macosx --show-sdk-path) ; \
fi ; \
cmake . -B"$(BUILD_DIR)" -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) ; \
cmake --build "$(BUILD_DIR)" -- -j$(BUILD_THREADS) ; \
cmake --install "$(BUILD_DIR)"

5 changes: 2 additions & 3 deletions crates/schnorrkel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ crate-type = ["cdylib", "staticlib"]
cpp = { path = "../cpp" }
schnorrkel = { version="0.9.1", features = ["preaudit_deprecated"] }
ed25519-dalek = { version="1.0.0" }
rand_chacha = "0.3.1"
rand_core = "0.6.2"
rand_chacha = "0.2.1"
merlin = { version = "2.0", default-features = false }
parity-scale-codec = { version = "3.6.1", default-features = false, features = ["bit-vec", "derive"] }
rand = "0.8"
rand = "0.7"
bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] }
scale-info = { version = "2.11.1", default-features = false, features = ["derive"] }
itertools = "0.10.5"
Expand Down

0 comments on commit 3515272

Please sign in to comment.