Skip to content

Commit 961366d

Browse files
committed
Trying to Fix CI
1 parent a259a57 commit 961366d

File tree

3 files changed

+145
-12
lines changed

3 files changed

+145
-12
lines changed

.github/workflows/ci.yaml

Lines changed: 77 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,83 @@ jobs:
1414
- name: Lint
1515
run: |
1616
make fmt
17+
1718
build:
1819
runs-on: ubuntu-latest
20+
1921
steps:
20-
- uses: actions/checkout@v4
21-
- name: Build
22-
run: |
23-
make build
24-
- name: Archive
25-
uses: actions/upload-artifact@v4
26-
with:
27-
name: artifacts
28-
path: |
29-
build-artifacts/zephyr.uf2
30-
build-artifacts/zephyr/fprime-zephyr-deployment/dict/ReferenceDeploymentTopologyDictionary.json
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
submodules: recursive
26+
fetch-depth: 0
27+
28+
- name: Install system dependencies
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install -y \
32+
git cmake ninja-build gperf ccache dfu-util \
33+
device-tree-compiler wget xz-utils file make gcc \
34+
gcc-multilib g++-multilib libsdl2-dev libmagic1
35+
36+
- name: Set up Python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: '3.11'
40+
cache: 'pip'
41+
42+
- name: Cache Zephyr workspace
43+
id: cache-zephyr
44+
uses: actions/cache@v4
45+
with:
46+
path: |
47+
lib/zephyr-workspace
48+
~/zephyr-sdk-0.17.2
49+
key: zephyr-minimal-${{ hashFiles('west.yml') }}-${{ runner.os }}
50+
restore-keys: |
51+
zephyr-minimal-${{ hashFiles('west.yml') }}-
52+
zephyr-minimal-
53+
54+
- name: Setup minimal Zephyr environment
55+
run: |
56+
make zephyr-setup
57+
env:
58+
# Speed up pip installs
59+
PIP_DISABLE_PIP_VERSION_CHECK: 1
60+
PIP_NO_COMPILE: 1
61+
62+
- name: Display setup statistics
63+
run: |
64+
echo "=== Zephyr Setup Statistics ==="
65+
echo "Workspace size: $(du -sh lib/zephyr-workspace 2>/dev/null || echo 'N/A')"
66+
echo "SDK size: $(du -sh ~/zephyr-sdk-0.17.2 2>/dev/null || echo 'N/A')"
67+
echo "Modules installed:"
68+
west list 2>/dev/null || echo "West not initialized"
69+
70+
- name: Build for PROVES Flight Control Board v5c
71+
run: |
72+
make build
73+
74+
- name: Upload build artifacts
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: firmware-v5c
78+
path: |
79+
build-artifacts/zephyr.uf2
80+
build-artifacts/zephyr.elf
81+
build-artifacts/zephyr.hex
82+
build-artifacts/zephyr.bin
83+
retention-days: 30
84+
85+
- name: Display build statistics
86+
if: success()
87+
run: |
88+
echo "=== Build Statistics ==="
89+
if [ -f build-artifacts/zephyr.uf2 ]; then
90+
echo "Firmware size: $(ls -lh build-artifacts/zephyr.uf2 | awk '{print $5}')"
91+
fi
92+
if [ -f build-fprime-automatic-zephyr/zephyr/zephyr.stat ]; then
93+
echo ""
94+
echo "Memory usage:"
95+
cat build-fprime-automatic-zephyr/zephyr/zephyr.stat || true
96+
fi

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ zephyr-setup: fprime-venv ## Set up Zephyr environment (minimal RP2040/RP2350 on
2727
echo "Setting up minimal Zephyr environment (RP2040/RP2350 only)..."; \
2828
echo " - Using minimal module set (~80% disk space reduction)"; \
2929
echo " - Installing ARM toolchain only (~92% SDK reduction)"; \
30+
if [ ! -f .west/config ] && [ ! -f ../.west/config ]; then \
31+
echo " - Initializing West workspace..."; \
32+
$(UVX) west init -l .; \
33+
fi && \
3034
$(UVX) west update && \
3135
$(UVX) west zephyr-export && \
3236
$(UV) run west packages pip --install && \

docs/additional-resources/west-manifest-setup.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ Use the convenience script that handles everything:
2828
```
2929

3030
This script will:
31-
1. Initialize the West workspace
31+
1. Initialize the West workspace (if not already initialized)
3232
2. Download only the minimal modules
3333
3. Export the Zephyr CMake package
3434
4. Install only the ARM toolchain (~95 MB instead of ~1.2 GB)
3535

36+
**Note**: The script automatically detects if you're in a fresh clone (like in CI/CD) and initializes West workspace accordingly.
37+
3638
### Option B: Manual Setup
3739

3840
If you prefer to run the commands manually:
@@ -180,8 +182,69 @@ west list
180182
west build -b proves_flight_control_board_v5c FprimeZephyrReference/ReferenceDeployment
181183
```
182184

185+
## CI/CD Setup
186+
187+
The minimal setup works great in CI/CD environments like GitHub Actions. Here's an example workflow:
188+
189+
```yaml
190+
name: Build
191+
192+
on: [push, pull_request]
193+
194+
jobs:
195+
build:
196+
runs-on: ubuntu-latest
197+
steps:
198+
- uses: actions/checkout@v3
199+
with:
200+
submodules: recursive
201+
202+
- name: Setup Zephyr (Minimal)
203+
run: |
204+
make zephyr-setup
205+
206+
- name: Build
207+
run: |
208+
make build
209+
```
210+
211+
### Benefits in CI/CD
212+
- **Faster builds**: 3-7 min setup vs 40-60 min
213+
- **Lower costs**: Less compute time
214+
- **Better caching**: Smaller artifacts to cache
215+
- **Reliable**: Deterministic module versions
216+
217+
### Caching Strategy
218+
219+
For even faster CI/CD, cache the Zephyr workspace:
220+
221+
```yaml
222+
- name: Cache Zephyr Workspace
223+
uses: actions/cache@v3
224+
with:
225+
path: |
226+
lib/zephyr-workspace
227+
~/zephyr-sdk-0.17.2
228+
key: zephyr-${{ hashFiles('west.yml') }}
229+
230+
- name: Setup Zephyr (if cache miss)
231+
run: |
232+
if [ ! -d "lib/zephyr-workspace/modules" ]; then
233+
make zephyr-setup
234+
fi
235+
```
236+
183237
## Troubleshooting
184238

239+
### "no west workspace found" error in CI/CD
240+
241+
If you see this error:
242+
```
243+
FATAL ERROR: no west workspace found
244+
```
245+
246+
**Solution**: The Makefile now automatically runs `west init -l .` when needed. Make sure you're using the updated `Makefile` from this project.
247+
185248
### "Module not found" errors during build
186249

187250
If you encounter errors about missing modules during build, you may need to add that specific module to `west.yml`. Check the error message for the module name and add it following the pattern in the manifest.

0 commit comments

Comments
 (0)