Skip to content
Open
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
76 changes: 76 additions & 0 deletions .github/tidy-summary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# AUI Framework - Declarative UI toolkit for modern C++20
# Copyright (C) 2020-2024 Alex2772 and Contributors
#
# SPDX-License-Identifier: MPL-2.0
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

"""

This script is run on CI/CD. It runs cmake build and then parses the build log to count occurrences of each diagnostic
and prints them in descending order. It is handy to identify which diagnostic rules are causing issues and adjust the
build configuration accordingly. It is also useful to track the progress of fixing these issues over time.

"""


import re
import subprocess
import sys
from pathlib import Path

REGEX_DIAGNOSTIC = re.compile(r'.+ \[([a-zA-Z0-9-]+)(,.+)?\]$')
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'


if __name__ == '__main__':
if not Path('CMakeCache.txt').is_file():
raise RuntimeError('This script should be run inside preconfigured CMake build directory.')

# In .clang-tidy, we've disabled WarningsAsErrors. So, we need to ensure we are building all the files to capture
# all problems.
if subprocess.run("cmake --build . -t clean", shell=True).returncode != 0:
exit(-1)

cmake_process = subprocess.Popen("cmake --build .", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
cmake_process.stdout.readline()

def lines(pipe):
while True:
l = pipe.readline()
if not l:
return
l = l.decode('utf-8').rstrip('\n')
print(l)
yield l

count = {}
for line in lines(cmake_process.stdout):
line = line.strip()
if m := REGEX_DIAGNOSTIC.match(line):
diagnostic_name = m.group(1)
if diagnostic_name.startswith("-W"):
# TODO unskip warnings
continue

count[diagnostic_name] = count.get(diagnostic_name, 0) + 1

count_as_list = count.items()
print('Sorted by count:')
for i in sorted(count_as_list, key=lambda x: x[1], reverse=True):
print(f"{i[0]}: {i[1]}")

print('')
print('Sorted by name:')
for i in sorted(count_as_list, key=lambda x: x[0]):
print(f"{i[0]}: {i[1]}")

print('')
total = sum(count.values())
print(f'Total: {total}')
if total > 0:
exit(-1)


167 changes: 167 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
name: Build

on:
push:
branches:
- master
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
GIT_SUBMODULE_STRATEGY: recursive

permissions:
contents: write

jobs:
build-desktop:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- name: Fetch sources
uses: actions/checkout@v4

# Cache AUI boot directory
- name: Cache AUI.BOOT deps
id: cache-aui-boot
uses: actions/cache@v3
env:
cache-name: aui-boot
with:
path: ~/.aui
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: brew install cmake ninja

- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install \
pkg-config \
libglew-dev \
zlib1g-dev \
libssl-dev \
libcrypt-dev \
libcurl4-openssl-dev \
libgtk-4-dev \
libadwaita-1-dev \
libdbus-1-dev \
libfontconfig-dev \
ninja-build \
libpulse-dev \

- name: Install dependencies (Windows)
if: runner.os == 'Windows'
run: choco install innosetup

- name: Setup Clang 22 (Linux)
if: runner.os == 'Linux'
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 22 all
echo "CC=clang-22" >> $GITHUB_ENV
echo "CXX=clang++-22" >> $GITHUB_ENV

- name: Setup Clang (Windows)
if: runner.os == 'Windows'
run: |
choco install llvm -y
echo "CC=clang" >> $env:GITHUB_ENV
echo "CXX=clang++" >> $env:GITHUB_ENV

- name: Configure CMake
run: cmake -G "Ninja" -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=RelWithDebInfo ${{ runner.os == 'Windows' && '-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded' || '' }} -DAUI_INSTALL_RUNTIME_DEPENDENCIES=TRUE

- name: Build Project
run: cmake --build ${{github.workspace}}/build --config RelWithDebInfo

- name: Build Tests
run: cmake --build ${{github.workspace}}/build --config RelWithDebInfo --target Tests

- name: Run Tests (Windows)
if: runner.os == 'Windows'
working-directory: ${{github.workspace}}/build/bin
run: ${{github.workspace}}/build/bin/Tests.exe

- name: Run Tests (Linux and macOS)
if: runner.os != 'Windows'
working-directory: ${{github.workspace}}/build/bin
run: ${{github.workspace}}/build/bin/Tests

- name: Pack Windows Setup
if: runner.os == 'Windows'
working-directory: ${{github.workspace}}/build
run: |
cmake . -DAUI_APP_PACKAGING=INNOSETUP
cmake --build . --config RelWithDebInfo
cpack . -CRelWithDebInfo -B artifacts

- name: Pack Portable
working-directory: ${{github.workspace}}/build
run: |
cmake . -DAUI_APP_PACKAGING=${{ runner.os == 'Linux' && 'AUI_PORTABLE_TGZ' || 'AUI_PORTABLE_ZIP' }}
cmake --build . --config RelWithDebInfo
cpack . -CRelWithDebInfo -B artifacts

- name: Upload
uses: actions/upload-artifact@v4
with:
path: ${{github.workspace}}/build/artifacts/*.*
name: ${{ runner.os }}


release-draft:
runs-on: ubuntu-latest
permissions: write-all
if: github.event_name != 'pull_request'
needs: [ build-desktop ]
name: "Release draft"
steps:
- name: Fetch sources
uses: actions/checkout@v4

- name: Extract version
run: |
VERSION=$(grep -Po '[0-9\.]+(?= # CI_PROJECT_VERSION)' CMakeLists.txt)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION = $VERSION"

# Remove old release drafts
- name: Remove Old Release Drafts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/{owner}/{repo}/releases \
--jq '.[] | select(.draft == true) | .id' \
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}

- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: 'true'

- name: Create Release Draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "v${{ env.VERSION }}" \
--draft \
--title "v${{ env.VERSION }}" \
--target $GITHUB_SHA \
artifacts/*.*
101 changes: 101 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Code Quality

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
GIT_SUBMODULE_STRATEGY: recursive

permissions:
contents: write

jobs:
clang-tidy:
name: clang-tidy
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install \
libc++-dev \
clang \
pkg-config \
libglew-dev \
zlib1g-dev \
libssl-dev \
libcrypt-dev \
libcurl4-openssl-dev \
libgtk-4-dev \
libadwaita-1-dev \
libdbus-1-dev \
libfontconfig-dev \
ninja-build \
libpulse-dev \

- name: clang-tidy verify config
run: bash -c 'OUT=$(clang-tidy --dump-config 2>&1); echo "$OUT"; if echo "$OUT" | grep -q "error:"; then exit -1; fi'

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake -GNinja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DAUI_IGNORE_OPENSSL=TRUE -DCMAKE_CXX_CLANG_TIDY=/usr/bin/clang-tidy -DCMAKE_CXX_FLAGS="-stdlib=libc++ -std=c++20" ${{ matrix.compiler }}

- name: Run tidy
# Build your program with the given configuration
run: cd build && python3 ../.github/tidy-summary.py

valgrind:
name: valgrind
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install \
valgrind \
pkg-config \
libglew-dev \
zlib1g-dev \
libssl-dev \
libcrypt-dev \
libcurl4-openssl-dev \
libgtk-4-dev \
libadwaita-1-dev \
libdbus-1-dev \
libfontconfig-dev \
ninja-build \
libpulse-dev \


- name: Configure CMake asan
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -GNinja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DAUI_IGNORE_OPENSSL=TRUE -DAUI_ENABLE_DEATH_TESTS=FALSE

- name: Build project asan
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config Debug

- name: Build AUI tests asan
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config Debug --target Tests

- name: Run AUI tests asan
working-directory: ${{github.workspace}}/build/bin
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
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ option(BUILD_SHARED_LIBS OFF)
set(AUI_VERSION b5186aaf5f78ad6756c04aad3992ac8d3a07d319)

# Use AUI.Boot
#file(
# DOWNLOAD
# https://raw.githubusercontent.com/aui-framework/aui/${AUI_VERSION}/aui.boot.cmake
# ${CMAKE_CURRENT_BINARY_DIR}/aui.boot.cmake)
file(
DOWNLOAD
https://raw.githubusercontent.com/aui-framework/aui/7aac4a2b15238bbf7d25fcf029e914dbc1f02413/aui.boot.cmake
${CMAKE_CURRENT_BINARY_DIR}/aui.boot.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/aui.boot.cmake)

set(AUI_COROUTINES "Use C++20 coroutines" ON)
Expand Down
Loading