You can set up CI/CD workflows to ensure all assertion tests pass before merging code. The setup is very similar to standard Foundry/Forge workflows, with the addition of installing pcl and running pcl test for testing.
GitHub Actions Example
This workflow:
- Triggers on pull requests to main/develop branches when assertion or source files change
- Supports manual runs with
workflow_dispatch
- Uses the assertions profile via
FOUNDRY_PROFILE: assertions
- Installs the latest pcl from GitHub releases
- Runs all assertion tests with
pcl test
Use the FOUNDRY_PROFILE: assertions environment variable to ensure the correct Foundry profile is used for testing assertions.
Foundry Profile Configuration
Foundry profiles allow you to configure different compilation and testing settings for different parts of your project. For assertions, you typically want separate profiles for different types of tests to avoid running slow tests (like fuzz tests and backtests) every time you want to run quick unit tests locally.
This configuration goes in your project’s foundry.toml file, which you should be familiar with if you have used Foundry before.
Recommended Profile Structure
Organize your tests into separate folders and create profiles for each test type:
Example foundry.toml
Profile Benefits
- Unit tests (
unit-assertions) - Fast feedback during development
- Fuzz tests (
fuzz-assertions) - Run separately when testing edge cases
- Backtests (
backtest-assertions) - Run manually before deployment
- General (
assertions) - Runs all tests for comprehensive validation
When using pcl test or setting FOUNDRY_PROFILE=<profile>, Foundry uses that profile’s configuration instead of the default one.
Running Tests Locally with Profiles
You can set the FOUNDRY_PROFILE environment variable to use specific profiles:
If nothing is specified, the default profile is used.
Best Practices
- Run tests on PR - Catch issues before merging
- Use path filters - Only run tests when relevant files change
- Cache dependencies - Speed up CI runs (Foundry toolchain action handles this)
- Separate profiles - Keep assertion compilation separate from main project
- Pin versions - Consider pinning the
pcl version for reproducibility
Learn More: