Feature/docs static analyzer #6
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: Publish static analyzer to sites.ecmwf.int | |
on: | |
# REENABLE BEFORE MERGING | |
# pull_request_target: | |
pull_request: | |
types: [opened, synchronize, reopened, closed] | |
jobs: | |
build: | |
if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' || github.event_name == 'push'}} | |
runs-on: ubuntu-latest | |
outputs: | |
artifact-id: ${{ steps.upload-sareport.outputs.artifact-id }} | |
steps: | |
- name: Checkout Multio | |
uses: actions/checkout@v4 | |
with: | |
path: multio | |
- name: Checkout ecbuild | |
uses: actions/checkout@v4 | |
with: | |
repository: ecmwf/ecbuild | |
path: ecbuild | |
ref: 'develop' | |
- name: Checkout eckit | |
uses: actions/checkout@v4 | |
with: | |
repository: ecmwf/eckit | |
path: eckit | |
ref: 'develop' | |
- name: Checkout eccodes | |
uses: actions/checkout@v4 | |
with: | |
repository: ecmwf/eccodes | |
path: eccodes | |
ref: 'develop' | |
- name: Checkout metkit | |
uses: actions/checkout@v4 | |
with: | |
repository: ecmwf/metkit | |
path: metkit | |
ref: 'develop' | |
- name: Checkout fckit | |
uses: actions/checkout@v4 | |
with: | |
repository: ecmwf/fckit | |
path: fckit | |
ref: 'develop' | |
- name: Checkout fdb | |
uses: actions/checkout@v4 | |
with: | |
repository: ecmwf/fdb | |
path: fdb | |
ref: 'develop' | |
- name: Checkout atlas | |
uses: actions/checkout@v4 | |
with: | |
repository: ecmwf/atlas | |
path: atlas | |
ref: 'develop' | |
- name: Checkout mir | |
uses: actions/checkout@v4 | |
with: | |
repository: ecmwf/mir | |
path: mir | |
ref: 'develop' | |
# - name: Checkout pgen | |
# uses: actions/checkout@v4 | |
# with: | |
# repository: ecmwf/pgen | |
# path: pgen | |
# ref: 'develop' | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
- name: Install dependencies | |
run: | | |
python -m pip install CodeChecker | |
sudo apt-get install -y libaec-dev | |
- name: Generate CMakeLists.txt | |
shell: bash # default on ubuntu-latest | |
run: | | |
# Write the file atomically; fail if anything goes wrong | |
cat > CMakeLists.txt <<'CML' | |
cmake_minimum_required(VERSION 3.12 FATAL_ERROR) | |
#################################################################### | |
macro(ecbundle_add_project package_name) | |
# | |
# add_subdirectory depending on BUILD_${package_name} | |
# | |
set(BUILD_${package_name} ON CACHE BOOL "") | |
if(BUILD_${package_name}) | |
set(dir ${ARGV1}) | |
if(NOT dir) | |
set(dir ${package_name}) | |
endif() | |
add_subdirectory(${dir}) | |
endif() | |
endmacro() | |
macro(ecbundle_set key value) | |
set(${key} ${value} CACHE STRING "") | |
if("${${key}}" STREQUAL "${value}") | |
message(" - ${key} = ${value}") | |
else() | |
message(" - ${key} = ${${key}} [default=${value}]") | |
endif() | |
endmacro() | |
#################################################################### | |
message(" - source : ${CMAKE_CURRENT_SOURCE_DIR}") | |
message(" - build : ${CMAKE_CURRENT_BINARY_DIR}") | |
message(" - install : ${CMAKE_INSTALL_PREFIX}") | |
message(" - build type : ${CMAKE_BUILD_TYPE}") | |
message("Bundle variables set for this build:") | |
ecbundle_set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | |
ecbundle_set(ENABLE_AEC ON) | |
ecbundle_set(ENABLE_MEMFS ON) | |
ecbundle_set(CMAKE_BUILD_TYPE Release) | |
ecbundle_set(ENABLE_ECKIT_CMD off) | |
ecbundle_set(ENABLE_ECKIT_SQL off) | |
ecbundle_set(ENABLE_PYTHON_API_TESTS ON) | |
message("") | |
#################################################################### | |
find_package(ecbuild 3.0 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR}/ecbuild) | |
project(All VERSION 2024.11) | |
## Initialize | |
include(${CMAKE_CURRENT_BINARY_DIR}/init.cmake OPTIONAL) | |
## Projects | |
ecbundle_add_project(ecbuild) | |
ecbundle_add_project(eccodes) | |
ecbundle_add_project(eckit) | |
ecbundle_add_project(metkit) | |
ecbundle_add_project(fckit) | |
ecbundle_add_project(fdb) | |
ecbundle_add_project(atlas) | |
ecbundle_add_project(mir) | |
# ecbundle_add_project(pgen) | |
ecbundle_add_project(multio) | |
## Finalize | |
include(${CMAKE_CURRENT_BINARY_DIR}/final.cmake OPTIONAL) | |
ecbuild_install_project(NAME ${PROJECT_NAME}) | |
ecbuild_print_summary() | |
CML | |
- name: Build sources | |
run: | | |
mkdir build | |
cd build | |
cmake -GNinja .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON | |
ninja | |
- name: Analyze sources | |
run: | | |
CodeChecker analyze build/compile_commands.json -o cc_out --analyzers clangsa | |
CodeChecker parse -e html cc_out -o ./reports_html || true | |
- name: Archive static-analyzer report | |
id: upload-sareport | |
uses: actions/upload-artifact@v4 | |
with: | |
name: sareport | |
path: reports_html | |
preview-publish: | |
if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }} | |
needs: build | |
uses: ecmwf/reusable-workflows/.github/workflows/pr-preview-publish.yml@feature/allow-target-dir-in-sites-upload | |
with: | |
artifact-id: ${{ needs.build.outputs.artifact-id }} | |
space: docs | |
name: dev-section | |
path: multio/static-analyzer | |
link-text: 💣💥☠️ Static Analyzer Report ☠️💥💣 | |
link-tag: STATIC-ANALYSIS | |
secrets: | |
sites-token: ${{ secrets.ECMWF_SITES_DOCS_DEV_SECTION_TOKEN }} | |
preview-unpublish: | |
if: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' }} | |
uses: ecmwf/reusable-workflows/.github/workflows/pr-preview-unpublish.yml@feature/allow-target-dir-in-sites-upload | |
with: | |
space: docs | |
name: dev-section | |
path: multio/static-analyzer | |
secrets: | |
sites-token: ${{ secrets.ECMWF_SITES_DOCS_DEV_SECTION_TOKEN }} |