Skip to content

Commit 0c98e04

Browse files
committed
refactor(ci): clean up unused variables and enhance debugging in CI workflow
1 parent fccdd8e commit 0c98e04

File tree

3 files changed

+143
-34
lines changed

3 files changed

+143
-34
lines changed

.github/scripts/docs_build_examples.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import argparse
1010
from argparse import RawDescriptionHelpFormatter
11-
from esp_docs.generic_extensions.docs_embed.tool.wokwi_tool import DiagramSync
11+
# from esp_docs.generic_extensions.docs_embed.tool.wokwi_tool import DiagramSync
1212
import json
1313
import os
1414
import shutil
@@ -241,20 +241,20 @@ def build_example_for_target(sketch_dir, target, relative_path, args):
241241
ci_json = Path(sketch_dir) / 'ci.json'
242242
if ci_json.exists():
243243
shutil.copy(ci_json, output_dir / 'ci.json')
244-
if GENERATE_DIAGRAMS:
245-
print(f"Generating diagram for {relative_path} ({target})...")
246-
try:
247-
sync = DiagramSync(output_dir)
248-
sync.generate_diagram_from_ci(target)
249-
except Exception as e:
250-
print(f"WARNING: Failed to generate diagram for {relative_path} ({target}): {e}")
251-
if GENERATE_LAUNCHPAD_CONFIG:
252-
print(f"Generating LaunchPad config for {relative_path} ({target})...")
253-
try:
254-
sync = DiagramSync(output_dir)
255-
sync.generate_launchpad_config(DOCS_DEPLOY_URL_BASE, REPO_URL_PREFIX)
256-
except Exception as e:
257-
print(f"WARNING: Failed to generate LaunchPad config for {relative_path} ({target}): {e}")
244+
# if GENERATE_DIAGRAMS:
245+
# print(f"Generating diagram for {relative_path} ({target})...")
246+
# try:
247+
# sync = DiagramSync(output_dir)
248+
# sync.generate_diagram_from_ci(target)
249+
# except Exception as e:
250+
# print(f"WARNING: Failed to generate diagram for {relative_path} ({target}): {e}")
251+
# if GENERATE_LAUNCHPAD_CONFIG:
252+
# print(f"Generating LaunchPad config for {relative_path} ({target})...")
253+
# try:
254+
# sync = DiagramSync(output_dir)
255+
# sync.generate_launchpad_config(DOCS_DEPLOY_URL_BASE, REPO_URL_PREFIX)
256+
# except Exception as e:
257+
# print(f"WARNING: Failed to generate LaunchPad config for {relative_path} ({target}): {e}")
258258
else:
259259
print(f"ERROR: Failed to build {relative_path} for {target}")
260260
return False

.github/scripts/on-push.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
set -e
44

