From 0cc4ab7f17d43d625fa62813669a99735a45d156 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Thu, 30 Apr 2020 19:27:27 -0400 Subject: [PATCH 1/2] Add gitlab ci --- .ci/macos/Brewfile | 9 ++ .ci/script.sh | 1 + .ci/upload-nightly-gitlab.sh | 9 ++ .gitlab-ci.yml | 136 +++++++++++++++++++++++++++++++ CMakeLists.txt | 4 +- io.github.NhekoReborn.Nheko.json | 1 - src/Olm.cpp | 4 +- src/Utils.cpp | 2 +- 8 files changed, 160 insertions(+), 6 deletions(-) create mode 100644 .ci/macos/Brewfile create mode 100755 .ci/upload-nightly-gitlab.sh create mode 100644 .gitlab-ci.yml diff --git a/.ci/macos/Brewfile b/.ci/macos/Brewfile new file mode 100644 index 00000000..c32360ee --- /dev/null +++ b/.ci/macos/Brewfile @@ -0,0 +1,9 @@ +tap "nlohmann/json" + +brew "clang-format" +brew "cmake" +brew "ninja" +brew "openssl" +brew "qt5" +brew "python3" +brew "nlohmann_json" \ No newline at end of file diff --git a/.ci/script.sh b/.ci/script.sh index f43a6efb..63e7f135 100755 --- a/.ci/script.sh +++ b/.ci/script.sh @@ -71,6 +71,7 @@ cmake -GNinja -H. -Bbuild \ -DHUNTER_ROOT=".hunter" \ -DHUNTER_ENABLED=ON -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHUNTER_CONFIGURATION_TYPES=RelWithDebInfo \ + -DUSE_BUNDLED_OPENSSL=OFF \ -DCI_BUILD=ON fi cmake --build build diff --git a/.ci/upload-nightly-gitlab.sh b/.ci/upload-nightly-gitlab.sh new file mode 100755 index 00000000..c08857c1 --- /dev/null +++ b/.ci/upload-nightly-gitlab.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +file="$1" +fileName="nheko-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}-${file##*-}" + +uri=$(curl -H "Authorization: Bearer ${MATRIX_ACCESS_TOKEN}" -H "Content-Type: application/x-compressed" -X POST --data-binary "@${file}" "https://matrix.neko.dev/_matrix/media/r0/upload?filename=${fileName}" --http1.1 | python -c "import sys, json; print(json.load(sys.stdin)['content_uri'])") +echo "Uploaded to ${uri}" + +curl -H "Authorization: Bearer ${MATRIX_ACCESS_TOKEN}" -H "Content-Type: application/json" -X PUT -d "{ \"body\": \"${fileName}\", \"filename\": \"${fileName}\", \"info\": { \"mimetype\": \"application/x-compressed\", \"size\": $(wc -c < ${file}) }, \"msgtype\": \"m.file\", \"url\": \"${uri}\" }" "https://matrix.neko.dev/_matrix/client/r0/rooms/${ROOM}/send/m.room.message/$(date +%s)" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..385bcd92 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,136 @@ +variables: + CCACHE_COMPILERCHECK: content + CCACHE_DIR: "${CI_PROJECT_DIR}/.ccache" + # prevent configure tzdata hanging apt install commands + DEBIAN_FRONTEND: noninteractive + +build-gcc7: + stage: build + image: ubuntu:16.04 + tags: [docker] + variables: + CXX: g++-7 + CC: gcc-7 + QT_PKG: 510 + TRAVIS_OS_NAME: linux + before_script: + - apt-get update + - apt-get install -y software-properties-common + - add-apt-repository ppa:ubuntu-toolchain-r/test -y + - add-apt-repository ppa:beineri/opt-qt-5.10.1-xenial -y + - apt-get update && apt-get -y install --no-install-recommends g++-7 build-essential ninja-build qt${QT_PKG}{base,declarative,tools,multimedia,script,quickcontrols2,svg} liblmdb-dev libgl1-mesa-dev libssl-dev git ccache + # need recommended deps for wget + - apt-get -y install wget + - wget https://github.com/Kitware/CMake/releases/download/v3.19.0/cmake-3.19.0-Linux-x86_64.sh && sh cmake-3.19.0-Linux-x86_64.sh --skip-license --prefix=/usr/local + - /usr/sbin/update-ccache-symlinks + - update-alternatives --install /usr/bin/gcc gcc "/usr/bin/${CC}" 10 + - update-alternatives --install /usr/bin/g++ g++ "/usr/bin/${CXX}" 10 + - update-alternatives --set gcc "/usr/bin/${CC}" + - update-alternatives --set g++ "/usr/bin/${CXX}" + script: + - export PATH="/usr/lib/ccache:${PATH}" + - export CMAKE_BUILD_PARALLEL_LEVEL=$(cat /proc/cpuinfo | awk '/^processor/{print $3}' | wc -l) + - export PATH="/usr/local/bin/:${PATH}" + - . "/opt/qt${QT_PKG}/bin/qt${QT_PKG}-env.sh" || true + - mkdir -p .deps/usr .hunter + - mkdir -p build + - cmake -GNinja -H. -Bbuild + -DCMAKE_INSTALL_PREFIX=.deps/usr + -DHUNTER_ROOT=".hunter" + -DHUNTER_ENABLED=ON -DBUILD_SHARED_LIBS=OFF + -DCMAKE_BUILD_TYPE=Release -DHUNTER_CONFIGURATION_TYPES=Release + -DCI_BUILD=ON + - cmake --build build + cache: + key: "$CI_JOB_NAME" + paths: + - .hunter/ + - .ccache + +build-macos: + stage: build + tags: [macos] + before_script: + - brew update + - brew bundle --file=./.ci/macos/Brewfile + script: + - export PATH=/usr/local/opt/qt/bin/:${PATH} + - export CMAKE_PREFIX_PATH=/usr/local/opt/qt5 + - cmake -GNinja -H. -Bbuild + -DCMAKE_BUILD_TYPE=RelWithDebInfo + -DCMAKE_INSTALL_PREFIX=.deps/usr + -DHUNTER_ROOT=".hunter" + -DHUNTER_ENABLED=ON -DBUILD_SHARED_LIBS=OFF + -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHUNTER_CONFIGURATION_TYPES=RelWithDebInfo + -DUSE_BUNDLED_OPENSSL=ON + -DUSE_BUNDLED_BOOST=ON + -DCI_BUILD=ON + - cmake --build build + cache: + key: "${CI_JOB_NAME}" + paths: + - .hunter/ + - "${CCACHE_DIR}" + +build-flatpak-amd64: + stage: build + image: ubuntu:latest + #image: 'registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master' + tags: [docker] + before_script: + - apt-get update && apt-get -y install flatpak-builder git python curl + - flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + - flatpak --noninteractive install --user flathub org.kde.Platform//5.14 + - flatpak --noninteractive install --user flathub org.kde.Sdk//5.14 + script: + - export VERSION=$(git describe) + - mkdir -p build-flatpak + - cd build-flatpak + - flatpak-builder --user --disable-rofiles-fuse --ccache --repo=repo --default-branch=${CI_COMMIT_REF_NAME} --subject="Build of Nheko ${VERSION} `date`" app ../io.github.NhekoReborn.Nheko.json + - flatpak build-bundle repo nheko-amd64.flatpak io.github.NhekoReborn.Nheko ${CI_COMMIT_REF_NAME} + after_script: + - bash ./.ci/upload-nightly-gitlab.sh build-flatpak/nheko-amd64.flatpak + cache: + key: "$CI_JOB_NAME" + paths: + - build-flatpak/.flatpak-builder/ + artifacts: + expose_as: 'flatpak-amd64' + paths: ['build-flatpak/nheko-amd64.flatpak'] + name: flatpak-${CI_COMMIT_REF_NAME}-${VERSION}-amd64 + +build-flatpak-arm64: + stage: build + image: ubuntu:latest + #image: 'registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master' + tags: [docker-arm64] + before_script: + - apt-get update && apt-get -y install flatpak-builder git python curl + - flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + - flatpak --noninteractive install --user flathub org.kde.Platform//5.14 + - flatpak --noninteractive install --user flathub org.kde.Sdk//5.14 + script: + - export VERSION=$(git describe) + - mkdir -p build-flatpak + - cd build-flatpak + - flatpak-builder --user --disable-rofiles-fuse --ccache --repo=repo --default-branch=${CI_COMMIT_REF_NAME} --subject="Build of Nheko ${VERSION} `date` for arm64" app ../io.github.NhekoReborn.Nheko.json + - flatpak build-bundle repo nheko-arm64.flatpak io.github.NhekoReborn.Nheko ${CI_COMMIT_REF_NAME} + after_script: + - bash ./.ci/upload-nightly-gitlab.sh build-flatpak/nheko-arm64.flatpak + cache: + key: "$CI_JOB_NAME" + paths: + - build-flatpak/.flatpak-builder/ + artifacts: + expose_as: 'flatpak-arm64' + paths: ['build-flatpak/nheko-arm64.flatpak'] + name: flatpak-${CI_COMMIT_REF_NAME}-${VERSION}-arm64 + +linting: + stage: build + image: alpine:latest + tags: [docker] + before_script: + - apk update && apk add clang make git + script: + - make lint diff --git a/CMakeLists.txt b/CMakeLists.txt index e8570c77..d2689a97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,8 +89,8 @@ fix_project_version() # Set additional project information set(COMPANY "Nheko") -set(COPYRIGHT "Copyright (c) 2019 Nheko Contributors") -set(IDENTIFIER "com.github.mujx.nheko") +set(COPYRIGHT "Copyright (c) 2020 Nheko Contributors") +set(IDENTIFIER "io.github.nheko-reborn.nheko") add_project_meta(META_FILES_TO_INCLUDE) diff --git a/io.github.NhekoReborn.Nheko.json b/io.github.NhekoReborn.Nheko.json index cc76a3e9..913e239a 100644 --- a/io.github.NhekoReborn.Nheko.json +++ b/io.github.NhekoReborn.Nheko.json @@ -1,7 +1,6 @@ { "id": "io.github.NhekoReborn.Nheko", "command": "nheko", - "branch": "master", "runtime": "org.kde.Platform", "runtime-version": "5.15", "sdk": "org.kde.Sdk", diff --git a/src/Olm.cpp b/src/Olm.cpp index af8bb512..cdafabf3 100644 --- a/src/Olm.cpp +++ b/src/Olm.cpp @@ -435,8 +435,8 @@ send_key_request_for(mtx::events::EncryptedEvent e, e.content.session_id); mtx::events::msg::KeyRequest request; - request.action = !cancel ? mtx::events::msg::RequestAction::Request - : mtx::events::msg::RequestAction::Cancellation; + request.action = !cancel ? mtx::events::msg::RequestAction::Request + : mtx::events::msg::RequestAction::Cancellation; request.algorithm = MEGOLM_ALGO; request.room_id = e.room_id; request.sender_key = e.content.sender_key; diff --git a/src/Utils.cpp b/src/Utils.cpp index 743c393f..463c8af3 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -638,7 +638,7 @@ utils::luminance(const QColor &col) qreal lumRgb[3]; for (int i = 0; i < 3; i++) { - qreal v = colRgb[i] / 255.0; + qreal v = colRgb[i] / 255.0; v <= 0.03928 ? lumRgb[i] = v / 12.92 : lumRgb[i] = qPow((v + 0.055) / 1.055, 2.4); } From ab7a75a988a3d94d11c8484abfccd238af119d82 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 27 Nov 2020 01:36:48 +0100 Subject: [PATCH 2/2] Update ci flatpak sdk --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 385bcd92..e8523d31 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -80,8 +80,8 @@ build-flatpak-amd64: before_script: - apt-get update && apt-get -y install flatpak-builder git python curl - flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo - - flatpak --noninteractive install --user flathub org.kde.Platform//5.14 - - flatpak --noninteractive install --user flathub org.kde.Sdk//5.14 + - flatpak --noninteractive install --user flathub org.kde.Platform//5.15 + - flatpak --noninteractive install --user flathub org.kde.Sdk//5.15 script: - export VERSION=$(git describe) - mkdir -p build-flatpak @@ -107,8 +107,8 @@ build-flatpak-arm64: before_script: - apt-get update && apt-get -y install flatpak-builder git python curl - flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo - - flatpak --noninteractive install --user flathub org.kde.Platform//5.14 - - flatpak --noninteractive install --user flathub org.kde.Sdk//5.14 + - flatpak --noninteractive install --user flathub org.kde.Platform//5.15 + - flatpak --noninteractive install --user flathub org.kde.Sdk//5.15 script: - export VERSION=$(git describe) - mkdir -p build-flatpak