ci: add a headers-check workflow that runs include-what-you-use on th… #3
Workflow file for this run
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: Check headers | |
| on: [push, pull_request] | |
| jobs: | |
| headers-check: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| board: ['HACKRF_ONE', 'JAWBREAKER', 'RAD1O', 'PRALINE'] | |
| cmake: ['3.10.0', 'latest'] | |
| # Don't cancel all builds when one fails | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Setup cmake | |
| uses: jwlawson/actions-setup-cmake@v2 | |
| with: | |
| cmake-version: ${{ matrix.cmake }} | |
| - name: Install Arm GNU Toolchain | |
| uses: carlosperate/arm-none-eabi-gcc-action@v1 | |
| - name: Install dependencies | |
| run: | | |
| python3 -m venv environment && source environment/bin/activate | |
| python3 -m pip install PyYAML | |
| sudo apt update | |
| sudo apt install iwyu | |
| - name: Build libopencm3 | |
| shell: bash | |
| working-directory: ${{github.workspace}}/firmware/libopencm3/ | |
| run: | | |
| source ../../environment/bin/activate | |
| make | |
| - name: Create Build Environment | |
| run: cmake -E make_directory ${{github.workspace}}/firmware/build | |
| - name: Configure CMake | |
| shell: bash | |
| working-directory: ${{github.workspace}}/firmware/build | |
| run: cmake $GITHUB_WORKSPACE/firmware/ -DCMAKE_BUILD_TYPE=Release -DBOARD=${{ matrix.board }} -DCHECK_HEADERS=1 | |
| - name: Build | |
| working-directory: ${{github.workspace}}/firmware/build | |
| shell: bash | |
| run: | | |
| source ../../environment/bin/activate | |
| output="$(cmake --build . --config Release 2>&1)" | |
| while IFS= read -r line | |
| do | |
| if [[ "${line}" == "Warning: include-what-you-use"* ]]; then | |
| exit_code=1 | |
| dump=1 | |
| elif [[ "${line}" == "---" ]]; then | |
| dump=0 | |
| fi | |
| if [[ ${dump} == "1" ]]; then | |
| echo "${line}" | |
| fi | |
| done <<< ${output} | |
| if [[ ${exit_code} == "1" ]]; then | |
| echo "Header check failed for board target: ${{ matrix.board }}" | |
| else | |
| echo "Header check succeeded for board target: ${{ matrix.board }}" | |
| fi | |
| exit ${exit_code} |