|
| 1 | +# CI/CD Pipeline |
| 2 | + |
| 3 | +This directory contains GitHub Actions workflows for automated testing and validation. |
| 4 | + |
| 5 | +## Workflows |
| 6 | + |
| 7 | +### `ci.yml` - Continuous Integration Pipeline |
| 8 | + |
| 9 | +Automated testing pipeline that runs on every push and pull request. |
| 10 | + |
| 11 | +#### Jobs |
| 12 | + |
| 13 | +1. **Unit Tests** (`unit-tests`) |
| 14 | + - Platform: Ubuntu Latest |
| 15 | + - Compiles and runs all unit tests |
| 16 | + - Tests boundary conditions and initialization modules |
| 17 | + - Uploads test results as artifacts |
| 18 | + |
| 19 | +2. **CPU OpenMP Build** (`cpu-openmp`) |
| 20 | + - Platform: Ubuntu Latest |
| 21 | + - Builds CPU OpenMP version with g++-13 |
| 22 | + - Runs smoke test with 10 particles |
| 23 | + - Validates no NaN values in output |
| 24 | + - Uploads executable and simulation results |
| 25 | + |
| 26 | +3. **GPU Hybrid Build** (`gpu-hybrid-macos`) |
| 27 | + - Platform: macOS Latest (required for Metal support) |
| 28 | + - Builds GPU hybrid version with clang++ |
| 29 | + - Tests CPU fallback mode with 100 particles |
| 30 | + - Validates Metal shader compilation |
| 31 | + - Checks for NaN-free output |
| 32 | + - Uploads executable and simulation results |
| 33 | + |
| 34 | +4. **Benchmark Validation** (`benchmark-validation`) |
| 35 | + - Platform: macOS Latest |
| 36 | + - Validates benchmark script functionality |
| 37 | + - Runs minimal 3-way comparison (100 particles only) |
| 38 | + - Verifies Python visualization dependencies (uv, plotly, pandas) |
| 39 | + - Checks CSV output format |
| 40 | + |
| 41 | +5. **Documentation Check** (`documentation-check`) |
| 42 | + - Platform: Ubuntu Latest |
| 43 | + - Verifies all README files exist |
| 44 | + - Validates LICENSE file (Apache 2.0) |
| 45 | + - Checks parameter.txt format (11 tab-separated values) |
| 46 | + - Detects broken relative links |
| 47 | + |
| 48 | +6. **CI Success** (`ci-success`) |
| 49 | + - Summary job requiring all previous jobs to pass |
| 50 | + - Provides consolidated success message |
| 51 | + |
| 52 | +## Triggers |
| 53 | + |
| 54 | +The pipeline runs on: |
| 55 | +- **Push** to `main` or `jv/improvement2` branches |
| 56 | +- **Pull requests** to `main` |
| 57 | +- **Manual dispatch** via GitHub Actions UI |
| 58 | + |
| 59 | +## Artifacts |
| 60 | + |
| 61 | +Each job produces artifacts that are retained for 90 days: |
| 62 | +- `test-results` - Unit test executables |
| 63 | +- `cpu-openmp-build` - CPU version executable and output |
| 64 | +- `gpu-hybrid-macos-build` - GPU version executable and output |
| 65 | +- `benchmark-test-results` - Benchmark CSV data |
| 66 | + |
| 67 | +## Local Testing |
| 68 | + |
| 69 | +Run the same checks locally before pushing: |
| 70 | + |
| 71 | +```bash |
| 72 | +# Unit tests |
| 73 | +cd tests |
| 74 | +make test |
| 75 | + |
| 76 | +# CPU build |
| 77 | +cd cpu_openmp |
| 78 | +make clean && make |
| 79 | +echo -e "0.01\t1e-4\t10\t10.1\t0.0\t0.0\t15.0\t15.0\t10\t5\t2" > parameter.txt |
| 80 | +./abp_3D_confine.out |
| 81 | + |
| 82 | +# GPU build (macOS only) |
| 83 | +cd gpu_hybrid |
| 84 | +make clean && make |
| 85 | +echo -e "0.01\t1e-4\t100\t10.1\t0.0\t0.0\t15.0\t15.0\t10\t5\t2" > parameter.txt |
| 86 | +./abp_3D_confine.out |
| 87 | + |
| 88 | +# Check for NaN |
| 89 | +grep -q "nan" data/simulation.csv && echo "FAIL: NaN detected" || echo "PASS: No NaN" |
| 90 | +``` |
| 91 | + |
| 92 | +## Requirements |
| 93 | + |
| 94 | +### Ubuntu Runners |
| 95 | +- build-essential |
| 96 | +- g++-13 |
| 97 | +- libomp-dev |
| 98 | + |
| 99 | +### macOS Runners |
| 100 | +- Xcode Command Line Tools |
| 101 | +- Homebrew (libomp) |
| 102 | +- Metal framework (built-in) |
| 103 | + |
| 104 | +## Status Badge |
| 105 | + |
| 106 | +Add to README.md: |
| 107 | +```markdown |
| 108 | +[](https://github.com/jvachier/active_particles_in_3D/actions) |
| 109 | +``` |
| 110 | + |
| 111 | +## Troubleshooting |
| 112 | + |
| 113 | +### Tests fail on Ubuntu but pass locally (macOS) |
| 114 | +- Check g++ version (requires g++-13+) |
| 115 | +- Verify OpenMP installation: `dpkg -l | grep libomp` |
| 116 | + |
| 117 | +### GPU tests fail on macOS |
| 118 | +- Ensure libomp installed: `brew list libomp` |
| 119 | +- Check Metal shader exists: `test -f gpu_hybrid/particle_interactions.metal` |
| 120 | + |
| 121 | +### Benchmark validation timeout |
| 122 | +- Reduce particle count in `benchmark_test.sh` |
| 123 | +- Current: 100 particles, 10 timesteps (takes ~1s) |
| 124 | + |
| 125 | +### Documentation check fails |
| 126 | +- Verify parameter.txt has 11 fields: `awk -F'\t' '{print NF}' parameter.txt` |
| 127 | +- Check relative links in README files |
| 128 | + |
| 129 | +## Contributing |
| 130 | + |
| 131 | +When adding new features: |
| 132 | +1. Update unit tests if modifying core modules |
| 133 | +2. Ensure all tests pass locally before pushing |
| 134 | +3. Update documentation (README files) |
| 135 | +4. If adding new dependencies, update CI workflow |
| 136 | + |
| 137 | +## Maintenance |
| 138 | + |
| 139 | +Pipeline configuration is in YAML format. Key sections: |
| 140 | +- `on:` - Trigger conditions |
| 141 | +- `jobs:` - Individual test stages |
| 142 | +- `steps:` - Commands within each job |
| 143 | +- `needs:` - Job dependencies |
| 144 | + |
| 145 | +To modify: |
| 146 | +1. Edit `.github/workflows/ci.yml` |
| 147 | +2. Test locally if possible |
| 148 | +3. Push to feature branch first |
| 149 | +4. Monitor Actions tab for results |
| 150 | +5. Merge to main after verification |
| 151 | + |
| 152 | +--- |
| 153 | + |
| 154 | +**Last Updated**: November 2025 |
| 155 | +**Maintainer**: Jeremy Vachier |
0 commit comments