Skip to content

Commit

Permalink
Merge pull request #49 from silicon-heaven/ci-add-wasm
Browse files Browse the repository at this point in the history
CI: Multiple improvements
  • Loading branch information
fvacek authored Apr 18, 2024
2 parents f05bbe7 + ae3d144 commit 120cb86
Show file tree
Hide file tree
Showing 45 changed files with 245 additions and 158 deletions.
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
HeaderFilterRegex: .*
Checks:
-*,
cppcoreguidelines-*,
Expand All @@ -16,9 +17,11 @@ Checks:
-bugprone-suspicious-missing-comma,
-clang-analyzer-core.UndefinedBinaryOperatorResult,
-clang-analyzer-cplusplus.NewDeleteLeaks,
-clang-analyzer-cplusplus.NewDelete,
-clang-analyzer-optin.cplusplus.VirtualCall,
-clang-analyzer-security.FloatLoopCounter,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-explicit-virtual-functions,
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/appimage/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ runs:
shell: bash

- name: Upload AppImage
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: shvspy-${{ env.VERSION }}-x86_64.Appimage
path: shvspy-*-x86_64.AppImage
38 changes: 24 additions & 14 deletions .github/actions/cmake/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ inputs:
qt_version:
description: "Specify Qt version to use"
required: true
default: "6.5.3"
qt_arch:
description: "Specify Qt version to use"
description: "Specify Qt arch to use"
default: "gcc_64"
use_qt6:
description: "Specify whether we're using Qt 5 or Qt 6"
Expand All @@ -21,9 +22,9 @@ runs:
using: "composite"
steps:
# Linux deps
- name: Install/cache clazy, ninja, openldap, doctest libfuse, and Qt's dependencies
- name: Install apt packages
if: runner.os != 'Windows'
uses: awalsh128/cache-apt-pkgs-action@v1.3.0
uses: awalsh128/cache-apt-pkgs-action@v1.4.2
with:
packages: ninja-build libgl1-mesa-dev libpulse-dev libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-shape0 libxcb-util1 libxcb-xinerama0 libxkbcommon-x11-0 libxcb-cursor-dev clazy libfuse-dev
version: 1.0
Expand All @@ -45,6 +46,15 @@ runs:
arch: ${{ inputs.qt_arch }}
install-deps: false
modules: ${{ inputs.modules }}
extra: --autodesktop

- name: WASM-specific stuff
if: inputs.qt_arch == 'wasm_singlethread'
run: |
chmod +x "${Qt6_DIR}/bin/qt-cmake"
echo cmake_extra_args="'-DBUILD_SHARED_LIBS=OFF' '-DQT_HOST_PATH=$(realpath "${Qt6_DIR}/../gcc_64")'" >> "$GITHUB_ENV"
echo CMAKE_BIN="${Qt6_DIR}/bin/qt-cmake" >> "$GITHUB_ENV"
shell: bash

- name: ccache
uses: hendrikmuhs/[email protected]
Expand All @@ -55,15 +65,15 @@ runs:
run: |
CFLAGS="-Werror ${CFLAGS}" \
CXXFLAGS="-Werror ${CXXFLAGS}" \
cmake \
-S '${{github.workspace}}' \
-B '${{github.workspace}}/build' \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=OFF \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DSHVSPY_USE_QT6=${{ inputs.use_qt6 }} \
${{ env.cmake_extra_args }} \
${{ inputs.additional_cmake_args }}
"${CMAKE_BIN:-cmake}" \
-S '${{github.workspace}}' \
-B '${{github.workspace}}/build' \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=OFF \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DSHVSPY_USE_QT6=${{ inputs.use_qt6 }} \
${{ env.cmake_extra_args }} \
${{ inputs.additional_cmake_args }}
shell: bash
37 changes: 24 additions & 13 deletions .github/actions/run-linter/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ runs:
CC: clang-15
CXX: clang++-15
with:
qt_version: 6.5.0
qt_version: 6.5.3
use_qt6: ON
modules: qtserialport qtwebsockets qtnetworkauth
additional_cmake_args: -DCMAKE_GLOBAL_AUTOGEN_TARGET=ON -DCMAKE_AUTOGEN_ORIGIN_DEPENDS=OFF
Expand All @@ -24,24 +24,35 @@ runs:
with:
os: ubuntu-latest

