ClearGrow Controller CI/CD
GitHub Actions workflows for automated testing, building, and releasing ClearGrow Controller firmware.
Workflows
1. CI Pipeline (ci.yml)
Triggers:
- Push to
mainordevelopbranches - Pull requests targeting
mainordevelop
Jobs:
-
Test - Validates all unit tests
- Runs
test/run_tests.shto validate test structure - Generates coverage report with
test/run_coverage.sh - Must pass before builds proceed
- Runs
-
Build Development - Builds firmware with development configuration
- Uses
sdkconfig.defaults(no security features) - Generates size analysis report
- Uploads firmware artifacts (retained 30 days)
- Uses
-
Build Production - Builds firmware with production configuration
- Uses
sdkconfig.defaults+sdkconfig.defaults.prod - Enables flash encryption, secure boot, NVS encryption
- Uploads firmware artifacts (retained 90 days)
- Uses
-
Status Summary - Reports overall CI status
- Aggregates results from all jobs
- Provides clear pass/fail status
Artifacts Generated:
firmware-dev-<sha>- Development binaries (.bin, .elf, .map)firmware-prod-<sha>- Production binaries (.bin, .elf, .map)build-report-dev-<sha>.txt- Development size analysisbuild-report-prod-<sha>.txt- Production size analysis
2. Coverage Tracking (coverage.yml)
Triggers:
- Push to
main - Pull requests targeting
main
Features:
- Builds with coverage flags (
-fprofile-arcs -ftest-coverage) - Generates component coverage report
- Comments coverage summary on pull requests
- Tracks coverage metrics over time
Future Enhancement:
- Full gcov/lcov line coverage analysis
- Coverage trend graphs
- Minimum coverage thresholds
3. Release Workflow (release.yml)
Triggers:
- Git tags matching
v*.*.*(e.g.,v2.1.0)
Process:
- Builds production firmware with security features
- Generates versioned artifacts with SHA256 checksums
- Creates comprehensive release notes
- Publishes GitHub Release with all artifacts
Release Artifacts:
cleargrow-controller-v{version}.bin- Main firmwarebootloader-v{version}.bin- Bootloaderpartition-table-v{version}.bin- Partition tablechecksums-v{version}.txt- SHA256 checksumsbuild-report-v{version}.txt- Size analysisRELEASE_NOTES.md- Flashing instructions
Using the Workflows
For Developers
Local Development:
# Before pushing, run tests locally
cd /root/cleargrow/controller/test
./run_tests.sh
# Check coverage
./run_coverage.sh
# Build to verify
cd ..
idf.py build
Pull Request Process:
- Create feature branch
- Commit changes
- Push to GitHub
- Open pull request to
developormain - CI automatically runs and reports status
- Coverage report posted as PR comment
- Review build artifacts if needed
Accessing Artifacts:
- Navigate to Actions tab on GitHub
- Click on the workflow run
- Scroll to "Artifacts" section
- Download desired artifacts
For Maintainers
Creating a Release:
-
Update version in code (if needed)
-
Commit and push changes
-
Create and push git tag:
git tag -a v2.1.0 -m "Release version 2.1.0" git push origin v2.1.0 -
GitHub Actions automatically:
- Builds production firmware
- Generates checksums
- Creates GitHub Release
- Uploads all artifacts
-
Edit release notes on GitHub (optional)
-
Distribute firmware to users/OTA server
Build Configurations
Development Build
- Security: Disabled
- Use Case: Daily development, debugging
- Reflashing: Easy, no restrictions
- Config:
sdkconfig.defaults
Production Build
- Security: Full (flash encryption, secure boot, NVS encryption)
- Use Case: Manufacturing, production deployment
- Reflashing: Restricted (one-way operation)
- Config:
sdkconfig.defaults+sdkconfig.defaults.prod
Status Checks
Pull requests require all CI checks to pass:
- Unit tests validated
- Coverage report generated
- Development build successful
- Production build successful
Troubleshooting
Build Failures
ESP-IDF version mismatch:
- Workflow uses ESP-IDF v5.2
- Ensure local environment matches:
idf.py --version
Missing submodules:
- Workflows checkout with
submodules: recursive - Local:
git submodule update --init --recursive
Configuration errors:
- Check
sdkconfig.defaultsandsdkconfig.defaults.prod - Run
idf.py menuconfigto verify settings
Test Failures
Test script errors:
- Ensure scripts are executable:
chmod +x test/run_*.sh - Run locally to reproduce:
cd test && ./run_tests.sh
Missing test files:
- Test runner validates file structure
- Add missing tests or update test list in
run_tests.sh
Artifact Issues
Artifacts expired:
- Development artifacts: 30 day retention
- Production artifacts: 90 day retention
- Rebuild from git tag if needed
Download failures:
- Check artifact size (large .elf files)
- Use GitHub CLI for reliable downloads:
gh run download <run-id>
Performance
Typical workflow execution times:
- Test job: 2-3 minutes
- Build Development: 5-8 minutes
- Build Production: 5-8 minutes
- Coverage: 3-5 minutes
- Release: 6-10 minutes
Total CI time (parallel execution): ~10-15 minutes
Future Enhancements
Planned improvements tracked in testing assessment:
-
Hardware-in-the-Loop Testing (CTRL-TE-002)
- Dedicated ESP32-S3 test hardware
- Automated peripheral testing
- Integration with CI pipeline
-
Full Line Coverage (gcov/lcov)
- Generate detailed coverage reports
- Visualize coverage trends
- Enforce minimum thresholds
-
Performance Benchmarks
- Boot time measurements
- Memory usage tracking
- Regression detection
-
Automated Firmware Signing
- ECDSA signature generation
- Secure key management
- OTA package creation
-
Multi-Environment Testing
- Test across ESP-IDF versions
- Validate against different configurations
- Matrix builds
References
- ESP-IDF CI Action: https://github.com/espressif/esp-idf-ci-action
- GitHub Actions Docs: https://docs.github.com/en/actions
- Testing Documentation:
/root/cleargrow/controller/test/README.md - Production Build Guide:
/root/cleargrow/docs/guides/developer/onboarding/production-build.md