|
| 1 | +name: Check includes |
| 2 | +on: [push, pull_request] |
| 3 | + |
| 4 | +defaults: |
| 5 | + run: |
| 6 | + shell: bash |
| 7 | + |
| 8 | +jobs: |
| 9 | + includes-check: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + container: |
| 12 | + image: "debian:13" |
| 13 | + options: --user 0 |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + board: ['HACKRF_ONE', 'JAWBREAKER', 'RAD1O', 'PRALINE'] |
| 17 | + cmake: ['3.10.0', 'latest'] |
| 18 | + |
| 19 | + # Don't cancel all builds when one fails |
| 20 | + fail-fast: false |
| 21 | + |
| 22 | + steps: |
| 23 | + |
| 24 | + - name: Make it work on debian |
| 25 | + run: | |
| 26 | + apt update |
| 27 | + apt install -y git python3 python3-pip python3-venv nodejs |
| 28 | + # actions/checkout insists on putting the checkout in the |
| 29 | + # working directory rather than ${{ github.workspace }}. |
| 30 | + # |
| 31 | + # This may just be because the 'runner' user does not exist |
| 32 | + # in the docker image at startup. |
| 33 | + # |
| 34 | + # also see: https://github.com/actions/runner/issues/878 |
| 35 | + useradd -ms /bin/bash runner |
| 36 | + ln -s /__w /home/runner/work |
| 37 | +
|
| 38 | + - name: Checkout repository |
| 39 | + uses: actions/checkout@v6 |
| 40 | + with: |
| 41 | + submodules: true |
| 42 | + |
| 43 | + - name: Setup cmake |
| 44 | + uses: jwlawson/actions-setup-cmake@v2 |
| 45 | + with: |
| 46 | + cmake-version: ${{ matrix.cmake }} |
| 47 | + |
| 48 | + - name: Install Arm GNU Toolchain |
| 49 | + uses: carlosperate/arm-none-eabi-gcc-action@v1 |
| 50 | + |
| 51 | + - name: Install dependencies |
| 52 | + run: | |
| 53 | + python3 -m venv environment && source environment/bin/activate |
| 54 | + python3 -m pip install PyYAML |
| 55 | + apt install -y iwyu |
| 56 | + iwyu --version |
| 57 | +
|
| 58 | + - name: Build libopencm3 |
| 59 | + working-directory: ${{github.workspace}}/firmware/libopencm3/ |
| 60 | + run: | |
| 61 | + source ../../environment/bin/activate |
| 62 | + make |
| 63 | +
|
| 64 | + - name: Create Build Environment |
| 65 | + run: cmake -E make_directory ${{github.workspace}}/firmware/build |
| 66 | + |
| 67 | + - name: Configure CMake |
| 68 | + working-directory: ${{github.workspace}}/firmware/build |
| 69 | + run: cmake ${{github.workspace}}/firmware/ -DCMAKE_BUILD_TYPE=Release -DBOARD=${{ matrix.board }} -DCHECK_INCLUDES=1 |
| 70 | + |
| 71 | + - name: Build |
| 72 | + working-directory: ${{github.workspace}}/firmware/build |
| 73 | + run: | |
| 74 | + source ../../environment/bin/activate |
| 75 | + output="$(cmake --build . --config Release 2>&1)" |
| 76 | + while IFS= read -r line |
| 77 | + do |
| 78 | + if [[ "${line}" == "Warning: include-what-you-use"* ]]; then |
| 79 | + exit_code=1 |
| 80 | + dump=1 |
| 81 | + echo |
| 82 | + elif [[ "${line}" == "---" ]]; then |
| 83 | + dump=0 |
| 84 | + echo |
| 85 | + fi |
| 86 | + if [[ ${dump} == "1" ]]; then |
| 87 | + echo "${line}" |
| 88 | + fi |
| 89 | + done <<< ${output} |
| 90 | + if [[ ${exit_code} == "1" ]]; then |
| 91 | + echo "Includes check failed for board target: ${{ matrix.board }}" |
| 92 | + else |
| 93 | + echo "Includes check succeeded for board target: ${{ matrix.board }}" |
| 94 | + fi |
| 95 | + echo $(include-what-you-use --version) |
| 96 | + exit ${exit_code} |
0 commit comments