Skip to content

Commit

Permalink
Update clang-format and apply clazy diff
Browse files Browse the repository at this point in the history
Signed-off-by: Geoff Hutchison <[email protected]>
  • Loading branch information
ghutchis committed Dec 30, 2024
1 parent 2f5e353 commit aa73d33
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
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
34 changes: 20 additions & 14 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ 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 @@ -33,7 +35,7 @@ jobs:
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 clazy
sudo apt-get -qq install clang-tidy clang-tools clazy
- name: Install Qt
uses: jurplel/install-qt-action@v3
Expand Down Expand Up @@ -61,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 @@ -77,7 +81,7 @@ 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
Expand All @@ -86,29 +90,31 @@ jobs:

- name: Create results directory
run: |
mkdir ${{ runner.workspace }}/clang-tidy-result
mkdir ${{ runner.workspace }}/results
# let's try manually running clazy
- 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: results
path: ${{ runner.workspace }}/results/

0 comments on commit aa73d33

Please sign in to comment.