- name: Install ctcache
run: |
CTCACHE_REF=e70da77cb867d74ccadce3f3c5862fc9cf4d22a7
curl --location "https://github.com/matus-chochlik/ctcache/archive/${CTCACHE_REF}.tar.gz" | tar --extract --to-stdout --gzip --file - "ctcache-${CTCACHE_REF}/clang-tidy-cache" | sudo tee /usr/bin/clang-tidy-cache > /dev/null
sudo chmod +x /usr/bin/clang-tidy-cache
echo CTCACHE_DIR='${{github.workspace}}/.ctcache' >> "$GITHUB_ENV"
shell: bash

- name: Generate timestamp
run: echo "NOW=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")" >> $GITHUB_ENV
shell: bash

- name: Setup clang-tidy cache
uses: actions/cache@v4
with:
key: ctcache-${{ github.job }}-${{ env.NOW }}
path: ${{github.workspace}}/.ctcache
restore-keys: ctcache-${{ github.job }}-

- name: Build autogenerated stuff
shell: bash
run: cmake --build ${{github.workspace}}/build --parallel "$(nproc)" --target autogen

- name: Copy compile_commands.json
- name: Mark generated files as system
shell: bash
run: cp build/compile_commands.json compile_commands.json
run: sed -i "s@-I$(pwd)/build@-isystem $(pwd)/build@" build/compile_commands.json

