1--- 2 3name: Sparse Zephyr 4 5# 'workflow_dispatch' allows running this workflow manually from the 6# 'Actions' tab 7# yamllint disable-line rule:truthy 8on: [push, pull_request, workflow_dispatch, workflow_call] 9 10jobs: 11 # As of sparse commit ce1a6720f69e / Sept 2022, the exit status of 12 # sparse.c is an unusable mess and always zero in practice. Moreover 13 # SOF has hundreds of sparse warnings right now. So fail only on a 14 # small subset of specific warnings defined in 15 # sof/scripts/parse_sparse_output.sh 16 warnings-subset: 17 18 # We're sharing binaries with the zephyr-build container so keep 19 # this in sync with it. 20 runs-on: ubuntu-20.04 21 22 strategy: 23 fail-fast: false 24 matrix: 25 platforms: [ 26 {platform: tgl, 27 real_cc: xtensa-intel_s1000_zephyr-elf/bin/xtensa-intel_s1000_zephyr-elf-gcc}, 28 # This is the WRONG compiler for MTL but for now this is the 29 # one and only one expected by the Zephyr build system so it 30 # must be set to this value to sparse MTL. 31 # Sparse needs a REAL_CC but it does not matter which one, it 32 # does not affect sparse results. 33 # As soon as sof/west.yml is updated to a fixed Zephyr version 34 # this will fail with an error message that will show the 35 # exact value that must replace this one. 36 {platform: mtl, 37 real_cc: xtensa-intel_s1000_zephyr-elf/bin/xtensa-intel_s1000_zephyr-elf-gcc}, 38 ] 39 40 steps: 41 - name: git clone sparse analyzer 42 uses: actions/checkout@v3 43 with: 44 fetch-depth: 10 45 # TODO: switch to thesofproject/sparse 46 repository: marc-hb/sparse 47 path: workspace/sparse 48 49 - name: build sparse analyzer 50 run: cd workspace/sparse && make -j4 51 52 - name: git clone sof 53 uses: actions/checkout@v3 54 # From time to time this will catch a git tag and change SOF_VERSION 55 with: 56 fetch-depth: 10 57 path: ./workspace/sof 58 59 - name: west clones 60 run: pip3 install west && cd workspace/sof/ && west init -l && 61 west update --narrow --fetch-opt=--depth=5 62 63 # Not strictly necessary but saves a lot of scrolling in the next step 64 # Caching a 12G image is unfortunately not possible: 65 # https://github.com/ScribeMD/docker-cache/issues/304 66 # For faster builds we would have to pay for some persistent runners. 67 - name: Download docker image && ls /opt/toolchains/ 68 run: cd workspace && ./sof/zephyr/docker-run.sh ls -l /opt/toolchains/ 69 70 # We have to painfully extract REAL_CC from the docker image to 71 # tell the Zephyr build what it... already knows and wants!! Zephyr 72 # commit 3ebb18b8826 explains this sparse problem. 73 # 74 # --pristine is important to reproduce _warnings_. It makes no 75 # difference for github but it's useful for anyone trying to 76 # reproduce and copying the command from the logs. 77 - name: analyze zephyr 78 working-directory: ./workspace 79 run: | 80 ./sof/zephyr/docker-run.sh /bin/sh -c \ 81 'cmake -P ./sof/zephyr/FindZephyr-sdk.cmake > zsdk_location' 82 cat zsdk_location 83 ZSDK=$(cat zsdk_location); _RCC=${{ matrix.platforms.real_cc }} 84 REAL_CC="$ZSDK/$_RCC" ./sof/zephyr/docker-run.sh \ 85 ./sof/zephyr/docker-build.sh ${{ matrix.platforms.platform }} \ 86 --cmake-args=-DSPARSE=y --pristine 2>&1 | tee _.log 87 printf '\n\n\t\t\t ---- Messages below are treated as sparse errors --- \n\n\n' 88 (set -x; ./sof/scripts/parse_sparse_output.sh ${{ matrix.platforms.platform }} <_.log) 89