Skip to content

Commit f52055f

Browse files
committed
u
1 parent 97688eb commit f52055f

File tree

5 files changed

+174
-7
lines changed

5 files changed

+174
-7
lines changed

.clang-tidy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ Checks: >
8585
-modernize-use-using,
8686
8787
88-
WarningsAsErrors: '*'
88+
# we have a pipeline that treats those as errors; during development, it may be too noisy
89+
#WarningsAsErrors: '*'
90+
91+
HeaderFilterRegex: '^.*/src/.*$'
8992

9093
FormatStyle: google
9194
CheckOptions:

.github/tidy-summary.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# AUI Framework - Declarative UI toolkit for modern C++20
2+
# Copyright (C) 2020-2024 Alex2772 and Contributors
3+
#
4+
# SPDX-License-Identifier: MPL-2.0
5+
#
6+
# This Source Code Form is subject to the terms of the Mozilla Public
7+
# License, v. 2.0. If a copy of the MPL was not distributed with this
8+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+
10+
"""
11+
12+
This script is run on CI/CD. It runs cmake build and then parses the build log to count occurrences of each diagnostic
13+
and prints them in descending order. It is handy to identify which diagnostic rules are causing issues and adjust the
14+
build configuration accordingly. It is also useful to track the progress of fixing these issues over time.
15+
16+
"""
17+
18+
19+
import re
20+
import subprocess
21+
import sys
22+
from pathlib import Path
23+
24+
REGEX_DIAGNOSTIC = re.compile(r'.+ \[([a-zA-Z0-9-]+)(,.+)?\]$')
25+
assert REGEX_DIAGNOSTIC.match("/home/AUI/Common/ASmallVector.h:326:5: warning: function 'contains' should be marked [[nodiscard]] [modernize-use-nodiscard,-warnings-as-errors]").group(1) == 'modernize-use-nodiscard'
26+
27+
28+
if __name__ == '__main__':
29+
if not Path('CMakeCache.txt').is_file():
30+
raise RuntimeError('This script should be run inside preconfigured CMake build directory.')
31+
32+
# In .clang-tidy, we've disabled WarningsAsErrors. So, we need to ensure we are building all the files to capture
33+
# all problems.
34+
if subprocess.run("cmake --build . -t clean", shell=True).returncode != 0:
35+
exit(-1)
36+
37+
cmake_process = subprocess.Popen("cmake --build .", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
38+
cmake_process.stdout.readline()
39+
40+
def lines(pipe):
41+
while True:
42+
l = pipe.readline()
43+
if not l:
44+
return
45+
l = l.decode('utf-8').rstrip('\n')
46+
print(l)
47+
yield l
48+
49+
count = {}
50+
for line in lines(cmake_process.stdout):
51+
line = line.strip()
52+
if m := REGEX_DIAGNOSTIC.match(line):
53+
diagnostic_name = m.group(1)
54+
if diagnostic_name.startswith("-W"):
55+
# TODO unskip warnings
56+
continue
57+
58+
count[diagnostic_name] = count.get(diagnostic_name, 0) + 1
59+
60+
count_as_list = count.items()
61+
print('Sorted by count:')
62+
for i in sorted(count_as_list, key=lambda x: x[1], reverse=True):
63+
print(f"{i[0]}: {i[1]}")
64+
65+
print('')
66+
print('Sorted by name:')
67+
for i in sorted(count_as_list, key=lambda x: x[0]):
68+
print(f"{i[0]}: {i[1]}")
69+
70+
print('')
71+
total = sum(count.values())
72+
print(f'Total: {total}')
73+
if total > 0:
74+
exit(-1)
75+
76+

.github/workflows/build.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,26 @@ jobs:
5555
- name: Configure CMake
5656
run: cmake -G "${{ matrix.os=='windows-latest' && 'Visual Studio 17 2022' || 'Ninja' }}" -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=RelWithDebInfo ${{matrix.additional_cmake_flags}} -DAUI_INSTALL_RUNTIME_DEPENDENCIES=TRUE
5757

58-
- name: Configure CPack
58+
- name: Configure CPack (Windows)
5959
if: matrix.os == 'windows-latest'
6060
run: cmake -B ${{github.workspace}}/build -DCPACK_GENERATOR=INNOSETUP
6161

62-
- name: Build project
62+
- name: Configure CPack (Linux)
63+
if: matrix.os == 'ubuntu-latest'
64+
run: cmake -B ${{github.workspace}}/build -DCPACK_GENERATOR=TGZ
65+
66+
- name: Build Project
6367
run: cmake --build ${{github.workspace}}/build --config RelWithDebInfo
6468

65-
- name: Build AUI tests
69+
- name: Build Tests
6670
run: cmake --build ${{github.workspace}}/build --config RelWithDebInfo --target Tests
6771

68-
- name: Run AUI tests
72+
- name: Run Tests (Windows)
6973
if: matrix.os == 'windows-latest'
7074
working-directory: ${{github.workspace}}/build/bin/RelWithDebInfo/
7175
run: ${{github.workspace}}/build/bin/RelWithDebInfo/Tests.exe
7276

73-
- name: Run AUI tests
77+
- name: Run Tests (Linux and macOS)
7478
if: matrix.os == 'ubuntu-latest'
7579
working-directory: ${{github.workspace}}/build/bin
7680
run: ${{github.workspace}}/build/bin/Tests
@@ -79,13 +83,21 @@ jobs:
7983
working-directory: ${{github.workspace}}/build
8084
run: cpack . -CRelWithDebInfo
8185

82-
- name: Upload
86+
- name: Upload (Windows)
8387
if: matrix.os == 'windows-latest'
8488
uses: actions/upload-artifact@v4
8589
with:
8690
path: ${{github.workspace}}/build/*.exe
8791
name: ${{ matrix.os }}
8892

93+
- name: Upload (Linux)
94+
if: matrix.os == 'ubuntu-latest'
95+
uses: actions/upload-artifact@v4
96+
with:
97+
path: ${{github.workspace}}/build/*.gz
98+
name: ${{ matrix.os }}
99+
100+
89101
release:
90102
runs-on: ubuntu-latest
91103
permissions: write-all

.github/workflows/code-quality.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Code Quality
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
env:
14+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
15+
GIT_SUBMODULE_STRATEGY: recursive
16+
17+
permissions:
18+
contents: write
19+
20+
jobs:
21+
clang-tidy:
22+
name: clang-tidy
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
with:
28+
submodules: true
29+
30+
- name: Install Linux dependencies
31+
run: sudo apt-get update && sudo apt-get install pkg-config libglew-dev zlib1g-dev libssl-dev libcrypt-dev libcurl4-openssl-dev libgtk-3-dev libfontconfig-dev ninja-build libpulse-dev clang libc++-dev
32+
33+
- name: clang-tidy verify config
34+
run: bash -c 'OUT=$(clang-tidy --dump-config 2>&1); echo "$OUT"; if echo "$OUT" | grep -q "error:"; then exit -1; fi'
35+
36+
- name: Configure CMake
37+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
38+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
39+
run: CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake -GNinja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=OFF -DAUI_IGNORE_OPENSSL=TRUE -DCMAKE_CXX_CLANG_TIDY=/usr/bin/clang-tidy -DCMAKE_CXX_FLAGS="-stdlib=libc++ -std=c++20"
40+
41+
- name: Run tidy
42+
# Build your program with the given configuration
43+
run: cd build && python3 ../.github/tidy-summary.py
44+
45+
valgrind:
46+
name: valgrind
47+
runs-on: ubuntu-latest
48+
49+
steps:
50+
- uses: actions/checkout@v2
51+
with:
52+
submodules: true
53+
54+
- name: Install Linux dependencies
55+
run: sudo apt-get update && sudo apt-get install pkg-config libglew-dev zlib1g-dev libssl-dev libcrypt-dev libcurl4-openssl-dev libgtk-3-dev libfontconfig-dev ninja-build libpulse-dev valgrind
56+
57+
- name: Configure CMake asan
58+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
59+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
60+
run: cmake -GNinja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DAUI_IGNORE_OPENSSL=TRUE -DAUI_ENABLE_DEATH_TESTS=FALSE
61+
62+
- name: Build project asan
63+
# Build your program with the given configuration
64+
run: cmake --build ${{github.workspace}}/build --config Debug
65+
66+
- name: Build AUI tests asan
67+
# Build your program with the given configuration
68+
run: cmake --build ${{github.workspace}}/build --config Debug --target Tests
69+
70+
- name: Run AUI tests asan
71+
working-directory: ${{github.workspace}}/build/bin
72+
run: valgrind --suppressions=${{github.workspace}}/valgrind_suppressions.supp --error-exitcode=1 --tool=memcheck --leak-check=full --track-origins=yes --gen-suppressions=all ${{github.workspace}}/build/bin/Tests --gtest_filter="-Threading.FutureOn*"

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ automation of building, testing and releasing process.
2323
In the `.github/workflows` directory, you can find definitions for the following GitHub Actions workflows:
2424
- [Build](.github/workflows/build.yml)
2525
- Triggered on `push` and `pull_request` events.
26+
- [Code Quality](.github/workflows/code-quality.yml)
27+
- Triggered on `push` and `pull_request` events.
28+
- Performs `clang-tidy` checks (static analysis) and generates nice summary with `.github/tidy-summary.py`.
29+
- Performs `valgrind` checks on tests (dynamic analysis).
2630

2731

2832
# Code Quality and Formatting

0 commit comments

Comments
 (0)