diff --git a/.github/workflows/compiler_warnings.yaml b/.github/workflows/compiler_warnings.yaml
new file mode 100644
index 00000000..185f025c
--- /dev/null
+++ b/.github/workflows/compiler_warnings.yaml
@@ -0,0 +1,222 @@
+name: Report Compiler Warnings
+
+on:
+ pull_request: {}
+
+permissions:
+ pull-requests: write
+ contents: read
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
+ cancel-in-progress: true
+
+jobs:
+ warnings:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ # Clone the repo to a subdirectory, so we can initialize the Zephyr
+ # workspace in the parent directory.
+ path: zephyr-workspace/open-earable-v2
+
+ - name: Cache/Install APT Packages
+ uses: awalsh128/cache-apt-pkgs-action@latest
+ with:
+ packages: ccache git cmake ninja-build gperf ccache dfu-util device-tree-compiler wget python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1
+ version: 1.0
+ execute_install_scripts: true
+
+ - name: Cache PIP Packages
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/pip
+ key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
+ restore-keys: |
+ ${{ runner.os }}-pip-
+
+ - name: Install West
+ run: pip3 install west
+
+ - name: Install Zephyr SDK
+ run: |
+ wget -q https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.0/zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz
+ tar xf zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz -C ~/
+ ~/zephyr-sdk-0.17.0/setup.sh -c -t arm-zephyr-eabi
+
+ - name: Initialize Zephyr Workspace
+ run: |
+ cd zephyr-workspace
+ west init -l open-earable-v2
+ west update --narrow -o=--depth=1
+ pip3 install -r zephyr/scripts/requirements.txt
+
+ - name: Register Custom Boards
+ run: |
+ mkdir -p $(pwd)/workflow-board-temp
+ cp -R $(pwd)/zephyr-workspace/open-earable-v2/boards $(pwd)/workflow-board-temp/boards
+
+ mkdir -p $(pwd)/workflow-board-temp/boards/arm
+ cp -R -f $(pwd)/workflow-board-temp/boards/teco/* $(pwd)/workflow-board-temp/boards/arm/ || true
+ rm -f -R $(pwd)/workflow-board-temp/boards/teco
+
+ cp -R -f $(pwd)/workflow-board-temp/boards/* $(pwd)/zephyr-workspace/zephyr/boards
+
+ - name: Cache ~/.cache/ccache
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/ccache
+ key: ccache-warnings-v1-${{ runner.os }}-${{ hashFiles('zephyr-workspace/open-earable-v2/west.yml') }}
+ restore-keys: |
+ ccache-warnings-v1-${{ runner.os }}-
+
+ - name: Build with Extended Compiler Warnings
+ continue-on-error: true
+ timeout-minutes: 15
+ id: warning-build
+ env:
+ EXTRA_CFLAGS: -Wextra -Wshadow
+ EXTRA_CXXFLAGS: -Wextra -Wshadow
+ run: |
+ set -o pipefail
+ cd zephyr-workspace
+ west build \
+ --build-dir build-warnings \
+ --board openearable_v2/nrf5340/cpuapp \
+ --pristine=always open-earable-v2 \
+ -- -DFILE_SUFFIX="fota" \
+ 2>&1 | tee warning-build.log
+
+ - name: Collect Compiler Warnings
+ if: always()
+ continue-on-error: true
+ id: compiler-warnings
+ run: |
+ mkdir -p workflow-board-temp
+ warning_report="workflow-board-temp/compiler-warnings.txt"
+ project_warning_report="workflow-board-temp/project-compiler-warnings.txt"
+ configuration_warning_report="workflow-board-temp/configuration-warnings.txt"
+
+ if [ -f zephyr-workspace/warning-build.log ]; then
+ sed -E 's/\x1B\[[0-9;]*[mK]//g' zephyr-workspace/warning-build.log \
+ | grep -Ei '(^|[[:space:]])warning:' \
+ > "$warning_report" || true
+ else
+ touch "$warning_report"
+ fi
+
+ grep '/zephyr-workspace/open-earable-v2/' "$warning_report" \
+ | sed -E 's#^.*/zephyr-workspace/open-earable-v2/##' \
+ | awk '!seen[$0]++' \
+ > "$project_warning_report" || true
+
+ grep -Ei '^[[:space:]]*(---[[:space:]]*)?warning:' "$warning_report" \
+ | awk '!seen[$0]++' \
+ > "$configuration_warning_report" || true
+
+ warning_count=$(wc -l < "$warning_report" | tr -d ' ')
+ project_warning_count=$(wc -l < "$project_warning_report" | tr -d ' ')
+ configuration_warning_count=$(wc -l < "$configuration_warning_report" | tr -d ' ')
+
+ echo "count=$warning_count" >> "$GITHUB_OUTPUT"
+ echo "project_count=$project_warning_count" >> "$GITHUB_OUTPUT"
+ echo "configuration_count=$configuration_warning_count" >> "$GITHUB_OUTPUT"
+ echo "Collected $warning_count warning(s): $project_warning_count unique project and $configuration_warning_count unique configuration warning(s)."
+
+ - name: Upload Complete Compiler Warning Report
+ if: always()
+ continue-on-error: true
+ uses: actions/upload-artifact@v4
+ id: warning-artifact-upload
+ with:
+ name: compiler-warnings
+ path: workflow-board-temp/compiler-warnings.txt
+
+ - name: Prepare PR Comment
+ if: always()
+ continue-on-error: true
+ env:
+ WARNING_BUILD_OUTCOME: ${{ steps.warning-build.outcome }}
+ TOTAL_WARNING_COUNT: ${{ steps.compiler-warnings.outputs.count }}
+ PROJECT_WARNING_COUNT: ${{ steps.compiler-warnings.outputs.project_count }}
+ CONFIGURATION_WARNING_COUNT: ${{ steps.compiler-warnings.outputs.configuration_count }}
+ WARNING_REPORT_URL: ${{ steps.warning-artifact-upload.outputs.artifact-url }}
+ run: |
+ comment="workflow-board-temp/compiler-warnings-comment.md"
+ project_warning_report="workflow-board-temp/project-compiler-warnings.txt"
+ configuration_warning_report="workflow-board-temp/configuration-warnings.txt"
+ touch "$project_warning_report" "$configuration_warning_report"
+
+ {
+ echo "## Compiler warnings"
+ echo
+
+ if [ "$WARNING_BUILD_OUTCOME" = "success" ]; then
+ echo "The extended-warning build completed successfully."
+ elif [ "$WARNING_BUILD_OUTCOME" = "failure" ]; then
+ echo "The extended-warning build failed; this report may be incomplete."
+ else
+ echo "The extended-warning build did not run."
+ fi
+
+ echo
+ if [ "$WARNING_BUILD_OUTCOME" = "skipped" ]; then
+ echo "### Project compiler warnings: unavailable"
+ elif [ "${PROJECT_WARNING_COUNT:-0}" -eq 0 ]; then
+ echo "### Project compiler warnings: none"
+ else
+ echo "### Project compiler warnings: $PROJECT_WARNING_COUNT"
+ echo
+ echo ""
+ echo "Show project warnings
"
+ echo
+ echo '```text'
+ head -n 100 "$project_warning_report"
+ echo '```'
+ echo
+ if [ "$PROJECT_WARNING_COUNT" -gt 100 ]; then
+ echo "Showing the first 100 unique project warnings."
+ echo
+ fi
+ echo " "
+ fi
+
+ if [ "$WARNING_BUILD_OUTCOME" != "skipped" ]; then
+ echo
+ if [ "${CONFIGURATION_WARNING_COUNT:-0}" -eq 0 ]; then
+ echo "### Configuration and security warnings: none"
+ else
+ echo "### Configuration and security warnings: $CONFIGURATION_WARNING_COUNT"
+ echo
+ echo ""
+ echo "Show configuration warnings
"
+ echo
+ echo '```text'
+ head -n 50 "$configuration_warning_report"
+ echo '```'
+ echo
+ echo " "
+ fi
+
+ echo
+ if [ -n "$WARNING_REPORT_URL" ]; then
+ echo "The [complete warning report]($WARNING_REPORT_URL) contains all ${TOTAL_WARNING_COUNT:-0} warning lines, including warnings from Zephyr and other dependencies."
+ else
+ echo "The complete warning report artifact could not be uploaded."
+ fi
+ fi
+
+ echo
+ echo "[View the warning workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
+ } > "$comment"
+
+ cat "$comment" >> "$GITHUB_STEP_SUMMARY"
+
+ - name: Comment Compiler Warnings on PR
+ if: always()
+ continue-on-error: true
+ uses: thollander/actions-comment-pull-request@v3
+ with:
+ file-path: workflow-board-temp/compiler-warnings-comment.md
+ comment-tag: compiler-warnings