Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[skip-ci] Update to allow clazy-standalone runs too #1903

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
if: ${{ github.ref != 'refs/heads/master' }}
steps:
- name: 'Install clang-format'
run: sudo apt-get -qq install clang-format-15
run: sudo apt-get -qq install clang-format-16

- uses: actions/checkout@v4

Expand All @@ -17,17 +17,16 @@ jobs:
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/openchemistry/avogadrolibs
git fetch origin master:master

echo `which clang-format-diff-13`
export MASTER_SHA=`cat .git/refs/heads/master`
echo MASTER_SHA=${MASTER_SHA}

git diff `cat .git/refs/heads/master` --name-only
DIFF=`git diff -U0 ${MASTER_SHA} -- '*.h' '*.cpp' | clang-format-diff-13 -p1`
DIFF=`git diff -U0 ${MASTER_SHA} -- '*.h' '*.cpp' | clang-format-diff-16 -p1`
if [ -z "$DIFF" ]; then
printf "clang-format-diff reports no problems"
exit 0
else
git diff -U0 ${MASTER_SHA} -- '*.h' '*.cpp' | clang-format-diff-13 -p1 >${{ runner.workspace }}/clang-format.diff
git diff -U0 ${MASTER_SHA} -- '*.h' '*.cpp' | clang-format-diff-16 -p1 >${{ runner.workspace }}/clang-format.diff
exit 1
fi

Expand Down
52 changes: 31 additions & 21 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: Clang-Tidy Static Analysis

on:
workflow_dispatch:
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:
Expand All @@ -29,10 +31,11 @@ jobs:
- 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 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
sudo apt-get -qq install clang-tidy clang-tools clazy

- name: Install Qt
uses: jurplel/install-qt-action@v3
Expand Down Expand Up @@ -60,13 +63,15 @@ jobs:

- name: Grab cache files
uses: actions/cache@v4
if: runner.os != 'Windows'
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
Expand All @@ -76,38 +81,43 @@ jobs:

- name: Build
run: |
CC=${{matrix.config.cc}} CXX=${{matrix.config.cxx}} ninja
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 }}/clang-tidy-result

mkdir ${{ runner.workspace }}/results

- name: Setup tmate session
uses: mxschmitt/action-tmate@v3

- 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
#run-clang-tidy -p ../build -fix
cd avogadrolibs
pwd
echo "Generating diff"
git diff >${{ runner.workspace }}/clang-tidy-result/tidy.patch
git diff >${{ runner.workspace }}/results/tidy.patch
working-directory: ${{ runner.workspace }}/avogadrolibs

- name: Save PR metadata
run: |
echo ${{ github.event.number }} > ${{ runner.workspace }}/clang-tidy-result/pr-id.txt
echo ${{ github.event.pull_request.head.repo.full_name }} > ${{ runner.workspace }}/clang-tidy-result/pr-head-repo.txt
echo ${{ github.event.pull_request.head.ref }} > ${{ runner.workspace }}/clang-tidy-result/pr-head-ref.txt
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: clang-tidy-result
path: ${{ runner.workspace }}/clang-tidy-result/

- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
name: results
path: ${{ runner.workspace }}/results/
Loading