Skip to content

Commit

Permalink
feat(ci): KDE CI pipelines for linux, android and win32, fix fortify.
Browse files Browse the repository at this point in the history
  • Loading branch information
TallFurryMan committed Mar 17, 2024
1 parent 949f050 commit 75ba288
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 52 deletions.
93 changes: 50 additions & 43 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,76 +1,83 @@
# This YAML recipe builds KStars with INDI support, then runs all tests
# Build dependencies are in packaged into image definition 'docker/Dockerfile'
# As of 202009, two-stage pipeline fails on propagation of artifact from stage build to stage test
# Probably because the upload uses a webdav REST API, and there are many large files in the list
# It uses both KDE CI and custom image until tests are stabilised in the KDE CI image
# Build dependencies for the custom image are packaged into image definition 'docker/Dockerfile'

include:
- project: sysadmin/ci-utilities
file:
- /gitlab-templates/linux.yml
- /gitlab-templates/windows.yml
- /gitlab-templates/android.yml
# - /gitlab-templates/reuse-lint.yml
# - /gitlab-templates/flatpak.yml

# Android CI is not ready yet
android_qt515:
allow_failure: true

stages:
- build
- test
#- test-unstable

image: tallfurryman/kstars-ci:0.12

variables:
CCACHE_BASEDIR: "$CI_PROJECT_DIR"
QT_TEST_TIMEOUT_FUNCTION: "600"
QT_QPA_PLATFORM: "eglfs"
# In order to be cached successfully, the ccache folder must reside *inside* $CI_PROJECT_DIR
CCACHE_DIR: "$CI_PROJECT_DIR/.ccache"

# We cache the ccache folder
cache:
key: "CCACHE-DB-$CI_PROJECT_ID"
paths:
- "${CCACHE_DIR}"
# Unfortunately, cache:when is not available in the KDE version of gitlab
# Impact: we need a first build to succeed before the cache is available on the runner for further builds
# when:
# - always

.build_recipe: &build_recipe
- add-apt-repository --remove ppa:mutlaqja/indinightly
- add-apt-repository ppa:mutlaqja/ppa
- apt update
- apt -y --no-install-recommends install libindi1 libindi-dev libindi-data indi-bin xplanet gsc phd2 libstellarsolver libstellarsolver-dev
- mkdir -p kstars-build
- cd kstars-build
- cmake -GNinja -DCMAKE_BUILD_TYPE=Release .. -DCCACHE_SUPPORT=ON -DBUILD_TESTING=${BUILD_TESTING:-OFF} -DBUILD_DOC=${BUILD_DOC:-OFF}
- ninja -j8 all install
# This is the custom build we use until tests are operational in the KDE CI image
.custom_build:
interruptible: true
image: tallfurryman/kstars-ci:0.12
variables:
CCACHE_BASEDIR: "$CI_PROJECT_DIR"
QT_TEST_TIMEOUT_FUNCTION: "600"
QT_QPA_PLATFORM: "eglfs"
CCACHE_DIR: "$CI_PROJECT_DIR/.ccache"
cache:
key: "CCACHE-DB-$CI_PROJECT_ID"
paths: [ "${CCACHE_DIR}" ]
when: always
before_script:
- du -hs "${CCACHE_DIR}" || mkdir -p "${CCACHE_DIR}"
- add-apt-repository --remove ppa:mutlaqja/indinightly
- add-apt-repository ppa:mutlaqja/ppa
- apt update
- apt -y --no-install-recommends install libindi1 libindi-dev libindi-data indi-bin xplanet gsc phd2 libstellarsolver libstellarsolver-dev
- mkdir -p kstars-build
after_script:
- ccache -s