5-
export ARDUINO_BUILD_DIR="$HOME/.arduino/build.tmp"
6-
75
function build {
86
local target=$1
97
local chunk_index=$2

.github/workflows/docs_build.yml

Lines changed: 128 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ jobs:
4242
key: compiled-binaries-consolidated-${{ github.sha }}
4343
restore-keys: |
4444
compiled-binaries-consolidated-
45-
compiled-binaries-Linux-${{ github.sha }}-
46-
compiled-binaries-Linux-
4745
path: compiled_binaries
4846
lookup-only: false
4947

@@ -55,32 +53,145 @@ jobs:
5553
path: compiled_binaries
5654
continue-on-error: true
5755

58-
- name: Copy cached binaries to local directory
56+
- name: Debug - List cached binaries structure
5957
run: |
58+
echo "=========================================="
59+
echo "Debugging cached binaries structure"
60+
echo "=========================================="
6061
if [ -d "compiled_binaries" ]; then
61-
echo "Found cached binaries, copying to local workspace..."
62-
mkdir -p local_binaries
63-
cp -r compiled_binaries/* local_binaries/ || true
64-
echo "Available binaries:"
65-
find local_binaries -type f -name "*.bin" -o -name "*.elf" | head -20
66-
echo "Total binary files found: $(find local_binaries -type f \( -name "*.bin" -o -name "*.elf" \) | wc -l)"
67-
68-
echo "Contents of compiled_binaries directory:"
69-
find compiled_binaries -type f | head -20
62+
echo "✓ compiled_binaries directory exists"
63+
echo ""
64+
echo "Directory tree (first 50 entries):"
65+
find compiled_binaries -type f | head -50 | sort
66+
echo ""
67+
echo "Binary files (.bin):"
68+
find compiled_binaries -type f -name "*.bin" | head -30
69+
echo ""
70+
echo "ELF files:"
71+
find compiled_binaries -type f -name "*.elf" | head -30
72+
echo ""
73+
echo "Total binary files: $(find compiled_binaries -type f -name "*.bin" | wc -l)"
74+
echo "Total ELF files: $(find compiled_binaries -type f -name "*.elf" | wc -l)"
75+
echo ""
76+
echo "Sample directory structure:"
77+
ls -la compiled_binaries/ || true
7078
else
71-
echo "No cached binaries found, will build fresh"
79+
echo "✗ compiled_binaries directory NOT found"
80+
echo "WARNING: No cached binaries available!"
7281
fi
82+
echo "=========================================="
7383
74-
- name: Build Examples
84+
- name: Copy cached binaries to docs/_static/binaries/
7585
run: |
76-
source .github/scripts/install-arduino-cli.sh
77-
source .github/scripts/install-arduino-core-esp32.sh
78-
python3 .github/scripts/docs_build_examples.py -ai $ARDUINO_IDE_PATH -au $ARDUINO_USR_PATH -d
86+
echo "Copying cached binaries to docs/_static/binaries/"
87+
mkdir -p docs/_static/binaries
88+
89+
if [ ! -d "compiled_binaries" ]; then
90+
echo "ERROR: No compiled_binaries directory found!"
91+
echo "Cannot proceed without binaries. Exiting."
92+
exit 1
93+
fi
94+
95+
# Find all .bin files in compiled_binaries
96+
echo "Processing binary files..."
97+
bin_count=0
98+
skip_count=0
99+
100+
# Binaries are stored in structure like:
101+
# compiled_binaries/{home}/.arduino/tests/{target}/{SketchName}/build.tmp/{SketchName}.ino.bin
102+
# We need to:
103+
# 1. Extract sketch name and target from path
104+
# 2. Find the sketch in libraries/ directory
105+
# 3. Copy to docs/_static/binaries/libraries/{LibraryName}/examples/{SketchName}/{target}/
106+
107+
find compiled_binaries -type f -name "*.bin" | while read -r bin_file; do
108+
echo "Processing: $bin_file"
109+
110+
# Extract the binary filename (e.g., WiFiClientSecure.ino.bin)
111+
bin_name=$(basename "$bin_file")
112+
113+
# Extract sketch name (remove .ino.bin or .bin extension)
114+
sketch_name="${bin_name%.ino.bin}"
115+
if [ "$sketch_name" == "$bin_name" ]; then
116+
sketch_name="${bin_name%.bin}"
117+
fi
118+
119+
# Extract target from path (esp32, esp32s2, esp32s3, esp32c3, esp32c6, esp32h2, esp32p4, esp32c5)
120+
if [[ "$bin_file" =~ /(esp32[a-z0-9]*)/ ]]; then
121+
target="${BASH_REMATCH[1]}"
122+
else
123+
echo " ⚠ Could not determine target from path: $bin_file"
124+
skip_count=$((skip_count + 1))
125+
continue
126+
fi
127+
128+
# Search for the sketch in libraries directory
129+
sketch_ino_file=$(find libraries -type f -name "${sketch_name}.ino" 2>/dev/null | head -1)
130+
131+
if [ -z "$sketch_ino_file" ]; then
132+
echo " ⚠ Could not find sketch '${sketch_name}.ino' in libraries/"
133+
skip_count=$((skip_count + 1))
134+
continue
135+
fi
136+
137+
# Extract the relative path from libraries/
138+
# e.g., libraries/NetworkClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino
139+
# becomes: NetworkClientSecure/examples/WiFiClientSecure
140+
sketch_dir=$(dirname "$sketch_ino_file")
141+
relative_path="${sketch_dir#libraries/}"
142+
143+
echo " ✓ Found sketch at: $sketch_ino_file"
144+
echo " ✓ Target: $target"
145+
echo " ✓ Relative path: $relative_path"
146+
147+
# Create output directory
148+
output_dir="docs/_static/binaries/libraries/${relative_path}/${target}"
149+
mkdir -p "$output_dir"
150+
151+
# Copy the binary
152+
cp "$bin_file" "$output_dir/"
153+
echo " → Copied to: $output_dir/$bin_name"
154+
bin_count=$((bin_count + 1))
155+
done
156+
157+
echo ""
158+
echo "=========================================="
159+
echo "Binary copy completed!"
160+
echo " Binaries copied: $bin_count"
161+
echo " Binaries skipped: $skip_count"
162+
echo "=========================================="
163+
echo ""
164+
echo "Final structure in docs/_static/binaries/:"
165+
find docs/_static/binaries -type f -name "*.bin" | head -30
166+
echo ""
167+
echo "Total binaries in docs/_static/binaries/: $(find docs/_static/binaries -type f -name "*.bin" | wc -l)"
79168
80169
- name: Cleanup Binaries
81170
run: |
82171
python3 .github/scripts/docs_build_examples.py -c
83172
173+
- name: Debug - Final binaries structure after cleanup
174+
run: |
175+
echo "=========================================="
176+
echo "Final structure in docs/_static/binaries/ (after cleanup)"
177+
echo "=========================================="
178+
if [ -d "docs/_static/binaries" ]; then
179+
echo "Directory tree:"
180+
find docs/_static/binaries -type f | sort
181+
echo ""
182+
echo "Files by type:"
183+
echo " .bin files: $(find docs/_static/binaries -type f -name "*.bin" | wc -l)"
184+
echo " .elf files: $(find docs/_static/binaries -type f -name "*.elf" | wc -l)"
185+
echo " .json files: $(find docs/_static/binaries -type f -name "*.json" | wc -l)"
186+
echo " .toml files: $(find docs/_static/binaries -type f -name "*.toml" | wc -l)"
187+
echo ""
188+
echo "Example of final structure (first 20 files):"
189+
find docs/_static/binaries -type f | head -20
190+
else
191+
echo "WARNING: docs/_static/binaries/ directory not found!"
192+
fi
193+
echo "=========================================="
194+
84195
- name: Build
85196
run: |
86197
sudo apt update

0 commit comments

Comments
 (0)