Skip to content

fix: 修复 CI 工具链配置 #2

fix: 修复 CI 工具链配置

fix: 修复 CI 工具链配置 #2

Workflow file for this run

name: AstroBox ESP32-S3 Build
on:
push:
branches: [main, develop]
tags: ['v*']
pull_request:
branches: [main, develop]
workflow_dispatch:
inputs:
build_type:
description: 'Build type'
required: true
default: 'release'
type: choice
options:
- debug
- release
features:
description: 'Cargo features (comma-separated)'
required: false
default: 'sdcard,repo_net,mi_account,webui,plugin_runtime'
type: string
flash_size:
description: 'Flash size for image generation'
required: false
default: '16mb'
type: choice
options:
- 4mb
- 8mb
- 16mb
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
ESP_IDF_VERSION: "v5.3.3"
MCU: "esp32s3"
CARGO_TARGET: "xtensa-esp32s3-espidf"
ESPUP_INSTALL_DIR: "$HOME/esp"
jobs:
build:
name: Build (${{ matrix.build_type }}, ${{ matrix.features }})
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
build_type: [release]
features:
- "sdcard,repo_net,mi_account,webui,plugin_runtime"
- "sdcard,repo_net,mi_account,webui"
- "sdcard,repo_net,mi_account"
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
cmake ninja-build dfu-util \
python3 python3-pip python3-venv \
gcc-arm-none-eabi libudev-dev libssl-dev
- name: Install Rust toolchain
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install espup and esp-idf
run: |
cargo install espup
espup install esp32s3
espup toolchain install esp32s3
# Install the esp rust toolchain (provides xtensa target + ldproxy)
espup toolchain install esp32s3
cargo install espflash
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-registry-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-registry-${{ runner.os }}-
- name: Cache esp-idf
uses: actions/cache@v4
with:
path: ~/.espressif
key: esp-idf-${{ env.ESP_IDF_VERSION }}
restore-keys: |
esp-idf-
- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: cargo-build-${{ runner.os }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', '**/build.rs') }}
restore-keys: |
cargo-build-${{ runner.os }}-${{ matrix.features }}-
- name: Build firmware
env:
FEATURES: ${{ matrix.features }}
run: |
set -e
. $HOME/esp/esp-idf/export.sh 2>/dev/null || true
export ESP_IDF_VERSION="v5.3.3"
export MCU="esp32s3"
export CARGO_TARGET="xtensa-esp32s3-espidf"
FEATURES_CLEAN=$(echo "$FEATURES" | tr ' ' ',')
echo "============================================"
echo " Building AstroBox ESP32-S3 Firmware"
echo " Build type: ${{ matrix.build_type }}"
echo " Features: $FEATURES_CLEAN"
echo " Target: $CARGO_TARGET"
echo "============================================"
if [ "${{ matrix.build_type }}" = "release" ]; then
cargo build --release --features "$FEATURES_CLEAN"
else
cargo build --features "$FEATURES_CLEAN"
fi
echo "Build completed successfully!"
- name: Generate firmware image
run: |
set -e
BINARY_PATH="./target/xtensa-esp32s3-espidf/${{ matrix.build_type }}/app_esp32s3"
FEATURES_SUFFIX=$(echo '${{ matrix.features }}' | tr ',' '_')
OUTPUT_NAME="astrobox_esp32s3_${{ matrix.build_type }}_${FEATURES_SUFFIX}"
echo "Generating firmware image: ${OUTPUT_NAME}.bin"
espflash save-image \
--chip esp32s3 \
--flash-size 16mb \
--partition-table ./partitions.csv \
"$BINARY_PATH" \
"./${OUTPUT_NAME}.bin"
echo "Firmware generated successfully!"
ls -lh "./${OUTPUT_NAME}.bin"
- name: Upload firmware artifact
uses: actions/upload-artifact@v4
with:
name: "firmware-${{ matrix.build_type }}-$(echo '${{ matrix.features }}' | tr ',' '_')"
path: "astrobox_esp32s3_*.bin"
retention-days: 30
if-no-files-found: error
- name: Upload ELF artifact
uses: actions/upload-artifact@v4
with:
name: "elf-${{ matrix.build_type }}-$(echo '${{ matrix.features }}' | tr ',' '_')"
path: "target/xtensa-esp32s3-espidf/${{ matrix.build_type }}/app_esp32s3"
retention-days: 30
if-no-files-found: ignore
- name: Upload debug symbols
uses: actions/upload-artifact@v4
if: matrix.build_type == 'release'
with:
name: "symbols-${{ matrix.build_type }}-$(echo '${{ matrix.features }}' | tr ',' '_')"
path: |
target/xtensa-esp32s3-espidf/${{ matrix.build_type }}/*.map
retention-days: 14
if-no-files-found: ignore
release:
name: Create Release
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-22.04
steps:
- name: Download all firmware artifacts
uses: actions/download-artifact@v4
with:
pattern: firmware-*
path: artifacts
merge-multiple: true
- name: Display downloaded artifacts
run: |
ls -lh artifacts/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: artifacts/*.bin
generate_release_notes: true
draft: false
prerelease: false
lint:
name: Code Quality Checks
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build python3 python3-venv
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Setup esp toolchain
run: |
cargo install espup
espup install esp32s3
espup toolchain install esp32s3
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-lint-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-lint-${{ runner.os }}-
- name: Clippy check
run: |
. $HOME/esp/esp-idf/export.sh 2>/dev/null || true
export ESP_IDF_VERSION="v5.3.3"
export MCU="esp32s3"
cargo clippy --features "sdcard,repo_net,mi_account,webui" 2>&1 || echo "Clippy finished with warnings (non-blocking)"
- name: Check formatting
run: |
rustup component add rustfmt
cargo fmt -- --check 2>&1 || echo "Run 'cargo fmt' to fix formatting (non-blocking)"
test:
name: Unit Tests
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build python3 python3-venv
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Setup esp toolchain
run: |
cargo install espup
espup install esp32s3
espup toolchain install esp32s3
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-test-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-test-${{ runner.os }}-
- name: Run tests
run: |
. $HOME/esp/esp-idf/export.sh 2>/dev/null || true
export ESP_IDF_VERSION="v5.3.3"
export MCU="esp32s3"
echo "Running unit tests..."
cargo test --features "sdcard,repo_net,mi_account,webui" 2>&1
echo "Tests completed!"