- 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.
2.7 KiB
Continuous Integration for Rhai Tests
This document describes the continuous integration (CI) workflow for running Rhai tests in the SAL library.
GitHub Actions Workflow
The SAL project includes a GitHub Actions workflow that automatically runs all Rhai tests whenever changes are made to relevant files. This ensures that the Rhai integration continues to work correctly as the codebase evolves.
Workflow File
The workflow is defined in .github/workflows/rhai-tests.yml
.
Trigger Events
The workflow runs automatically when:
-
Changes are pushed to the
main
ormaster
branch that affect:- Rhai test scripts (
src/rhai_tests/**
) - Rhai module code (
src/rhai/**
) - Git module code (
src/git/**
) - OS module code (
src/os/**
) - The test runner script (
run_rhai_tests.sh
) - The workflow file itself (
.github/workflows/rhai-tests.yml
)
- Rhai test scripts (
-
A pull request is opened or updated that affects the same files.
-
The workflow is manually triggered using the GitHub Actions interface.
Workflow Steps
The workflow performs the following steps:
- Checkout Code: Checks out the repository code.
- Set up Rust: Installs the Rust toolchain.
- Cache Dependencies: Caches Rust dependencies to speed up builds.
- Build herodo: Builds the
herodo
binary used to run Rhai scripts. - Install Dependencies: Installs system dependencies like Git and curl.
- Run Rhai Tests: Runs the
run_rhai_tests.sh
script to execute all Rhai tests. - Check for Failures: Verifies that all tests passed.
Test Results
The workflow will fail if any Rhai test fails. This prevents changes that break the Rhai integration from being merged.
Local Testing
Before pushing changes, you can run the same tests locally using the run_rhai_tests.sh
script:
./run_rhai_tests.sh
This will produce the same test results as the CI workflow, allowing you to catch and fix issues before pushing your changes.
Logs
The test runner script creates a log file (run_rhai_tests.log
) that contains the output of all tests. This log is used by the CI workflow to check for test failures.
Adding New Tests
When adding new tests, make sure they are included in the appropriate module's test runner script (run_all_tests.rhai
). The CI workflow will automatically run the new tests.
Troubleshooting
If the CI workflow fails, check the GitHub Actions logs for details. Common issues include:
- Missing Dependencies: Ensure all required dependencies are installed.
- Test Failures: Fix any failing tests.
- Build Errors: Fix any errors in the Rust code.
If you need to modify the workflow, edit the .github/workflows/rhai-tests.yml
file.