From dc1131718fe9003ae672b111e879172089c0d3a6 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Thu, 16 May 2024 09:45:11 -0400 Subject: [PATCH] replace C linter with clang-tidy CI (#459) --- .github/workflows/c-linter.yml | 45 ------------------- .github/workflows/clang-tidy.yml | 36 +++++++++++++++ .../dependencies_clang-tidy-apt-llvm.sh | 22 +++++++++ 3 files changed, 58 insertions(+), 45 deletions(-) delete mode 100644 .github/workflows/c-linter.yml create mode 100644 .github/workflows/clang-tidy.yml create mode 100755 .github/workflows/dependencies_clang-tidy-apt-llvm.sh diff --git a/.github/workflows/c-linter.yml b/.github/workflows/c-linter.yml deleted file mode 100644 index 6856d1879..000000000 --- a/.github/workflows/c-linter.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: cpp-linter - -on: [pull_request] -jobs: - cpp-linter: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Get submodules - run: | - git submodule update --init - cd external/Microphysics - git fetch; git checkout development - cd ../amrex - git fetch; git checkout development - cd ../.. - - - name: Install dependencies - run: | - sudo apt-get update -y -qq - sudo apt-get -qq -y install curl clang-tidy cmake jq clang cppcheck clang-format bear g++>=9.3.0 gfortran>=9.3.0 - - - name: Run cpp linter - uses: AMReX-Astro/cpp-linter-action@main - with: - build_path: 'Exec/science/wdconvect' - make_options: '-j 2 USE_OMP=FALSE USE_MPI=FALSE USE_CUDA=FALSE DIM=3 DEBUG=TRUE' - ignore_files: 'amrex|Microphysics' - header_filter: 'MAESTROeX' - config_file: ${GITHUB_WORKSPACE}/.clang-tidy - - - name: Archive clang tidy report - uses: actions/upload-artifact@v4 - with: - name: clang-tidy-report - path: clang-tidy-report.txt - - - name: Archive cppcheck report - uses: actions/upload-artifact@v4 - with: - name: cppcheck-report - path: cppcheck-report.txt \ No newline at end of file diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml new file mode 100644 index 000000000..b9c2e799f --- /dev/null +++ b/.github/workflows/clang-tidy.yml @@ -0,0 +1,36 @@ +name: "clang-tidy" + +on: [pull_request] + +concurrency: + group: ${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }} + cancel-in-progress: true + +jobs: + clang_tidy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Get submodules + run: | + git submodule update --init + cd external/Microphysics + git fetch; git checkout development + echo "MICROPHYSICS_HOME=$(pwd)" >> $GITHUB_ENV + cd ../amrex + git fetch; git checkout development + echo "AMREX_HOME=$(pwd)" >> $GITHUB_ENV + cd ../.. + + - name: Install dependencies + run: | + .github/workflows/dependencies_clang-tidy-apt-llvm.sh 17 + + - name: Compile wdconvect + run: | + echo $AMREX_HOME + echo $MICROPHYSICS_HOME + cd Exec/science/wdconvect + make USE_MPI=FALSE USE_OMP=FALSE USE_CLANG_TIDY=TRUE CLANG_TIDY=clang-tidy-17 CLANG_TIDY_WARN_ERROR=TRUE -j 4 + diff --git a/.github/workflows/dependencies_clang-tidy-apt-llvm.sh b/.github/workflows/dependencies_clang-tidy-apt-llvm.sh new file mode 100755 index 000000000..b64cd619e --- /dev/null +++ b/.github/workflows/dependencies_clang-tidy-apt-llvm.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -eu -o pipefail + +# `man apt.conf`: +# Number of retries to perform. If this is non-zero APT will retry +# failed files the given number of times. +echo 'Acquire::Retries "3";' | sudo tee /etc/apt/apt.conf.d/80-retries + +if [[ ! -f /etc/apt/trusted.gpg.d/apt.llvm.org.asc ]]; then + wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc +fi + +source /etc/os-release # set UBUNTU_CODENAME + +sudo add-apt-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME} main" +sudo add-apt-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-$1 main" + +sudo apt-get update + +sudo apt-get install -y --no-install-recommends \ + clang-tidy-$1 libomp-$1-dev