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
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{cpp,hpp,txt,cmake,json,qrc,ui,ts,yml}]
indent_style = space
indent_size = 4

[*.{yml,qrc,ui}]
indent_size = 2

[Makefile]
indent_style = tab
79 changes: 71 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Static Analysis
name: Build, Test and Static Analysis

on:
push:
Expand All @@ -7,11 +7,13 @@ on:
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
validate-and-package:
ubuntu-apt:
name: Ubuntu (apt)
runs-on: ubuntu-24.04
permissions:
contents: write

steps:
- name: Checkout Source Code
Expand All @@ -24,16 +26,77 @@ jobs:
sudo apt-get update
sudo apt-get install -y \
build-essential cmake \
qt6-base-dev qt6-tools-dev qt6-tools-dev-tools \
qt6-base-dev qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools \
libqt6widgets6 \
cppcheck \
dpkg-dev
cppcheck

- name: Build
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release -DUNIBACKPACK_WERROR=ON
cmake --build build --parallel

- name: Run Tests
run: ctest --test-dir build --output-on-failure

- name: Run cppcheck Static Analysis
run: |
cppcheck --enable=warning,style,performance,portability \
--library=qt \
--suppress=shadowVariable \
--error-exitcode=1 \
src/
-I include \
src/ include/ tests/

arch-pacman:
name: Arch Linux (pacman)
runs-on: ubuntu-24.04
container: archlinux:latest

steps:
- name: Install Build Dependencies
run: pacman -Syu --noconfirm --needed base-devel cmake qt6-base qt6-tools

- name: Checkout Source Code
uses: actions/checkout@v7

- name: Build
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release -DUNIBACKPACK_WERROR=ON
cmake --build build --parallel

- name: Run Tests
run: ctest --test-dir build --output-on-failure

- name: Check Install Layout
run: |
DESTDIR="$PWD/pkg" cmake --install build --prefix /usr
test -x pkg/usr/bin/unibackpack
test -f pkg/usr/share/applications/unibackpack.desktop
test -f pkg/usr/share/icons/hicolor/512x512/apps/unibackpack.png

docs:
name: Documentation (Doxygen)
runs-on: ubuntu-24.04
# Ubuntu's Doxygen is older than the Doxyfile and warns about its tags
container: archlinux:latest

steps:
- name: Install Doxygen
run: pacman -Syu --noconfirm --needed doxygen

- name: Checkout Source Code
uses: actions/checkout@v7

# Fails on any warning, except for parameters and return values without their own
# @param/@return: most functions are documented in one line that names them with @p
- name: Generate Documentation
run: |
( cat Doxyfile
echo "WARN_AS_ERROR = FAIL_ON_WARNINGS"
echo "WARN_NO_PARAMDOC = NO" ) | doxygen -

- name: Upload Documentation
uses: actions/upload-artifact@v7
with:
name: docs-html
path: docs/html
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
.vscode/

# Executable
UniBackpack
*.deb

# Qt files
Expand Down
84 changes: 67 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,98 @@ project(unibackpack VERSION 0.1 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Network LinguistTools)
option(BUILD_TESTING "Build the unit tests" ON)
option(UNIBACKPACK_WERROR "Treat compiler warnings as errors" OFF)

# Applied to every target defined below; Qt's headers are system includes and stay quiet
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
if(UNIBACKPACK_WERROR)
add_compile_options(-Werror)
endif()
endif()

find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets LinguistTools)

set(CMAKE_AUTOMOC ON) # Handles Signals/Slots
set(CMAKE_AUTORCC ON) # Handles .qrc resource files
set(CMAKE_AUTOUIC ON) # Handles .ui files

set(CMAKE_AUTOUIC_SEARCH_PATHS ui)

qt_add_executable(unibackpack
# Source files
src/main.cpp
include(GNUInstallDirs)

# Everything except the widgets, so the tests can link against it
qt_add_library(unibackpack_core STATIC
src/Downloader.cpp
src/MainWindow.cpp
src/utils/applyTranslator.cpp
src/PackageManager.cpp
src/utils/language.cpp
src/utils/loadUniversities.cpp
src/utils/packageList.cpp

# Header files
include/MainWindow.hpp
include/Downloader.hpp
include/utils/applyTranslator.hpp
include/PackageManager.hpp
include/utils/language.hpp
include/utils/loadUniversities.hpp
include/utils/packageList.hpp
)

# UI
ui/MainWindow.ui
target_include_directories(unibackpack_core PUBLIC include)
target_link_libraries(unibackpack_core PUBLIC Qt6::Core)

# Resources
qt_add_executable(unibackpack
src/main.cpp
src/MainWindow.cpp
include/MainWindow.hpp
ui/MainWindow.ui
resources/resources.qrc
)

target_include_directories(unibackpack PRIVATE include)

target_link_libraries(unibackpack PRIVATE
Qt6::Core
unibackpack_core
Qt6::Gui
Qt6::Widgets
Qt6::Network
)

# Every package list under resources/lists/ is embedded as :/lists/<university>/<department>/packages.json
file(GLOB_RECURSE PACKAGE_LISTS CONFIGURE_DEPENDS
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
resources/lists/*.json)
qt_add_resources(unibackpack package_lists
PREFIX "/"
BASE resources
FILES ${PACKAGE_LISTS})

# Strings from the core library are translated too, so lupdate scans its sources as well
get_target_property(CORE_SOURCES unibackpack_core SOURCES)
qt_add_translations(unibackpack
TS_FILES
translations/unibackpack_en.ts
translations/unibackpack_el.ts
SOURCES
${CORE_SOURCES}
src/main.cpp
src/MainWindow.cpp
include/MainWindow.hpp
ui/MainWindow.ui
INCLUDE_DIRECTORIES
include
)

install(TARGETS unibackpack DESTINATION bin)
install(TARGETS unibackpack RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES resources/unibackpack.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
install(FILES resources/icons/unibackpack.png
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/512x512/apps)

if(BUILD_TESTING)
enable_testing()
find_package(Qt6 REQUIRED COMPONENTS Test)

qt_add_executable(tst_package_manager tests/tst_package_manager.cpp)
target_link_libraries(tst_package_manager PRIVATE unibackpack_core Qt6::Test)
# The tests also check the bundled data files, read from the source tree
target_compile_definitions(tst_package_manager PRIVATE
UNIBACKPACK_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
add_test(NAME tst_package_manager COMMAND tst_package_manager)
endif()
15 changes: 4 additions & 11 deletions PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,10 @@ build() {
cmake --build build
}

check() {
ctest --test-dir build --output-on-failure
}

package() {
DESTDIR="$pkgdir" cmake --install build

install -Dm644 "$srcdir/$_pkgname/resources/unibackpack.desktop" \
"$pkgdir/usr/share/applications/unibackpack.desktop"

if [ -f "$srcdir/$_pkgname/resources/icons/unibackpack.png" ]; then
install -Dm644 "$srcdir/$_pkgname/resources/icons/unibackpack.png" \
"$pkgdir/usr/share/pixmaps/unibackpack.png"
else
sed -i 's/^Icon=.*/Icon=system-software-install/' \
"$pkgdir/usr/share/applications/unibackpack.desktop"
fi
}
Loading