[skip-ci] Update to allow clazy-standalone runs too #705
Workflow file for this run
This file contains 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: Clang-Tidy Static Analysis | |
on: | |
[pull_request, workflow_dispatch] | |
env: | |
FEATURES: -DUSE_VTK=ON -DBUILD_GPL_PLUGINS=ON -DWITH_COORDGEN=OFF -DUSE_YAEHMOP=ON | |
BUILD_TYPE: RelWithDebInfo | |
QT_VERSION: 5.15.2 | |
CACHE: -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache | |
SCCACHE_GHA_ENABLED: "true" | |
jobs: | |
build: | |
name: ${{ matrix.config.name }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
name: "Ubuntu Analysis", | |
os: ubuntu-latest, | |
cc: "clang", cxx: "clang++", | |
cmake_flags: "-G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DUSE_SYSTEM_LIBXML2=ON -USE_SYSTEM_ZLIB=ON", | |
cpack: "", | |
} | |
steps: | |
- name: Install Dependencies (Linux) | |
if: runner.os == 'Linux' | |
run: | | |
sudo add-apt-repository -y universe | |
sudo apt-get -qq update | |
sudo apt-get -qq install ninja-build bear libeigen3-dev libboost-all-dev libglew-dev libxml2-dev | |
sudo apt-get -qq install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5x11extras5-dev libqt5svg5-dev | |
sudo apt-get -qq install clang-tidy clang-tools clazy | |
- name: Install Qt | |
uses: jurplel/install-qt-action@v3 | |
with: | |
cache: true | |
version: ${{ env.QT_VERSION }} | |
- name: Checkout openchemistry | |
uses: actions/checkout@v4 | |
with: | |
repository: openchemistry/openchemistry | |
submodules: recursive | |
- name: Checkout avogadroapp | |
uses: actions/checkout@v4 | |
with: | |
repository: openchemistry/avogadroapp | |
path: avogadroapp | |
- name: Checkout avogadrolibs | |
uses: actions/checkout@v4 | |
with: | |
path: avogadrolibs | |
fetch-depth: 2 | |
- name: Grab cache files | |
uses: actions/cache@v4 | |
with: | |
path: | | |
${{ runner.workspace }}/build/thirdparty | |
${{ runner.workspace }}/build/Downloads | |
key: ${{ matrix.config.name }}-thirdparty | |
- name: Run sccache-cache | |
uses: mozilla-actions/sccache-action@main | |
- name: Configure | |
run: | | |
if [ ! -d "${{ runner.workspace }}/build" ]; then mkdir "${{ runner.workspace }}/build"; fi | |
cd "${{ runner.workspace }}/build" | |
CC=${{matrix.config.cc}} CXX=${{matrix.config.cxx}} cmake $GITHUB_WORKSPACE ${{env.FEATURES}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{matrix.config.cmake_flags}} | |
shell: bash | |
- name: Build | |
run: | | |
CC=${{matrix.config.cc}} CXX=${{matrix.config.cxx}} CMAKE_C_COMPILER_LAUNCHER=sccache CMAKE_CXX_COMPILER_LAUNCHER=sccache ninja | |
# only re-compile avogadrolibs | |
(cd avogadrolibs; ninja clean) | |
bear -- ninja | |
shell: bash | |
working-directory: ${{ runner.workspace }}/build | |
- name: Create results directory | |
run: | | |
mkdir ${{ runner.workspace }}/results | |
- name: Clazy | |
run: | | |
find ../avogadrolibs/avogadrolibs/avogadro/ -name "*.cpp" | xargs clazy-standalone -p compile_commands.json -checks=old-style-connect -export-fixes=${{ runner.workspace }}/results/clazy-fixes.yaml | |
clang-apply-replacements ${{ runner.workspace }}/results/clazy-fixes.yaml | |
working-directory: ${{ runner.workspace }}/build | |
- name: Analyze | |
run: | | |
# generate the fixes and we'll make a diff | |
#run-clang-tidy -p ../build -fix | |
cd avogadrolibs | |
pwd | |
echo "Generating diff" | |
git diff >${{ runner.workspace }}/results/tidy.patch | |
working-directory: ${{ runner.workspace }}/avogadrolibs | |
- name: Save PR metadata | |
run: | | |
echo ${{ github.event.number }} > ${{ runner.workspace }}/results/pr-id.txt | |
echo ${{ github.event.pull_request.head.repo.full_name }} > ${{ runner.workspace }}/results/pr-head-repo.txt | |
echo ${{ github.event.pull_request.head.ref }} > ${{ runner.workspace }}/results/pr-head-ref.txt | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: results | |
path: ${{ runner.workspace }}/results/ |