feat(ci): enhance documentation build workflow to collect ci.json fil… #44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Documentation Build and Deploy CI | |
| on: | |
| # # Wait for Compilation Tests workflow to complete (uses macOS binaries) | |
| # workflow_run: | |
| # workflows: ["Compilation Tests"] | |
| # types: | |
| # - completed | |
| # branches: | |
| # - master | |
| # - release/v2.x | |
| # - wokwi-embed-launchpad | |
| # Manual trigger for testing docs changes without waiting for compilation | |
| workflow_dispatch: | |
| # Also run on direct pushes to docs or workflow files (for testing) | |
| push: | |
| branches: | |
| - master | |
| - release/v2.x | |
| - wokwi-embed-launchpad | |
| paths: | |
| - "docs/**" | |
| - ".github/workflows/docs_build.yml" | |
| pull_request: | |
| paths: | |
| - "docs/**" | |
| - ".github/workflows/docs_build.yml" | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-docs: | |
| name: Build ESP-Docs | |
| runs-on: ubuntu-22.04 | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| submodules: true | |
| - uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.0.4 | |
| with: | |
| cache-dependency-path: docs/requirements.txt | |
| cache: "pip" | |
| python-version: "3.10" | |
| - name: Restore docs binaries from cache (macOS builds) | |
| id: cache-restore | |
| uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | |
| with: | |
| key: docs-binaries-macos-${{ github.run_id }} | |
| restore-keys: | | |
| docs-binaries-macos- | |
| path: docs_binaries | |
| lookup-only: false | |
| # - name: Download docs binaries artifact (fallback) | |
| # if: steps.cache-restore.outputs.cache-hit != 'true' | |
| # uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1 | |
| # with: | |
| # name: docs-binaries-macos | |
| # path: docs_binaries | |
| # continue-on-error: true | |
| - name: Debug - List cached binaries structure | |
| run: | | |
| echo "==========================================" | |
| echo "Debugging cached binaries structure (macOS builds)" | |
| echo "==========================================" | |
| if [ -d "docs_binaries" ]; then | |
| echo "✓ docs_binaries directory exists" | |
| echo "" | |
| echo "Directory tree (first 50 entries):" | |
| find docs_binaries -type f 2>/dev/null | head -50 | sort || true | |
| echo "" | |
| echo "Binary files (.bin):" | |
| find docs_binaries -type f -name "*.bin" 2>/dev/null | head -30 || true | |
| echo "" | |
| echo "ELF files:" | |
| find docs_binaries -type f -name "*.elf" 2>/dev/null | head -30 || true | |
| echo "" | |
| echo "Total binary files: $(find docs_binaries -type f -name "*.bin" 2>/dev/null | wc -l)" | |
| echo "Total ELF files: $(find docs_binaries -type f -name "*.elf" 2>/dev/null | wc -l)" | |
| echo "" | |
| echo "Sample directory structure:" | |
| ls -la docs_binaries/ || true | |
| else | |
| echo "✗ docs_binaries directory NOT found" | |
| echo "WARNING: No cached binaries available!" | |
| fi | |
| echo "==========================================" | |
| - name: Copy cached binaries to docs/_static/binaries/ | |
| run: | | |
| echo "Copying cached .merged.bin binaries to docs/_static/binaries/" | |
| mkdir -p docs/_static/binaries | |
| if [ ! -d "docs_binaries" ]; then | |
| echo "WARNING: No docs_binaries directory found!" | |
| echo "Continuing anyway - docs will build without binaries." | |
| exit 0 | |
| fi | |
| # Find only .merged.bin files in docs_binaries | |
| echo "Processing .merged.bin files from macOS builds..." | |
| # Binaries are stored in structure like: | |
| # docs_binaries/{target}/{SketchName}/build.tmp/{SketchName}.ino.merged.bin | |
| # We need to: | |
| # 1. Extract sketch name and target from path | |
| # 2. Find the sketch in libraries/ directory | |
| # 3. Copy .merged.bin to docs/_static/binaries/libraries/{LibraryName}/examples/{SketchName}/{target}/ | |
| bin_count=0 | |
| skip_count=0 | |
| while IFS= read -r bin_file; do | |
| echo "Processing: $bin_file" | |
| # Extract the binary filename (e.g., WiFiClientSecure.ino.merged.bin) | |
| bin_name=$(basename "$bin_file") | |
| # Extract sketch name (remove .ino.merged.bin extension) | |
| sketch_name="${bin_name%.ino.merged.bin}" | |
| # Extract target from path (esp32, esp32s2, esp32s3, esp32c3, esp32c6, esp32h2, esp32p4, esp32c5) | |
| if [[ "$bin_file" =~ /(esp32[a-z0-9]*)/ ]]; then | |
| target="${BASH_REMATCH[1]}" | |
| else | |
| echo " ⚠ Could not determine target from path: $bin_file" | |
| skip_count=$((skip_count + 1)) | |
| continue | |
| fi | |
| # Search for the sketch in libraries directory | |
| sketch_ino_file=$(find libraries -type f -name "${sketch_name}.ino" 2>/dev/null | head -1) | |
| if [ -z "$sketch_ino_file" ]; then | |
| echo " ⚠ Could not find sketch '${sketch_name}.ino' in libraries/" | |
| skip_count=$((skip_count + 1)) | |
| continue | |
| fi | |
| # Extract the relative path from libraries/ | |
| # e.g., libraries/NetworkClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino | |
| # becomes: NetworkClientSecure/examples/WiFiClientSecure | |
| sketch_dir=$(dirname "$sketch_ino_file") | |
| relative_path="${sketch_dir#libraries/}" | |
| echo " ✓ Found sketch at: $sketch_ino_file" | |
| echo " ✓ Target: $target" | |
| echo " ✓ Relative path: $relative_path" | |
| # Create output directory | |
| output_dir="docs/_static/binaries/libraries/${relative_path}/${target}" | |
| mkdir -p "$output_dir" | |
| # Copy the .merged.bin file | |
| cp "$bin_file" "$output_dir/" | |
| echo " → Copied to: $output_dir/$bin_name" | |
| bin_count=$((bin_count + 1)) | |
| # Also copy ci.json if it exists in the same directory | |
| ci_json_file=$(dirname "$bin_file")/ci.json | |
| if [ -f "$ci_json_file" ]; then | |
| cp "$ci_json_file" "$output_dir/" | |
| echo " → Copied ci.json to: $output_dir/ci.json" | |
| fi | |
| done < <(find docs_binaries -type f -name "*.merged.bin") | |
| echo "" | |
| echo "==========================================" | |
| echo ".merged.bin copy completed!" | |
| echo " .merged.bin files copied: $bin_count" | |
| echo " Files skipped: $skip_count" | |
| echo "==========================================" | |
| echo "" | |
| echo "Final structure in docs/_static/binaries/:" | |
| find docs/_static/binaries -type f -name "*.merged.bin" 2>/dev/null | head -30 || true | |
| echo "" | |
| echo "Total .merged.bin files in docs/_static/binaries/: $(find docs/_static/binaries -type f -name "*.merged.bin" 2>/dev/null | wc -l)" | |
| - name: Cleanup Binaries | |
| run: | | |
| python3 .github/scripts/docs_build_examples.py -c | |
| - name: Debug - Final binaries structure after cleanup | |
| run: | | |
| echo "==========================================" | |
| echo "Final structure in docs/_static/binaries/ (after cleanup)" | |
| echo "==========================================" | |
| if [ -d "docs/_static/binaries" ]; then | |
| echo "Directory tree:" | |
| find docs/_static/binaries -type f 2>/dev/null | sort || true | |
| echo "" | |
| echo "Files by type:" | |
| echo " .merged.bin files: $(find docs/_static/binaries -type f -name "*.merged.bin" 2>/dev/null | wc -l)" | |
| echo " .json files: $(find docs/_static/binaries -type f -name "*.json" 2>/dev/null | wc -l)" | |
| echo " .toml files: $(find docs/_static/binaries -type f -name "*.toml" 2>/dev/null | wc -l)" | |
| echo " diagram.json files: $(find docs/_static/binaries -type f -name "diagram*.json" 2>/dev/null | wc -l)" | |
| echo "" | |
| echo "Example of final structure (first 20 files):" | |
| find docs/_static/binaries -type f 2>/dev/null | head -20 || true | |
| else | |
| echo "WARNING: docs/_static/binaries/ directory not found!" | |
| fi | |
| echo "==========================================" | |
| - name: Build | |
| run: | | |
| sudo apt update | |
| sudo apt install python3-pip python3-setuptools | |
| # GitHub CI installs pip3 and setuptools outside the path. | |
| # Update the path to include them and run. | |
| cd ./docs | |
| PATH=/home/runner/.local/bin:$PATH pip3 install -r requirements.txt --prefer-binary | |
| PATH=/home/runner/.local/bin:$PATH SPHINXOPTS="-W" build-docs -l en | |
| - name: Archive Docs | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: docs | |
| path: docs |