# Run the build and keep the ccache folder as a fail-fast
build:
stage: build
interruptible: true
extends: .custom_build
only:
- master
- merge_requests
before_script:
- du -hs "${CCACHE_DIR}" || mkdir -p "${CCACHE_DIR}"
script:
- *build_recipe
after_script:
- ccache -s
- cd kstars-build
- cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCCACHE_SUPPORT=ON -DBUILD_TESTING=OFF -DBUILD_DOC=OFF ..
- ninja -j8 all install

# Run the full validation in one step, stable tests that must not fail
# The artifacts take far too much time to propagate from one step to the other
# The cache is unreliable, and only works on the same runner if there is no shared cache - use it for ccache instead
# Consolidate runner with build packages and build
build-and-test-stable:
stage: test
interruptible: true
extends: .custom_build
timeout: 3 hours
only:
- merge_requests
variables:
BUILD_TESTING: "ON"
before_script:
- *build_recipe
script:
- cd kstars-build
- cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCCACHE_SUPPORT=ON -DBUILD_TESTING=ON -DBUILD_DOC=ON ..
- ninja -j8 all install
- rm -rf Testing
- mkdir -p /var/run/dbus
- dbus-daemon --config-file=/usr/share/dbus-1/system.conf --print-address
- dbus-send --system --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNames
- apt install -y --no-install-recommends dbus-x11
- export $(dbus-launch)
- dbus-send --session --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNames
- dbus-send --session --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNames
- xvfb-run ctest -T test -L stable -LE unstable --output-on-failure
after_script:
- pwd
Expand Down Expand Up @@ -109,7 +116,7 @@ build-and-test-stable:
# reports:
# junit:
# ./junit_result.unstable.xml

#
# build-appimage:
# stage: test
# interruptible: true
Expand All @@ -131,4 +138,4 @@ build-and-test-stable:
# expire_in: 1 week
# paths:
# - 'kstars-build/*.AppImage*'

#
31 changes: 31 additions & 0 deletions .kde-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SPDX-FileCopyrightText: 2024 Eric Dejouhanet <[email protected]>
# SPDX-License-Identifier: GPL-2.0-or-later

Dependencies:
- 'on': ['@all']
'require':
'frameworks/extra-cmake-modules': '@stable'
'frameworks/kconfig': '@stable'
'frameworks/kguidaddons': '@stable'
'frameworks/ki18n': '@stable'
'frameworks/kplotting': '@stable'

- 'on': ['Linux','Windows']
'require':
'frameworks/breeze-icons': '@stable'
'frameworks/kcrash': '@stable'
'frameworks/kdoctools': '@stable'
'frameworks/kinit': '@stable'
'frameworks/knewstuff': '@stable'
'frameworks/knotifications': '@stable'
'frameworks/knotifyconfig': '@stable'
'frameworks/kxmlgui': '@stable'

#- 'on': ['Android']
# 'require':

Options:
in-source-build: False
setup-dbus-session: True
setup-x-environment: True
cmake-options: --trace-expand --debug-find
15 changes: 12 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ endif ()
MACRO_BOOL_TO_01(INDI_FOUND HAVE_INDI)
set_package_properties(INDI PROPERTIES DESCRIPTION "Astronomical instrumentation control" URL "https://www.indilib.org" TYPE OPTIONAL PURPOSE "Support for controlling astronomical devices on Linux with KStars.")

if (INDI_FOUND AND NOT ANDROID)
if (NOT ANDROID)
find_package(StellarSolver REQUIRED 2.2)
endif(INDI_FOUND AND NOT ANDROID)
endif(NOT ANDROID)
MACRO_BOOL_TO_01(StellarSolver_FOUND HAVE_STELLARSOLVER)

find_package(Nova)
Expand Down Expand Up @@ -297,7 +297,16 @@ endif ()