- name: Run the linter
shell: bash
run: |
BASE_REF="${{github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before}}"
git fetch --depth=1 origin "$BASE_REF"
readarray -t CHANGED_FILES < <(git diff --name-only "$BASE_REF" | grep 'cpp$')
if [[ "${#CHANGED_FILES[@]}" -eq 0 ]]; then
echo "No changed cpp files."
exit 0
fi
echo "Changed files:"
printf '%s\n' "${CHANGED_FILES[@]}"
printf '%s\n' "${CHANGED_FILES[@]}" | parallel --verbose --jobs "$(nproc)" --plus _=[{#}/{##}] ${{ inputs.lint_program_with_args }} {}
readarray -t FILES < <(find '${{github.workspace}}' -name \*.cpp | grep -v 3rdparty/ | grep -v build/ | grep -v emsdk-cache/)
printf '%s\n' "${FILES[@]}" | parallel --verbose --jobs "$(nproc)" --plus _=[{#}/{##}] ${{ inputs.lint_program_with_args }} {}
7 changes: 3 additions & 4 deletions .github/workflows/appimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ on:

jobs:
ubuntu-qt6:
name: Qt 6.5.0 / Ubuntu 22.04
name: Qt 6.5.3 / Ubuntu 22.04
runs-on: ubuntu-22.04
steps:
- name: Clone the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true

- name: Setup CMake
uses: ./.github/actions/cmake
with:
qt_version: 6.5.0
use_qt6: ON
modules: qtserialport qtwebsockets qtnetworkauth
additional_cmake_args: -DCMAKE_INSTALL_PREFIX='${{ github.workspace }}/install/usr'
Expand All @@ -40,7 +39,7 @@ jobs:
CXXFLAGS: -Wno-stringop-overflow
steps:
- name: Clone the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true

Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ on:

jobs:
windows:
name: Qt 6.5.0 / Windows
name: Qt 6.5.3 / Windows
runs-on: windows-2022
steps:
- name: Clone the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true

- name: Setup CMake
uses: ./.github/actions/cmake
with:
qt_version: 6.5.0
qt_arch: win64_mingw
use_qt6: ON
modules: qtserialport qtwebsockets qtnetworkauth
Expand All @@ -36,9 +35,7 @@ jobs:
run: cmake --install '${{ github.workspace }}/build'

- name: Run windeployqt
# --no-translations is needed because https://bugreports.qt.io/browse/QTBUG-112204
# FIXME: Remove when 6.5.1 becomes available.
run: windeployqt --no-translations -websockets -serialport '${{ github.workspace }}/install/bin/shvspy.exe'
run: windeployqt -websockets -serialport '${{ github.workspace }}/install/bin/shvspy.exe'

- name: Copy MinGW runtime libraries
# windeployqt is unable to copy those, because it looks for them next to where g++.exe is. On the GitHub runner,
Expand All @@ -54,7 +51,7 @@ jobs:
run: iscc "-DBUILD_DIR=${{ github.workspace }}/install" "-DVERSION=${{ env.VERSION }}" shvspy/shvspy.iss

- name: Upload installer
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: shvspy-${{ env.VERSION }}-setup.exe
path: ${{ github.workspace }}/install/_inno/shvspy/shvspy-*-setup.exe
8 changes: 4 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Clone the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true

- name: Run clang-tidy
uses: ./.github/actions/run-linter
with:
lint_program_with_args: clang-tidy-15 --quiet --warnings-as-errors=*
lint_program_with_args: clang-tidy-cache clang-tidy-15 -p build --quiet --warnings-as-errors=*

clazy:
name: clazy / Ubuntu 22.04
runs-on: ubuntu-22.04
steps:
- name: Clone the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true

- name: Run clazy
uses: ./.github/actions/run-linter
with:
lint_program_with_args: clazy-standalone --checks=level1,no-fully-qualified-moc-types,no-non-pod-global-static
lint_program_with_args: clang-tidy-cache clazy-standalone -p build --checks=level1,no-fully-qualified-moc-types,no-non-pod-global-static
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
name: Qt 6.6.2 / NixOS
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Nix
uses: cachix/install-nix-action@v20
uses: cachix/install-nix-action@v26
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Build
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/webassembly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: WebAssembly

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

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
id-token: write
pages: write

env:
emsdk_cache_dir: "emsdk-cache"

jobs:
ubuntu-qt6-wasm:
name: Qt 6.6.3 / Ubuntu 22.04
runs-on: ubuntu-22.04
steps:
- name: Clone the repository
uses: actions/checkout@v4
with:
submodules: true

- name: Setup emsdk cache
uses: actions/cache@v4
with:
key: emsdk-cache
path: ${{ env.emsdk_cache_dir }}

- uses: mymindstorm/setup-emsdk@v14
with:
version: 3.1.37
actions-cache-folder: ${{ env.emsdk_cache_dir }}

- name: Setup CMake
uses: ./.github/actions/cmake
with:
qt_version: 6.6.3
qt_arch: wasm_singlethread
use_qt6: ON
modules: qtwebsockets

- name: Build
run: cmake --build '${{github.workspace}}/build' --parallel "$(nproc)"
shell: bash

- name: Consolidate WebAssembly artifacts
run: |
mkdir gh-sources
cp '${{github.workspace}}'/build/shvspy/*.{js,wasm,html} gh-sources/
mv gh-sources/shvspy.html gh-sources/index.html
cp '${{github.workspace}}'/distro/shvspy.AppDir/shvspy.svg gh-sources/qtlogo.svg
shell: bash

- name: Setup Pages
uses: actions/configure-pages@v5

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'gh-sources/'

- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/master'
uses: actions/deploy-pages@v4
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if(SHVSPY_USE_LOCAL_LIBSHV)
else()
set(WITH_BROKER OFF CACHE BOOL "")
set(LIBSHV_USE_QT6 "${SHVSPY_USE_QT6}" CACHE BOOL "")
add_subdirectory(3rdparty/libshv)
add_subdirectory(3rdparty/libshv SYSTEM)
endif()

if(NOT TARGET libshv::libshvvisu)
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Qt GUI tool for shvbroker administration and browsing

<img width="922" alt="image" src="https://user-images.githubusercontent.com/4949019/115882642-3dba7900-a44d-11eb-9769-630631d70f24.png">

## ShvSpy in the web browser
ShvSpy for the browser is available at https://silicon-heaven.github.io/shvspy.

## Graph view short-cuts
| short-cut | action |
|-----------|--------|
Expand Down
2 changes: 1 addition & 1 deletion shvspy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ qt_add_executable(shvspy
config/config.qrc
)

if(USE_QT6 AND NOT EMSCRIPTEN)
if(SHVSPY_USE_QT6 AND NOT EMSCRIPTEN)
target_link_libraries(shvspy PRIVATE libshv::libshvvisu Qt::NetworkAuth)
target_compile_definitions(shvspy PRIVATE "WITH_AZURE_SUPPORT")
else()
Expand Down
6 changes: 3 additions & 3 deletions shvspy/src/accessmodel/accessitemdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ QWidget *AccessItemDelegate::createEditor(QWidget *parent, const QStyleOptionVie
Q_UNUSED(option);
Q_UNUSED(index);

QLineEdit *editor = new QLineEdit(parent);
auto *editor = new QLineEdit(parent);
return editor;
}

void AccessItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
QLineEdit *e = qobject_cast<QLineEdit*>(editor);
auto *e = qobject_cast<QLineEdit*>(editor);
if (index.isValid() && e) {
std::string val = e->text().trimmed().toStdString();

if (index.column() == AccessModel::Columns::ColAccess) {
if (index.column() == AccessModel::Columns::ColAccess) {
std::string err;
shv::chainpack::RpcValue rv = shv::chainpack::RpcValue::fromCpon(val, &err);
if (!err.empty()) {
Expand Down
Loading

0 comments on commit 120cb86

Please sign in to comment.