|
| 1 | +name: static-analyzer |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + types: [opened, synchronize, reopened, closed] |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' || github.event_name == 'push'}} |
| 8 | + runs-on: ubuntu-latest |
| 9 | + outputs: |
| 10 | + artifact-id: ${{ steps.upload-sareport.outputs.artifact-id }} |
| 11 | + steps: |
| 12 | + - name: Checkout atlas |
| 13 | + uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + path: atlas |
| 16 | + - name: Checkout ecbuild |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + repository: ecmwf/ecbuild |
| 20 | + path: ecbuild |
| 21 | + ref: 'develop' |
| 22 | + - name: Checkout eckit |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + repository: ecmwf/eckit |
| 26 | + path: eckit |
| 27 | + ref: 'develop' |
| 28 | + - name: Checkout fckit |
| 29 | + uses: actions/checkout@v4 |
| 30 | + with: |
| 31 | + repository: ecmwf/fckit |
| 32 | + path: fckit |
| 33 | + ref: 'develop' |
| 34 | + - name: Install dependencies |
| 35 | + run: | |
| 36 | + python -m pip install CodeChecker |
| 37 | +
|
| 38 | + - name: Generate CMakeLists.txt |
| 39 | + shell: bash # default on ubuntu-latest |
| 40 | + run: | |
| 41 | + # Write the file atomically; fail if anything goes wrong |
| 42 | + cat > CMakeLists.txt <<'CML' |
| 43 | + cmake_minimum_required(VERSION 3.18 FATAL_ERROR) |
| 44 | +
|
| 45 | + #################################################################### |
| 46 | +
|
| 47 | + macro(ecbundle_add_project package_name) |
| 48 | + # |
| 49 | + # add_subdirectory depending on BUILD_${package_name} |
| 50 | + # |
| 51 | + set(BUILD_${package_name} ON CACHE BOOL "") |
| 52 | +
|
| 53 | + if(BUILD_${package_name}) |
| 54 | + set(dir ${ARGV1}) |
| 55 | + if(NOT dir) |
| 56 | + set(dir ${package_name}) |
| 57 | + endif() |
| 58 | + add_subdirectory(${dir}) |
| 59 | + endif() |
| 60 | + endmacro() |
| 61 | +
|
| 62 | + macro(ecbundle_set key value) |
| 63 | + set(${key} ${value} CACHE STRING "") |
| 64 | + if("${${key}}" STREQUAL "${value}") |
| 65 | + message(" - ${key} = ${value}") |
| 66 | + else() |
| 67 | + message(" - ${key} = ${${key}} [default=${value}]") |
| 68 | + endif() |
| 69 | + endmacro() |
| 70 | +
|
| 71 | + #################################################################### |
| 72 | +
|
| 73 | + message(" - source : ${CMAKE_CURRENT_SOURCE_DIR}") |
| 74 | + message(" - build : ${CMAKE_CURRENT_BINARY_DIR}") |
| 75 | + message(" - install : ${CMAKE_INSTALL_PREFIX}") |
| 76 | + message(" - build type : ${CMAKE_BUILD_TYPE}") |
| 77 | + message("Bundle variables set for this build:") |
| 78 | +
|
| 79 | + ecbundle_set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| 80 | + ecbundle_set(ENABLE_ECKIT_CMD OFF) |
| 81 | + ecbundle_set(ENABLE_ECKIT_SQL OFF) |
| 82 | + ecbundle_set(ENABLE_ECKIT_GEO OFF) |
| 83 | + ecbundle_set(ENABLE_OMP OFF) |
| 84 | + ecbundle_set(ECKIT_ENABLE_TESTS OFF) |
| 85 | + ecbundle_set(FCKIT_ENABLE_TESTS OFF) |
| 86 | +
|
| 87 | + message("") |
| 88 | +
|
| 89 | + #################################################################### |
| 90 | +
|
| 91 | + find_package(ecbuild 3.8 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR}/ecbuild) |
| 92 | + project(bundle VERSION 0.0.0) |
| 93 | +
|
| 94 | + ## Initialize |
| 95 | + include(${CMAKE_CURRENT_BINARY_DIR}/init.cmake OPTIONAL) |
| 96 | +
|
| 97 | + ## Projects |
| 98 | + ecbundle_add_project(ecbuild) |
| 99 | + ecbundle_add_project(eckit) |
| 100 | + ecbundle_add_project(fckit) |
| 101 | + ecbundle_add_project(atlas) |
| 102 | +
|
| 103 | + ## Finalize |
| 104 | + include(${CMAKE_CURRENT_BINARY_DIR}/final.cmake OPTIONAL) |
| 105 | +
|
| 106 | + ecbuild_install_project(NAME ${PROJECT_NAME}) |
| 107 | + ecbuild_print_summary() |
| 108 | + CML |
| 109 | +
|
| 110 | +
|
| 111 | + - name: Build sources |
| 112 | + run: | |
| 113 | + mkdir build |
| 114 | + cd build |
| 115 | + cmake -GNinja .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON |
| 116 | + ninja |
| 117 | +
|
| 118 | + - name: Analyze sources |
| 119 | + run: | |
| 120 | + jq '[ .[] | select(.file | test(".*/atlas/src/.*") ) ]' build/compile_commands.json > atlas_compile_commands.json |
| 121 | + jq '[ .[] | select(.file | test(".*/pluto/src/.*") ) ]' build/compile_commands.json > pluto_compile_commands.json |
| 122 | + jq -n --slurpfile atlas atlas_compile_commands.json --slurpfile pluto pluto_compile_commands.json '$atlas[] + $pluto[]' \ |
| 123 | + > build/filtered_compile_commands.json |
| 124 | + CodeChecker analyze build/filtered_compile_commands.json -o cc_out --analyzers clangsa -j 4 \ |
| 125 | + -i atlas/.github/static-analyzer-skip.txt |
| 126 | + CodeChecker parse -e html cc_out -o ./reports_html --trim-path-prefix ${PWD} || true |
| 127 | + - name: Archive static-analyzer report |
| 128 | + id: upload-sareport |
| 129 | + uses: actions/upload-artifact@v4 |
| 130 | + with: |
| 131 | + name: sareport |
| 132 | + path: reports_html |
| 133 | + preview-publish: |
| 134 | + if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }} |
| 135 | + needs: build |
| 136 | + uses: ecmwf/reusable-workflows/.github/workflows/pr-preview-publish.yml@main |
| 137 | + with: |
| 138 | + artifact-id: ${{ needs.build.outputs.artifact-id }} |
| 139 | + space: docs |
| 140 | + name: atlas |
| 141 | + path: static-analyzer |
| 142 | + link-text: 💣💥☠️ Static Analyzer Report ☠️💥💣 |
| 143 | + link-tag: STATIC-ANALYSIS |
| 144 | + secrets: |
| 145 | + sites-token: ${{ secrets.ECMWF_SITES_TOKEN }} |
| 146 | + preview-unpublish: |
| 147 | + if: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' }} |
| 148 | + uses: ecmwf/reusable-workflows/.github/workflows/pr-preview-unpublish.yml@main |
| 149 | + with: |
| 150 | + space: docs |
| 151 | + name: atlas |
| 152 | + path: static-analyzer |
| 153 | + secrets: |
| 154 | + sites-token: ${{ secrets.ECMWF_SITES_TOKEN }} |
0 commit comments