# Add security (hardening flags)
IF (UNIX OR APPLE OR ANDROID)
SET(SEC_COMP_FLAGS "-D_FORTIFY_SOURCE=2 -fstack-protector-all -Wcast-align -fPIE")
SET(SEC_COMP_FLAGS "${SEC_COMP_FLAGS} -fstack-protector-all -Wcast-align -fPIE")
# This is ill-defined, but I searched for a solution for quite a long time to no avail
# - FORTIFY_SOURCE generates a warning when there is no code optimization, and warnings will become errors at some point
# - Checking the build type in CMakeLists.txt is a bad practice, it is better to use generator expressions when importing targets
# - CMake modules do not expand cmake generator expressions when testing for a system/compiler feature
# - Testing CMAKE_BUILD_TYPE does not work well with multi-configuration generators, but those do not fill CMAKE_BUILD_TYPE
# - The "right" way to write this is "$<$<NOT:$<CONFIG:Debug>>:-D_FORTIFY_SOURCE=2>", but it fails the build configuration
IF (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(SEC_COMP_FLAGS "${SEC_COMP_FLAGS} -D_FORTIFY_SOURCE=2")
ENDIF (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
IF (NOT ANDROID AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT APPLE)
SET(SEC_COMP_FLAGS "${SEC_COMP_FLAGS} -Wa,--noexecstack")
ENDIF ()
Expand Down
21 changes: 15 additions & 6 deletions kstars/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ endif ()
if (NOT ANDROID)
find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIR})
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
endif ()

Expand Down Expand Up @@ -179,7 +180,6 @@ if (INDI_FOUND)
ekos/auxiliary/buildfilteroffsets.ui
ekos/auxiliary/opslogs.ui
ekos/auxiliary/serialportassistant.ui
ekos/auxiliary/stellarsolverprofileeditor.ui
ekos/auxiliary/darklibrary.ui
ekos/auxiliary/opticaltrains.ui
ekos/auxiliary/ledstatuswidget.ui
Expand Down Expand Up @@ -221,9 +221,6 @@ if (INDI_FOUND)
ekos/auxiliary/tabledelegate.cpp
ekos/auxiliary/opslogs.cpp
ekos/auxiliary/rotatorutils.cpp
ekos/auxiliary/stellarsolverprofileeditor.cpp
ekos/auxiliary/stellarsolverprofile.cpp
ekos/auxiliary/solverutils.cpp
ekos/auxiliary/serialportassistant.cpp
ekos/auxiliary/portselector.cpp
ekos/auxiliary/ledstatuswidget.cpp
Expand Down Expand Up @@ -438,6 +435,16 @@ if (CFITSIO_FOUND)
fitsviewer/fitsstretchui.ui
fitsviewer/opsfits.ui
)
set (ekos_SRCS
${ekos_SRCS}
ekos/auxiliary/stellarsolverprofileeditor.cpp
ekos/auxiliary/stellarsolverprofile.cpp
ekos/auxiliary/solverutils.cpp
)
set (ekosui_SRCS
${ekosui_SRCS}
ekos/auxiliary/stellarsolverprofileeditor.ui
)
include_directories(${CFITSIO_INCLUDE_DIR})

endif(CFITSIO_FOUND)
Expand Down Expand Up @@ -1301,6 +1308,10 @@ IF (NOT ANDROID)
target_link_libraries(KStarsLib KF5::NotifyConfig)
endif(KF5NotifyConfig_FOUND)

if (StellarSolver_FOUND)
target_link_libraries(KStarsLib StellarSolver::stellarsolver)
endif(StellarSolver_FOUND)

if(NOT WIN32)
target_link_libraries(KStarsLib m)
endif(NOT WIN32)
Expand Down Expand Up @@ -1357,8 +1368,6 @@ if(INDI_FOUND)
## Android: Requires INDI Qt5 Client built for Android
if (NOT ANDROID)
target_link_libraries(KStarsLib ${CMAKE_THREAD_LIBS_INIT})
# StellarSolver
target_link_libraries(KStarsLib StellarSolver::stellarsolver)
endif ()

if(WIN32 OR ANDROID)
Expand Down

0 comments on commit 75ba288

Please sign in to comment.