ci: Add CI workflow for Rhai tests
- Added a GitHub Actions workflow to automatically run Rhai tests on push and pull request events. - Created documentation for the CI workflow. - Improved test runner script to log output to a file and check for test failures.
This commit is contained in:
@@ -9,10 +9,19 @@ YELLOW='\033[0;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Create log file
|
||||
LOG_FILE="run_rhai_tests.log"
|
||||
> $LOG_FILE # Clear log file if it exists
|
||||
|
||||
# Function to log messages to both console and log file
|
||||
log() {
|
||||
echo -e "$1" | tee -a $LOG_FILE
|
||||
}
|
||||
|
||||
# Print header
|
||||
echo -e "${BLUE}=======================================${NC}"
|
||||
echo -e "${BLUE} Running All Rhai Tests ${NC}"
|
||||
echo -e "${BLUE}=======================================${NC}"
|
||||
log "${BLUE}=======================================${NC}"
|
||||
log "${BLUE} Running All Rhai Tests ${NC}"
|
||||
log "${BLUE}=======================================${NC}"
|
||||
|
||||
# Find all test runner scripts
|
||||
RUNNERS=$(find src/rhai_tests -name "run_all_tests.rhai")
|
||||
@@ -26,38 +35,39 @@ FAILED_MODULES=0
|
||||
for runner in $RUNNERS; do
|
||||
# Extract module name from path
|
||||
module=$(echo $runner | cut -d'/' -f3)
|
||||
|
||||
echo -e "\n${YELLOW}Running tests for module: ${module}${NC}"
|
||||
echo -e "${YELLOW}-------------------------------------${NC}"
|
||||
|
||||
|
||||
log "\n${YELLOW}Running tests for module: ${module}${NC}"
|
||||
log "${YELLOW}-------------------------------------${NC}"
|
||||
|
||||
# Run the test runner
|
||||
herodo --path $runner
|
||||
|
||||
herodo --path $runner | tee -a $LOG_FILE
|
||||
TEST_RESULT=${PIPESTATUS[0]}
|
||||
|
||||
# Check if the test passed
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "${GREEN}✓ Module ${module} tests passed${NC}"
|
||||
if [ $TEST_RESULT -eq 0 ]; then
|
||||
log "${GREEN}✓ Module ${module} tests passed${NC}"
|
||||
PASSED_MODULES=$((PASSED_MODULES + 1))
|
||||
else
|
||||
echo -e "${RED}✗ Module ${module} tests failed${NC}"
|
||||
log "${RED}✗ Module ${module} tests failed${NC}"
|
||||
FAILED_MODULES=$((FAILED_MODULES + 1))
|
||||
fi
|
||||
|
||||
|
||||
TOTAL_MODULES=$((TOTAL_MODULES + 1))
|
||||
done
|
||||
|
||||
# Print summary
|
||||
echo -e "\n${BLUE}=======================================${NC}"
|
||||
echo -e "${BLUE} Test Summary ${NC}"
|
||||
echo -e "${BLUE}=======================================${NC}"
|
||||
echo -e "Total modules tested: ${TOTAL_MODULES}"
|
||||
echo -e "Passed: ${GREEN}${PASSED_MODULES}${NC}"
|
||||
echo -e "Failed: ${RED}${FAILED_MODULES}${NC}"
|
||||
log "\n${BLUE}=======================================${NC}"
|
||||
log "${BLUE} Test Summary ${NC}"
|
||||
log "${BLUE}=======================================${NC}"
|
||||
log "Total modules tested: ${TOTAL_MODULES}"
|
||||
log "Passed: ${GREEN}${PASSED_MODULES}${NC}"
|
||||
log "Failed: ${RED}${FAILED_MODULES}${NC}"
|
||||
|
||||
# Set exit code based on test results
|
||||
if [ $FAILED_MODULES -eq 0 ]; then
|
||||
echo -e "\n${GREEN}All tests passed!${NC}"
|
||||
log "\n${GREEN}All tests passed!${NC}"
|
||||
exit 0
|
||||
else
|
||||
echo -e "\n${RED}Some tests failed!${NC}"
|
||||
log "\n${RED}Some tests failed!${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
Reference in New Issue
Block a user