|
| 1 | +# GitHub Actions Workflow Usage |
| 2 | + |
| 3 | +## 📋 Overview |
| 4 | + |
| 5 | +This repository contains a GitHub Actions workflow for automated KiCad hardware builds and documentation generation. |
| 6 | + |
| 7 | +## 🔧 Workflow: `pr-check.yml` |
| 8 | + |
| 9 | +### What it does: |
| 10 | +- **Hardware Build & Export**: Exports KiCad files to production-ready formats |
| 11 | +- **Documentation Build**: Validates and processes documentation files |
| 12 | +- **PR Summary**: Generates automated PR comments with build results |
| 13 | + |
| 14 | +### Jobs: |
| 15 | + |
| 16 | +#### 1. 🔧 Hardware Build & Export |
| 17 | +- Validates KiCad project files |
| 18 | +- Exports Gerber files for PCB manufacturing |
| 19 | +- Generates drill files |
| 20 | +- Creates PDF documentation (schematics and PCB layouts) |
| 21 | +- Exports SVG assembly diagrams |
| 22 | +- Generates 3D STEP models |
| 23 | +- Creates production summary |
| 24 | +- Uploads all artifacts |
| 25 | + |
| 26 | +#### 2. 📚 Documentation Build |
| 27 | +- Validates Markdown documentation |
| 28 | +- Builds AsciiDoc files (if present) |
| 29 | +- Generates LaTeX PDFs (if present) |
| 30 | +- Checks for broken links |
| 31 | +- Creates documentation statistics |
| 32 | +- Uploads documentation artifacts |
| 33 | + |
| 34 | +#### 3. 📋 PR Summary (PR only) |
| 35 | +- Downloads artifacts from previous jobs |
| 36 | +- Generates comprehensive PR summary |
| 37 | +- Comments results on Pull Request |
| 38 | + |
| 39 | +## 🚀 Usage |
| 40 | + |
| 41 | +### GitHub Actions (Automatic) |
| 42 | +The workflow runs automatically on: |
| 43 | +- Pull Requests to `main` or `develop` branches |
| 44 | +- Pushes to `main` branch |
| 45 | +- Changes to: |
| 46 | + - `KM217-WiFi/**` (hardware files) |
| 47 | + - `DOC/**` (documentation) |
| 48 | + - `.github/workflows/pr-check.yml` (workflow itself) |
| 49 | + |
| 50 | +### Local Testing with `act` |
| 51 | + |
| 52 | +#### Prerequisites |
| 53 | +```bash |
| 54 | +# Install act (GitHub Actions runner) |
| 55 | +# macOS |
| 56 | +brew install act |
| 57 | + |
| 58 | +# Linux |
| 59 | +curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash |
| 60 | + |
| 61 | +# Or download from: https://github.com/nektos/act/releases |
| 62 | +``` |
| 63 | + |
| 64 | +#### Run Local Tests |
| 65 | +```bash |
| 66 | +# Test hardware build only |
| 67 | +act -j hardware-build --artifact-server-path /tmp/artifacts |
| 68 | + |
| 69 | +# Test documentation build only |
| 70 | +act -j documentation-build --artifact-server-path /tmp/artifacts |
| 71 | + |
| 72 | +# Test complete workflow (excluding PR comments) |
| 73 | +act --artifact-server-path /tmp/artifacts |
| 74 | + |
| 75 | +# Use specific Docker platform (if needed) |
| 76 | +act -j hardware-build --artifact-server-path /tmp/artifacts --container-architecture linux/amd64 |
| 77 | +``` |
| 78 | + |
| 79 | +#### Local Artifacts |
| 80 | +When using `act`, artifacts are stored locally: |
| 81 | +- **Location**: `/tmp/artifacts/[run-id]/[artifact-name]/` |
| 82 | +- **Hardware exports**: `/tmp/artifacts/*/km217-wifi-hardware-exports/` |
| 83 | +- **Documentation**: `/tmp/artifacts/*/km217-wifi-documentation/` |
| 84 | + |
| 85 | +#### Extract Artifacts from Container |
| 86 | +```bash |
| 87 | +# Copy artifacts from act container to host |
| 88 | +docker cp $(docker ps -lq):/tmp/artifacts/ ./local-artifacts/ |
| 89 | +``` |
| 90 | + |
| 91 | +## 📦 Generated Artifacts |
| 92 | + |
| 93 | +### Hardware Exports (`km217-wifi-hardware-exports`) |
| 94 | +- **Gerber Files**: `Export/Gerbers/` - PCB manufacturing files |
| 95 | +- **Drill Files**: `Export/Drill/` - Drill hole information |
| 96 | +- **PDFs**: `Export/PDF/` - Schematics and PCB layout documentation |
| 97 | +- **Images**: `Export/Images/` - SVG assembly diagrams |
| 98 | +- **3D Models**: `Export/3D/` - STEP files for 3D visualization |
| 99 | +- **Summary**: `Export/PRODUCTION_SUMMARY.md` - Complete file overview |
| 100 | + |
| 101 | +### Documentation (`km217-wifi-documentation`) |
| 102 | +- All files from `DOC/` directory |
| 103 | +- Generated HTML/PDF files (if applicable) |
| 104 | +- Documentation statistics |
| 105 | + |
| 106 | +## 🔧 Customization |
| 107 | + |
| 108 | +### Modify KiCad Export Settings |
| 109 | +Edit the workflow file `.github/workflows/pr-check.yml`: |
| 110 | + |
| 111 | +```yaml |
| 112 | +# Example: Add more PCB layers |
| 113 | +--layers "F.Cu,B.Cu,In1.Cu,F.Paste,B.Paste,F.Silkscreen,B.Silkscreen,F.Mask,B.Mask,Edge.Cuts" |
| 114 | + |
| 115 | +# Example: Change precision |
| 116 | +--precision 5 # or 6 |
| 117 | +``` |
| 118 | + |
| 119 | +### Add Custom Validation |
| 120 | +Add custom steps in the workflow: |
| 121 | + |
| 122 | +```yaml |
| 123 | +- name: 🔍 Custom Validation |
| 124 | + run: | |
| 125 | + echo "Running custom validation..." |
| 126 | + # Your custom validation logic here |
| 127 | +``` |
| 128 | +
|
| 129 | +## 🐛 Troubleshooting |
| 130 | +
|
| 131 | +### Common Issues |
| 132 | +
|
| 133 | +1. **Missing 3D Models**: The STEP export shows warnings about missing 3D models. This is normal and doesn't affect the PCB manufacturing files. |
| 134 | +
|
| 135 | +2. **ImageMagick not available**: PNG conversion is skipped. SVG files are still generated. |
| 136 | +
|
| 137 | +3. **act fails with permissions**: Make sure Docker is running and you have permissions: |
| 138 | + ```bash |
| 139 | + sudo usermod -aG docker $USER |
| 140 | + # Log out and back in |
| 141 | + ``` |
| 142 | + |
| 143 | +4. **Workflow fails on syntax**: Check bash syntax in workflow scripts, especially: |
| 144 | + - Array definitions |
| 145 | + - String substitutions |
| 146 | + - EOF delimiters |
| 147 | + |
| 148 | +### Debug Tips |
| 149 | + |
| 150 | +1. **Enable act debug mode**: |
| 151 | + ```bash |
| 152 | + act -j hardware-build --artifact-server-path /tmp/artifacts --verbose |
| 153 | + ``` |
| 154 | + |
| 155 | +2. **Check generated files locally**: |
| 156 | + ```bash |
| 157 | + ls -la /tmp/artifacts/*/km217-wifi-hardware-exports/ |
| 158 | + unzip -l /tmp/artifacts/*/km217-wifi-hardware-exports/*.zip |
| 159 | + ``` |
| 160 | + |
| 161 | +3. **Validate KiCad CLI commands manually**: |
| 162 | + ```bash |
| 163 | + # In KiCad project directory |
| 164 | + kicad-cli sch export pdf --help |
| 165 | + kicad-cli pcb export gerbers --help |
| 166 | + ``` |
| 167 | + |
| 168 | +## 📚 References |
| 169 | + |
| 170 | +- [GitHub Actions Documentation](https://docs.github.com/en/actions) |
| 171 | +- [act - Local GitHub Actions](https://github.com/nektos/act) |
| 172 | +- [KiCad CLI Documentation](https://docs.kicad.org/master/en/cli/cli.html) |
| 173 | +- [KiCad Docker Image](https://github.com/the78mole/kicaddev-docker) |
0 commit comments