diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 25045ac5..c5a2b0e9 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -1,6 +1,10 @@ name: Build on: [push, pull_request] +permissions: + contents: read + pull-requests: write + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true # Cancel in-flight jobs for the same branch or PR @@ -129,7 +133,24 @@ jobs: sudo apt install --no-install-recommends git cmake ninja-build gperf ccache dfu-util device-tree-compiler wget python3-dev python3-venv python3-tk xz-utils file make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1 sudo apt install xxd + - name: Cache Zephyr + id: cache-zephyr + uses: actions/cache@v5 + with: + path: zephyrproject + key: ${{ runner.os }}-zephyr + + - name: Remove WARDuino from cache if present + if: steps.cache-zephyr.outputs.cache-hit == 'true' + working-directory: ${{ github.workspace }}/zephyrproject + run: | + rm -rf WARDuino + + source .venv/bin/activate + west zephyr-export + - name: Install Zephyr + if: steps.cache-zephyr.outputs.cache-hit != 'true' working-directory: ${{ github.workspace }} run: | python3 -m venv zephyrproject/.venv @@ -145,8 +166,19 @@ jobs: west packages pip --install - cd zephyr - west sdk install + - name: Cache Zephyr SDK + id: cache-zephyr-sdk + uses: actions/cache@v5 + with: + path: zephyr-sdk + key: ${{ runner.os }}-zephyr-sdk + + - name: Install Zephyr SDK + if: steps.cache-zephyr-sdk.outputs.cache-hit != 'true' + working-directory: ${{ github.workspace }}/zephyrproject + run: | + source .venv/bin/activate + west sdk install --install-dir ${{ github.workspace }}/zephyr-sdk - name: Checkout repository uses: actions/checkout@v6 @@ -160,8 +192,33 @@ jobs: cp tests/compilation/esp32/upload.wasm platforms/Zephyr/upload.wasm - name: Build ESP32 target + env: + Zephyr-sdk_DIR: ${{ github.workspace }}/zephyr-sdk/cmake working-directory: ${{ github.workspace }}/zephyrproject/WARDuino run: | source ../.venv/bin/activate cd platforms/Zephyr west build -b esp32_devkitc_wroom/esp32/procpu + + - name: Create ROM + RAM report + id: zephyr-size + working-directory: ${{ github.workspace }}/zephyrproject/WARDuino + run: | + source ../.venv/bin/activate + cd platforms/Zephyr + + echo "## Zephyr build size report" > build-size.md + echo "### ROM" >> build-size.md + echo '```text' >> build-size.md + echo $(west build -t rom_report | tail -n1 | tr -d " " | numfmt --to=iec --format="%.2f") >> build-size.md + echo '```' >> build-size.md + + - uses: jwalton/gh-find-current-pr@v1 + id: finder + + - name: Comment Zephyr size report + uses: marocchino/sticky-pull-request-comment@v3 + with: + header: build-size + number: ${{ steps.finder.outputs.pr }} + path: zephyrproject/WARDuino/platforms/Zephyr/build-size.md