diff --git a/.idea/editor.xml b/.idea/editor.xml new file mode 100644 index 0000000..ead1d8a --- /dev/null +++ b/.idea/editor.xml @@ -0,0 +1,248 @@ + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/Sim.xml b/.idea/runConfigurations/Sim.xml new file mode 100644 index 0000000..c851eaf --- /dev/null +++ b/.idea/runConfigurations/Sim.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git a/README.md b/README.md index 1d894fa..931c76b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # ๐Ÿš€ Luke's Rocket Launch Controller -[![Build Status](https://github.com/KofTwentyTwo/Lukes-Rocket-Launcher/workflows/Build%20and%20Test%20Arduino%20Firmware/badge.svg)](https://github.com/KofTwentyTwo/Lukes-Rocket-Launcher/actions) -[![Tests](https://github.com/KofTwentyTwo/Lukes-Rocket-Launcher/workflows/Build%20and%20Test%20Arduino%20Firmware/badge.svg?branch=main&event=push)](https://github.com/KofTwentyTwo/Lukes-Rocket-Launcher/actions) +[![CI/CD Pipeline](https://github.com/KofTwentyTwo/Lukes-Rocket-Launcher/workflows/Build%20and%20Test%20Arduino%20Firmware/badge.svg)](https://github.com/KofTwentyTwo/Lukes-Rocket-Launcher/actions?query=workflow%3A%22Build+and+Test+Arduino+Firmware%22) +[![Latest Release](https://img.shields.io/github/v/release/KofTwentyTwo/Lukes-Rocket-Launcher?include_prereleases&sort=semver)](https://github.com/KofTwentyTwo/Lukes-Rocket-Launcher/releases) +[![Tests](https://img.shields.io/badge/Tests-Passing-brightgreen.svg)](https://github.com/KofTwentyTwo/Lukes-Rocket-Launcher/actions?query=workflow%3A%22Build+and+Test+Arduino+Firmware%22) [![PlatformIO](https://img.shields.io/badge/PlatformIO-6.1.7-blue.svg)](https://platformio.org/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) @@ -9,12 +10,9 @@ **To be clear** - this is for an awesome 11-year-old that loves rockets and micro-electronics and a nerdy dad that wants to empower and support him in every way possible. Because nothing says "I love you" like helping your kid build something that can launch rockets into the sky! ๐Ÿš€๐Ÿ’• +![Rocket Launch Controller Circuit](docs/screen-1.png "Rocket Launch Controller Circuit") -![Rocket Launch Controller Circuit](docs/screen-1.png) - - +![Rocket Launch Demo](docs/clip-1.mp4) *Watch the controller in action! The simulation shows the complete launch sequence from startup to ignition.* @@ -155,57 +153,57 @@ The project now includes comprehensive unit testing: ``` ### **Building & Testing** ๐Ÿงช -The project now includes a comprehensive build system with automated testing! +The project now includes a comprehensive build system with automated testing and simulation! ```bash -# ๐Ÿš€ Default: Run tests and build everything -make +# ๐Ÿš€ Build and launch simulator (recommended for development) +./scripts/build.sh sim -# ๐Ÿงช Just run tests -make test +# ๐Ÿงช Run unit tests +./scripts/build.sh test -# ๐Ÿ”ง Build everything (skip tests) -make build-only +# ๐Ÿ”ง Build everything (tests + CMake + PlatformIO) +./scripts/build.sh -# ๐ŸŽฎ Build for simulation -make build-sim +# ๐ŸŽฎ Build simulation firmware only +./scripts/build.sh firmware-sim -# โšก Build for hardware -make build-hw +# โšก Build hardware firmware only +./scripts/build.sh firmware-hw # ๐Ÿ“ค Upload to Arduino -make upload - -# ๐ŸŽฎ Prepare for SimulIDE -make upload-sim +./scripts/build.sh upload # ๐Ÿ“ก Monitor serial output -make monitor +./scripts/build.sh monitor # ๐ŸŽจ Format code -make format +./scripts/build.sh format # ๐Ÿงน Clean build files -make clean +./scripts/build.sh clean -# โ“ Show all available targets -make help +# โ“ Show all available commands +./scripts/build.sh help ``` **Why the new build system?** We've added comprehensive unit testing and automated builds to ensure reliability and make development easier! ### **Build System Benefits** ๐ŸŽฏ -- **๐Ÿš€ One Command**: `make` runs tests and builds everything +- **๐Ÿš€ One Command**: `./scripts/build.sh sim` builds and launches simulator - **๐Ÿงช Quality Assurance**: Tests run automatically before builds - **๐Ÿ”ง Multiple Targets**: Build for simulation, hardware, or both +- **๐ŸŽฎ Simulator Integration**: Automatic SimulIDE launch with firmware loading - **๐Ÿ“ฑ Cross-Platform**: Works on macOS, Linux, and Windows - **๐ŸŽจ Code Quality**: Automatic formatting and style checking - **๐Ÿ“Š Status Monitoring**: Easy to see what's working and what needs attention ### **Simulation** (Test Before You Test!) -The project includes SimulIDE simulation files: -- Open `wiring/rocker_launcher_controls.sim1` in SimulIDE -- The firmware will automatically load from the build output +The project includes SimulIDE simulation files with **automatic launch**: +- **One command**: `./scripts/build.sh sim` builds and launches SimulIDE +- **Auto-loading**: Firmware automatically loads from the build output +- **Wiring files**: Use `wiring/rocker_launcher_controls.sim1` for testing +- **Fast iteration**: Make changes, re-run script, test immediately - Test all functionality before building hardware (because debugging with real rockets is expensive!) ## ๐ŸŽจ **3D Printing & Assembly** @@ -257,7 +255,7 @@ The project includes a comprehensive test suite: - **๐Ÿ” 1 test under investigation**: Startup transition logic - **๐Ÿงช Test framework**: Unity-based unit testing with mock hardware -**Run tests**: `make test` from the `code/RocketLauncher/` directory +**Run tests**: `./scripts/build.sh test` from the `code/RocketLauncher/` directory ### **Project Structure** ``` @@ -322,11 +320,12 @@ We welcome contributions to improve the rocket launch controller! Areas for enha 1. Fork the repository 2. Create a feature branch 3. Make your changes -4. **Run tests**: `make test` (must pass) -5. **Build everything**: `make` (tests + builds) -6. **Format code**: `make format` (maintains style) -7. Test thoroughly (simulation + hardware) -8. Submit a pull request +4. **Run tests**: `./scripts/build.sh test` (must pass) +5. **Test in simulator**: `./scripts/build.sh sim` (verify functionality) +6. **Build everything**: `./scripts/build.sh` (tests + builds) +7. **Format code**: `./scripts/build.sh format` (maintains style) +8. Test thoroughly (simulation + hardware) +9. Submit a pull request **Testing Requirements**: All new features must include unit tests. The test suite must pass before merging. diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000..198fb48 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,312 @@ +# ๐Ÿš€ Luke's Rocket Launcher - Release Management Guide + +## ๐Ÿ“‹ Quick Reference + +### **Branch Types & Naming** +- `main` - Production-ready code, always deployable +- `develop` - Integration branch for features +- `feature/*` - New features (from `develop`) +- `bugfix/*` - Bug fixes (from `main`) +- `release/*` - Release preparation (from `develop`) +- `hotfix/*` - Urgent fixes (from `main`) + +### **Release Commands** +```bash +# Start a new release +./scripts/release.sh 0.1.0 start + +# Finish a release (creates tag, merges to main/develop) +./scripts/release.sh 0.1.0 finish + +# Create a new branch +./scripts/create-branch.sh feature new-feature-name +``` + +--- + +## ๐ŸŒฟ Git Branching Model + +### **Main Branches** +- **`main`** - Always contains production-ready code +- **`develop`** - Integration branch for upcoming releases + +### **Supporting Branches** +- **`feature/*`** - New features (branch from `develop`, merge back to `develop`) +- **`bugfix/*`** - Bug fixes (branch from `main`, merge back to `main`) +- **`release/*`** - Release preparation (branch from `develop`, merge to both `main` and `develop`) +- **`hotfix/*`** - Critical fixes (branch from `main`, merge to both `main` and `develop`) + +--- + +## ๐Ÿš€ Release Process + +### **1. Start a Release** +```bash +# Create release branch from develop +./scripts/release.sh 0.1.0 start + +# This will: +# - Switch to develop branch +# - Create release/0.1.0 branch +# - Push to remote +``` + +### **2. Prepare the Release** +- Update version numbers in code +- Update CHANGELOG.md +- Update documentation +- Test thoroughly + +### **3. Finish the Release** +```bash +# Complete the release process +./scripts/release.sh 0.1.0 finish + +# This will: +# - Merge release branch to main +# - Create and push tag v0.1.0 +# - Merge release branch to develop +# - Clean up release branch +# - Trigger automated workflow +``` + +--- + +## โšก Automated Pipeline + +### **What Happens Automatically** +1. **Tag Push** triggers GitHub Actions workflow +2. **Workflow Builds** firmware (hardware + simulation) +3. **Workflow Creates** GitHub release +4. **Workflow Uploads** assets to release +5. **Workflow Publishes** to GitHub Packages + +### **No Manual Steps Needed** +- โŒ Don't manually create GitHub releases +- โŒ Don't manually upload assets +- โœ… Just run the release script +- โœ… Let the workflow handle everything else + +--- + +## ๐Ÿ”ง Branch Management + +### **Create New Branches** +```bash +# Feature branch (from develop) +./scripts/create-branch.sh feature new-feature-name + +# Bugfix branch (from main) +./scripts/create-branch.sh bugfix bug-description + +# Hotfix branch (from main) +./scripts/create-branch.sh hotfix urgent-fix-description +``` + +### **Branch Protection Rules** +- **`main`** - Requires PR, no direct pushes +- **`develop`** - Requires PR, no direct pushes +- **Feature branches** - Can be pushed directly + +--- + +## ๐Ÿ“ Pull Request Workflow + +### **1. Create PR** +```bash +# From feature branch to develop +gh pr create --base develop --head feature/new-feature + +# From develop to main (for releases) +gh pr create --base main --head develop +``` + +### **2. Review & Merge** +- Self-review is allowed (you're the only person) +- Merge when ready +- Delete feature branch after merge + +--- + +## ๐Ÿท๏ธ Version Management + +### **Semantic Versioning** +- **Major.Minor.Patch** (e.g., 1.2.3) +- **Major** - Breaking changes +- **Minor** - New features, backward compatible +- **Patch** - Bug fixes, backward compatible + +### **Pre-releases** +- Use for development/testing versions +- Example: 0.1.0 (pre-release) +- Mark as pre-release in GitHub + +--- + +## ๐Ÿšจ Troubleshooting + +### **Common Issues** + +#### **"already_exists" Error** +- **Cause**: Manual GitHub release conflicts with workflow +- **Solution**: Don't manually create releases, let workflow handle it + +#### **Workflow Not Running** +- **Cause**: Branch protection rules +- **Solution**: Create PR and merge to main/develop + +#### **Asset Upload Failures** +- **Cause**: Missing upload_url +- **Solution**: Ensure workflow creates release (don't skip creation) + +### **Reset Release** +```bash +# Delete local tag +git tag -d v0.1.0 + +# Delete remote tag +git push origin --delete v0.1.0 + +# Delete GitHub release manually on GitHub +# Start over with release script +``` + +--- + +## ๐Ÿ“š File Structure + +``` +Lukes-Rocket-Launcher/ +โ”œโ”€โ”€ .github/ +โ”‚ โ”œโ”€โ”€ workflows/c-cpp.yml # Main CI/CD workflow +โ”‚ โ”œโ”€โ”€ CODEOWNERS # Code ownership rules +โ”‚ โ””โ”€โ”€ pull_request_template.md # PR template +โ”œโ”€โ”€ scripts/ +โ”‚ โ”œโ”€โ”€ release.sh # Release management +โ”‚ โ”œโ”€โ”€ create-branch.sh # Branch creation +โ”‚ โ”œโ”€โ”€ setup-branch-protection.sh # Branch protection setup +โ”‚ โ”œโ”€โ”€ dev-sim.sh # Development simulator launcher +โ”‚ โ””โ”€โ”€ sim # Quick simulator alias +โ”œโ”€โ”€ code/RocketLauncher/ # Main firmware code +โ”œโ”€โ”€ wiring/ # SimulIDE wiring files +โ””โ”€โ”€ RELEASE.md # This file +``` + +## ๐Ÿ–ฅ๏ธ Development Environment + +### **Local Development Tools** +- **PlatformIO** - Arduino framework and build system +- **SimulIDE** - Arduino simulator for testing +- **CMake** - IDE integration and native testing +- **Unity** - Unit testing framework + +### **Quick Development Commands** +```bash +# Launch simulator (builds + opens SimulIDE) +./scripts/sim + +# Clean rebuild +./scripts/sim --clean + +# Run tests +cd code/RocketLauncher && pio test -e native + +# Build hardware firmware +cd code/RocketLauncher && pio run -e uno_hw +``` + +--- + +## ๐ŸŽฏ Best Practices + +### **Do's** +- โœ… Use semantic versioning +- โœ… Test before releasing +- โœ… Update documentation +- โœ… Let automation handle releases +- โœ… Use descriptive branch names + +### **Don'ts** +- โŒ Don't manually create GitHub releases +- โŒ Don't push directly to main/develop +- โŒ Don't skip testing +- โŒ Don't forget to update version numbers + +--- + +## ๐Ÿ”„ Daily Workflow + +### **Normal Development** +1. Create feature branch: `./scripts/create-branch.sh feature new-feature` +2. Make changes and commit +3. **Test locally**: `./scripts/sim` (builds and launches simulator) +4. Push and create PR to develop +5. Merge when ready + +### **Local Development Cycle** +```bash +# Quick simulator launch (builds + launches SimulIDE) +./scripts/sim + +# Force clean rebuild +./scripts/sim --clean + +# Run unit tests +cd code/RocketLauncher && pio test -e native + +# Build hardware firmware +cd code/RocketLauncher && pio run -e uno_hw +``` + +### **Release Day** +1. Start release: `./scripts/release.sh 1.0.0 start` +2. Prepare release (version, docs, testing) +3. Finish release: `./scripts/release.sh 1.0.0 finish` +4. Wait for automation to complete +5. Deploy and announce + +--- + +## ๐Ÿ“ž Quick Commands Reference + +```bash +# Branch Management +./scripts/create-branch.sh feature new-feature +./scripts/create-branch.sh bugfix bug-description +./scripts/create-branch.sh hotfix urgent-fix + +# Release Management +./scripts/release.sh 1.0.0 start +./scripts/release.sh 1.0.0 finish + +# Git Operations +git checkout develop +git pull origin develop +git checkout main +git pull origin main + +# Workflow Monitoring +gh run list --limit 5 +gh run view +``` + +--- + +## ๐ŸŽ‰ Success Indicators + +### **Release Completed Successfully When:** +- โœ… All workflow jobs show green checkmarks +- โœ… GitHub release exists with assets +- โœ… Firmware files are uploaded +- โœ… No "already_exists" errors +- โœ… Asset uploads complete + +### **If Something Goes Wrong:** +1. Check workflow logs: `gh run view ` +2. Look for error messages +3. Check if release already exists on GitHub +4. Reset and try again if needed + +--- + +*This guide covers the complete release pipeline. When in doubt, run the scripts and let automation handle the complexity! ๐Ÿš€* diff --git a/code/RocketLauncher/scripts/build.sh b/code/RocketLauncher/scripts/build.sh index 8d1c70c..4a5ae06 100755 --- a/code/RocketLauncher/scripts/build.sh +++ b/code/RocketLauncher/scripts/build.sh @@ -51,6 +51,7 @@ show_help() { echo " build.sh firmware-sim # Build simulation firmware" echo " build.sh firmware-hw # Build hardware firmware" echo " build.sh all-firmware # Build both firmwares" + echo " build.sh sim # Build and launch simulator" echo " build.sh upload # Upload to Arduino" echo " build.sh monitor # Start serial monitor" echo " build.sh pio-clean # Clean PlatformIO files" @@ -64,6 +65,7 @@ show_help() { echo -e "${BLUE}Examples:${NC}" echo " ./scripts/build.sh # Full build" echo " ./scripts/build.sh firmware-sim # Build simulation firmware" + echo " ./scripts/build.sh sim # Build and launch simulator" echo " ./scripts/build.sh --preset release # Release build" } @@ -220,6 +222,115 @@ format_code() { fi } +# Function to build and launch simulator +launch_simulator() { + print_status "Building and launching simulator..." + + # Check if PlatformIO is available + if ! command -v pio &> /dev/null; then + print_error "PlatformIO not found. Cannot build simulator firmware." + print_info "Install with: pip install platformio" + exit 1 + fi + + # Build simulation firmware + print_info "Building simulation firmware..." + pio run -e simulide + + if [ $? -ne 0 ]; then + print_error "Failed to build simulation firmware" + exit 1 + fi + + print_status "Simulation firmware built successfully" + + # Check if firmware was created and copy to expected location + BUILD_FIRMWARE_PATH=".pio/build/simulide/firmware.hex" + EXPECTED_FIRMWARE_PATH="out/simulide/firmware.hex" + + if [[ ! -f "$BUILD_FIRMWARE_PATH" ]]; then + print_error "Firmware file not found at build path: $BUILD_FIRMWARE_PATH" + exit 1 + fi + + # Create output directory and copy firmware (same as PlatformIO upload_command) + print_info "Copying firmware to expected location..." + mkdir -p "out/simulide" + cp "$BUILD_FIRMWARE_PATH" "$EXPECTED_FIRMWARE_PATH" + + if [[ ! -f "$EXPECTED_FIRMWARE_PATH" ]]; then + print_error "Failed to copy firmware to expected location" + exit 1 + fi + + print_status "Firmware ready at: $EXPECTED_FIRMWARE_PATH" + + # Check if SimulIDE is installed and launch it + SIMULIDE_PATH="" + if [[ "$OSTYPE" == "darwin"* ]]; then + # macOS + if [[ -d "/Applications/simulide.app" ]]; then + SIMULIDE_PATH="/Applications/simulide.app/Contents/MacOS/simulide" + elif [[ -d "$HOME/Applications/simulide.app" ]]; then + SIMULIDE_PATH="$HOME/Applications/simulide.app/Contents/MacOS/simulide" + fi + elif [[ "$OSTYPE" == "linux-gnu"* ]]; then + # Linux + if command -v simulide &> /dev/null; then + SIMULIDE_PATH="simulide" + fi + elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then + # Windows + if command -v simulide.exe &> /dev/null; then + SIMULIDE_PATH="simulide.exe" + fi + fi + + if [[ -n "$SIMULIDE_PATH" ]]; then + print_status "Launching SimulIDE..." + + # Choose the wiring file to use + WIRING_FILE="../../wiring/rocker_launcher_controls.sim1" + if [[ ! -f "$WIRING_FILE" ]]; then + print_warning "Default wiring file not found, looking for alternatives..." + + # Find any .sim1 file + ALTERNATIVE_WIRING=$(find "../../wiring" -name "*.sim1" | head -1) + if [[ -n "$ALTERNATIVE_WIRING" ]]; then + WIRING_FILE="$ALTERNATIVE_WIRING" + print_info "Using alternative wiring file: $WIRING_FILE" + else + print_warning "No wiring files found, launching SimulIDE without wiring file" + WIRING_FILE="" + fi + fi + + if [[ -n "$WIRING_FILE" ]]; then + print_info "Loading wiring file: $WIRING_FILE" + "$SIMULIDE_PATH" "$WIRING_FILE" & + else + print_info "Launching SimulIDE without wiring file..." + "$SIMULIDE_PATH" & + fi + + print_status "SimulIDE launched successfully!" + print_info "๐Ÿ’ก Development Tips:" + print_info " โ€ข The firmware will auto-load in SimulIDE" + print_info " โ€ข Make changes to your code and re-run: ./scripts/build.sh sim" + print_info " โ€ข Check SimulIDE console for any runtime errors" + else + print_warning "SimulIDE not found - firmware built but not launched" + print_info "๐Ÿ“‹ Manual Launch Instructions:" + print_info "1. Open SimulIDE manually" + print_info "2. Load the wiring file: ../../wiring/rocker_launcher_controls.sim1" + print_info "3. The firmware will auto-load from: $EXPECTED_FIRMWARE_PATH" + print_info "" + print_info "Install SimulIDE from: https://www.simulide.com/" + fi + + print_status "Simulator setup complete!" +} + # Function to show status show_status() { print_status "Project Status" @@ -296,6 +407,9 @@ main() { check_dependencies build_target "all_firmware" "Building both firmwares" ;; + "sim") + launch_simulator + ;; "upload") check_dependencies build_target "upload" "Building and uploading firmware"