diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000000000000000000000000000000000000..f83b5702b7fdfedb1bf81602389b837e215dd5e0 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @hluk diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml new file mode 100644 index 0000000000000000000000000000000000000000..a3c8fae389230bb9dbed0ce29500c84be610ede4 --- /dev/null +++ b/.github/workflows/build-linux.yml @@ -0,0 +1,84 @@ +--- +name: Linux Build + +# yamllint disable-line rule:truthy +on: + - push + - pull_request + +jobs: + build: + name: ${{matrix.buildname}} + runs-on: ${{matrix.os}} + strategy: + matrix: + include: + - os: ubuntu-20.04 + buildname: Linux-GCC + build_type: Debug + compiler: g++ + coverage: true + compiler_flags: >- + --coverage + -fprofile-arcs + -ftest-coverage + -fprofile-abs-path + compiler_package: g++ + + - os: ubuntu-20.04 + buildname: Linux-Clang + build_type: Debug + compiler: clang++ + compiler_package: clang + + steps: + - name: Checkout source code + uses: actions/checkout@v2 + with: + submodules: false + fetch-depth: 1 + + - name: Install dependencies + uses: nick-invision/retry@v2 + with: + timeout_minutes: 10 + retry_wait_seconds: 30 + max_attempts: 3 + command: >- + '${{github.workspace}}/utils/github/install-linux.sh' + '${{matrix.compiler_package}}' + + - name: Build with CMake + uses: lukka/run-cmake@v3 + with: + cmakeListsOrSettingsJson: CMakeListsTxtAdvanced + cmakeListsTxtPath: '${{github.workspace}}/CMakeLists.txt' + cmakeBuildType: Release + cmakeGenerator: Ninja + buildDirectory: '${{runner.workspace}}/build' + cmakeAppendedArgs: >- + -DWITH_TESTS=TRUE + -DPEDANTIC=TRUE + -DCMAKE_BUILD_TYPE='${{matrix.build_type}}' + -DCMAKE_INSTALL_PREFIX='${{runner.workspace}}/install' + -DCMAKE_CXX_FLAGS='${{matrix.compiler_flags}}' + -DCMAKE_C_FLAGS='${{matrix.compiler_flags}}' + -DCMAKE_CXX_COMPILER='${{matrix.compiler}}' + + - name: Install with CMake + run: cmake --install '${{runner.workspace}}/build' + + - name: Create gnupg directory for tests + run: mkdir -p ~/.gnupg + + - name: Run tests + working-directory: '${{runner.workspace}}/install/bin' + run: '${{github.workspace}}/utils/github/test-linux.sh' + + - name: Update coverage + if: matrix.coverage + env: + COVERALLS_REPO_TOKEN: '${{secrets.COVERALLS_REPO_TOKEN}}' + run: >- + '${{github.workspace}}/utils/github/coverage-linux.sh' + '${{runner.workspace}}/build' diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml new file mode 100644 index 0000000000000000000000000000000000000000..5cb722be85e4532c106fb5ca66c81c84be9b03d7 --- /dev/null +++ b/.github/workflows/build-macos.yml @@ -0,0 +1,73 @@ +--- +name: macOS Build + +# yamllint disable-line rule:truthy +on: + - push + - pull_request + +jobs: + build: + name: ${{matrix.buildname}} + runs-on: ${{matrix.os}} + strategy: + matrix: + include: + - os: macos-latest + buildname: macOS + build_type: Release + compiler: clang_64 + create_bundle: true + + env: + qt: '5.15.2' + + steps: + - name: Checkout source code + uses: actions/checkout@v2 + with: + submodules: false + fetch-depth: 1 + + - name: Restore Qt cache + uses: actions/cache@v2 + id: cache-qt + with: + path: ${{runner.workspace}}/Qt/${{env.qt}} + key: ${{matrix.os}}-qt-${{env.qt}}-${{matrix.compiler}} + + - name: Install Qt + uses: jurplel/install-qt-action@v2 + if: steps.cache-qt.outputs.cache-hit != 'true' + with: + version: ${{env.qt}} + dir: ${{runner.workspace}} + cached: ${{steps.cache-qt.outputs.cache-hit}} + + - name: Build with CMake + uses: lukka/run-cmake@v3 + with: + cmakeListsOrSettingsJson: CMakeListsTxtAdvanced + cmakeListsTxtPath: '${{github.workspace}}/CMakeLists.txt' + cmakeBuildType: Release + cmakeGenerator: Ninja + buildDirectory: '${{runner.workspace}}/build' + cmakeAppendedArgs: >- + -DWITH_TESTS=TRUE + -DCMAKE_BUILD_TYPE='${{matrix.build_type}}' + -DCMAKE_PREFIX_PATH='${{runner.workspace}}/Qt/${{env.qt}}/${{matrix.compiler}}/' + + - name: Create gnupg directory for tests + run: mkdir -p ~/.gnupg + + - name: Create macOS bundle + if: matrix.create_bundle + working-directory: '${{runner.workspace}}/build' + run: '${{github.workspace}}/utils/github/bundle-macos.sh' + + - name: Upload macOS bundle + if: matrix.create_bundle + uses: actions/upload-artifact@v2 + with: + name: CopyQ.dmg + path: '${{runner.workspace}}/build/CopyQ.dmg' diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 283288e21c3ca492f2c3774eb418100f5cac1188..0000000000000000000000000000000000000000 --- a/.travis.yml +++ /dev/null @@ -1,56 +0,0 @@ -sudo: required -language: cpp - -matrix: - include: - - os: osx - compiler: clang - - - os: linux - dist: bionic - compiler: gcc - env: - - COMPILER=g++ - - GCOV=gcov - - - os: linux - dist: bionic - compiler: clang - env: - - COMPILER=clang++ - -cache: - apt: true - ccache: true - directories: - - $HOME/.wheelhouse - -# Don't omit tags (default is git --depth=50). -git: - depth: 9999999 - -before_install: - - utils/travis/before-install-${TRAVIS_OS_NAME}.sh - -install: - - utils/travis/install-${TRAVIS_OS_NAME}.sh - -script: - - utils/travis/script-${TRAVIS_OS_NAME}.sh - -after_success: - - utils/travis/after_success-${TRAVIS_OS_NAME}.sh - -deploy: - provider: releases - api_key: - secure: Vax27ifQsc8SlTsLYVbxVJANDAxDroegN6nOPXCN1MLaoh4W2DQ/iGGx+waIOSYig8Sh+AUz2JhCFuMLMVqwFoWY2rxNPBrxhTBjm3aDhylbB+mRECnbInNb0kS3qv4lNDN6lHD4B6K01FWUUiHX14s2JQx4ut+KuwMxxhxyO4Y= - file: 'build/*.dmg' - file_glob: true - skip_cleanup: true - overwrite: true - on: - condition: "$TRAVIS_OS_NAME = osx" - tags: true - all_branches: true - repo: hluk/CopyQ diff --git a/README.md b/README.md index f57e891ac8695b77992e2e8c987992829e133617..8825bc80db82366df00bd4aff2c03bdeabb0bde0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ [](https://copyq.readthedocs.io/en/latest/?badge=latest) [](https://hosted.weblate.org/engage/copyq/?utm_source=widget) -[](https://travis-ci.org/hluk/CopyQ) +[](https://github.com/hluk/CopyQ/actions?query=branch%3Amaster+event%3Apush+workflow%3A%22Linux+Build%22) +[](https://github.com/hluk/CopyQ/actions?query=branch%3Amaster+event%3Apush+workflow%3A%22macOS+Build%22) [](https://ci.appveyor.com/project/hluk/copyq) [](https://coveralls.io/r/hluk/CopyQ?branch=master) diff --git a/docs/source-code-overview.rst b/docs/source-code-overview.rst index 4606e3ab27bb64b25f3ff3b505ac8cc23b6bd8d8..8ba76a92616ee5f9dba15f3d5a353fc41b5c1f88 100644 --- a/docs/source-code-overview.rst +++ b/docs/source-code-overview.rst @@ -189,7 +189,7 @@ Continuous Integration (CI) The application binaries and packages are built and tested on multiple CI servers. -- `Travis CI <https://travis-ci.org/hluk/CopyQ>`__ +- `GitHub Actions <https://github.com/hluk/CopyQ/actions>`__ - Builds packages for OS X. - Builds and runs tests for Linux binaries. @@ -211,4 +211,4 @@ CI servers. - Builds beta and unstable packages for various Linux distributions. - `Coveralls <https://coveralls.io/github/hluk/CopyQ>`__ - - Contains coverage report from tests run with Travis CI. + - Contains coverage report from tests run with GitHub Actions. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 91636794116a7637b4a27e468e13fe1dfcb4c89c..ba279163e408e2198aea3fc805576ae7be7e1eef 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -168,8 +168,12 @@ else() get_property(_copyq_installed_plugins GLOBAL PROPERTY COPYQ_INSTALLED_PLUGINS) # Directories to look for dependencies - set(FIXUP_BUNDLE_DEP_DIRS "${CMAKE_BINARY_DIR};${QT_LIBRARY_DIRS}") + set(FIXUP_BUNDLE_DEP_DIRS "${CMAKE_BINARY_DIR};${QT_LIBRARY_DIRS};${Qt5Widgets_DIR}/../..") + message(STATUS "Fixup app: ${FIXUP_BUNDLE_APPS}") + message(STATUS "Fixup app plugins: ${_copyq_installed_plugins}") + message(STATUS "Fixup qt plugins: ${FIXUP_BUNDLE_QT_PLUGINS}") + message(STATUS "Fixup dirs: ${FIXUP_BUNDLE_DEP_DIRS}") install(CODE " include(BundleUtilities) set(BU_CHMOD_BUNDLE_ITEMS ON) diff --git a/utils/travis/script-osx.sh b/utils/github/bundle-macos.sh similarity index 59% rename from utils/travis/script-osx.sh rename to utils/github/bundle-macos.sh index f2a44aab297133b9beb9f7fc7ba82f02a42e5ace..80acc5ee8a5c54e4014a360a3ccc44cbfad67b72 100755 --- a/utils/travis/script-osx.sh +++ b/utils/github/bundle-macos.sh @@ -1,23 +1,11 @@ #!/bin/bash -# Build with Travis CI. - -set -exuo pipefail - -mkdir -p build -cd build - -cmake \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_PREFIX_PATH="$(brew --prefix qt5)" \ - -DWITH_TESTS=ON \ - .. - -cmake --build . --target all +# Creates macOS bundle. +set -xeuo pipefail cpack -app_bundle_path="_CPack_Packages/Darwin/DragNDrop/copyq-*/CopyQ.app" -executable="$(ls ${PWD}/${app_bundle_path}/Contents/MacOS/CopyQ)" +app_bundle_path="$(echo _CPack_Packages/Darwin/DragNDrop/copyq-*/CopyQ.app)" +executable="${PWD}/${app_bundle_path}/Contents/MacOS/CopyQ" # Test the app before deployment. "$executable" --help @@ -40,8 +28,8 @@ export COPYQ_TESTS_RERUN_FAILED=1 "$executable" tests # Print dependencies to let us further make sure that we don't depend on local libraries -otool -L $executable -otool -L ${app_bundle_path}/Contents/PlugIns/copyq/* -otool -L ${app_bundle_path}/Contents/Frameworks/Qt*.framework/Versions/5/Qt* +otool -L "$executable" +otool -L "$app_bundle_path/Contents/PlugIns/copyq/"* +otool -L "$app_bundle_path/Contents/Frameworks/"Qt*.framework/Versions/5/Qt* mv copyq-*.dmg CopyQ.dmg diff --git a/utils/github/coverage-linux.sh b/utils/github/coverage-linux.sh new file mode 100755 index 0000000000000000000000000000000000000000..8273362f152a9674405e7635ca3c66251dc772b5 --- /dev/null +++ b/utils/github/coverage-linux.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# Generates and uploads coverage report for Coveralls after running tests. +set -xeuo pipefail + +build_root=$1 + +# Exclude system and 3rd party files. +exclude_files=( + qxt + /usr + plugins/itemfakevim/fakevim + src/gui/fix_icon_id.h +) + +# Exclude generated files. +exclude_regexs=( + "$build_root/.*" + 'build/.*' + '.*/moc_.*' + '.*\.moc$' + '.*_automoc\..*' + '.*/ui_.*' + '.*/qrc_.*' + '.*CMake.*' + '.*/tests/.*' + '.*/src/gui/add_icons.h' +) + +arguments=() + +for file in "${exclude_files[@]}"; do + arguments+=(--exclude "$file") +done + +for regex in "${exclude_regexs[@]}"; do + arguments+=(--exclude-pattern "$regex") +done + +export PATH="$HOME/.local/bin:$PATH" +pip install --user 'urllib3[secure]' cpp-coveralls + +# Looks like coveralls only supports build directory inside the source code +# directory. +ln -s "$build_root" build + +coveralls \ + --follow-symlinks \ + --build-root "build" \ + --gcov gcov \ + "${arguments[@]}" diff --git a/utils/travis/install-linux.sh b/utils/github/install-linux.sh similarity index 80% rename from utils/travis/install-linux.sh rename to utils/github/install-linux.sh index 19f9761c7082175dfcaa609544138cc9266e6d73..f04ec440d8a697b0a26c63374ecc83118311d2c7 100755 --- a/utils/travis/install-linux.sh +++ b/utils/github/install-linux.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash - -set -e -x +# Installs build dependencies. +set -xeuo pipefail packages=( qt5-default @@ -34,7 +34,4 @@ packages=( openbox ) -sudo apt-get install "${packages[@]}" - -# Coveralls -pip install --user 'urllib3[secure]' cpp-coveralls +sudo apt-get install "${packages[@]}" "$@" diff --git a/utils/github/test-linux.sh b/utils/github/test-linux.sh new file mode 100755 index 0000000000000000000000000000000000000000..8183c64d093209f6bf9cb2a3c6eb4892e6472569 --- /dev/null +++ b/utils/github/test-linux.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Runs tests. +set -xeuo pipefail + +# Enable verbose logging. +export COPYQ_LOG_LEVEL=DEBUG + +# Test command line arguments that don't need GUI. +DISPLAY="" ./copyq --help +DISPLAY="" ./copyq --version +DISPLAY="" ./copyq --info + +# Start X11 and window manager. +export DISPLAY=':99.0' +Xvfb :99 -screen 0 1280x960x24 & +sleep 5 +openbox & +sleep 8 + +# Clean up old configuration. +rm -rf ~/.config/copyq.test + +# Run tests. +export COPYQ_TESTS_RERUN_FAILED=0 +./copyq tests diff --git a/utils/travis/after_success-linux.sh b/utils/travis/after_success-linux.sh deleted file mode 100755 index b7f16964d13db74a9ba0ee304fc8ffd7ca5189a0..0000000000000000000000000000000000000000 --- a/utils/travis/after_success-linux.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# Generate coverage report for Coveralls after running tests with Travis CI. - -# Exclude system and 3rd party files. -exclude_files=( - qxt - /usr - plugins/itemfakevim/fakevim - src/gui/fix_icon_id.h -) - -# Exclude generated files. -exclude_regexs=( - 'build/.*' - '.*/moc_.*' - '.*\.moc$' - '.*_automoc\..*' - '.*/ui_.*' - '.*/qrc_.*' - '.*CMake.*' - '.*/tests/.*' - '.*/src/gui/add_icons.h' -) - -# Generate coverage report only with GCC. -if [ "$CC" == "gcc" ]; then - arguments=() - - for file in "${exclude_files[@]}"; do - arguments+=(--exclude "$file") - done - - for regex in "${exclude_regexs[@]}"; do - arguments+=(--exclude-pattern "$regex") - done - - coveralls \ - --build-root "build" \ - --gcov "$GCOV" \ - "${arguments[@]}" -fi diff --git a/utils/travis/after_success-osx.sh b/utils/travis/after_success-osx.sh deleted file mode 100755 index 08878fc61d59aefb65eb616f13ee73b34f3c16f9..0000000000000000000000000000000000000000 --- a/utils/travis/after_success-osx.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -# Doesn't do anything on OS X because we can't run tests on OS X on Travis CI. diff --git a/utils/travis/before-install-linux.sh b/utils/travis/before-install-linux.sh deleted file mode 100755 index 3abf741d1b75641ce42af19f42ef4b7a3c4f6782..0000000000000000000000000000000000000000 --- a/utils/travis/before-install-linux.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -e -x - -sudo apt-get update diff --git a/utils/travis/before-install-osx.sh b/utils/travis/before-install-osx.sh deleted file mode 100755 index d1246e765b0da04752950d75d1897d868fbb161c..0000000000000000000000000000000000000000 --- a/utils/travis/before-install-osx.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -e -x - -brew update diff --git a/utils/travis/install-osx.sh b/utils/travis/install-osx.sh deleted file mode 100755 index 2964113d9f62575c0d17cc678e7d8b24b35aae00..0000000000000000000000000000000000000000 --- a/utils/travis/install-osx.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -e -x - -brew install qt5 diff --git a/utils/travis/script-linux.sh b/utils/travis/script-linux.sh deleted file mode 100755 index b827bd4c0694464ad54d6deda63b4aa2d4e8b370..0000000000000000000000000000000000000000 --- a/utils/travis/script-linux.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# Build and run tests with Travis CI. - -set -xeuo pipefail - -root=$PWD -mkdir build -cd build - -if [ "$CC" == "gcc" ]; then - # GCC build generates coverage. - cmake \ - -DCMAKE_BUILD_TYPE=Debug \ - -DCMAKE_CXX_COMPILER=$COMPILER \ - -DCMAKE_CXX_FLAGS=--coverage \ - -DCMAKE_C_FLAGS=--coverage \ - .. -else - cmake \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_CXX_COMPILER=$COMPILER \ - -DWITH_TESTS=ON \ - .. -fi - -# Build. -make - -# Enable verbose logging. -export COPYQ_LOG_LEVEL=DEBUG - -# Test command line arguments that don't need GUI. -DISPLAY="" ./copyq --help -DISPLAY="" ./copyq --version -DISPLAY="" ./copyq --info - -# Start X11 and window manager. -export DISPLAY=':99.0' -Xvfb :99 -screen 0 1280x960x24 & -sleep 5 -openbox & -sleep 8 - -# Clean up old configuration. -rm -rf ~/.config/copyq.test - -# Run tests. -export COPYQ_TESTS_RERUN_FAILED=0 -./copyq tests - -cd "$root" diff --git a/utils/update_travis-mac_branch.sh b/utils/update_travis-mac_branch.sh deleted file mode 100755 index cab4d11bb97b36ecf973dadcfd6acb4431615938..0000000000000000000000000000000000000000 --- a/utils/update_travis-mac_branch.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# Rebase last commit from target branch to source branch and push. -source_branch="master" -target_branch="travis-mac" -remote="origin" -msg="Updated Travis CI build file for OS X" -keep_files=( - .travis.yml -) - -branch_name () { - git rev-parse --abbrev-ref "$1" -} - -current_branch=$(branch_name HEAD) - -if [ "$current_branch" == "$source_branch" ]; then - echo "** Rebasing last commit from \"$target_branch\" to \"$source_branch\"." - git checkout -b "$target_branch" && - git checkout "$remote/$target_branch" -- "${keep_files[@]}" && - git add "${keep_files[@]}" && - git commit --message "$msg" && - git push --force "$remote" "HEAD:$target_branch" || - echo "** Failed to update \"$target_branch\" branch!" - git checkout "$current_branch" - git branch -D "$target_branch" -fi - diff --git a/version.cmake b/version.cmake index f18142581cbe46a473850f604463187343136ea6..628c28b99ec57c22d5fc73af6877347f87ac1ce9 100644 --- a/version.cmake +++ b/version.cmake @@ -1,16 +1,23 @@ set(copyq_version "v3.13.0") -find_package(Git) -if(GIT_FOUND) - execute_process(COMMAND - "${GIT_EXECUTABLE}" describe --tags - RESULT_VARIABLE copyq_git_describe_result - OUTPUT_VARIABLE copyq_git_describe_output - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if(copyq_git_describe_result EQUAL 0) - set(copyq_version "${copyq_git_describe_output}") +set(copyq_github_sha "$ENV{GITHUB_SHA}") +if (copyq_github_sha) + get_filename_component(copyq_github_ref "$ENV{GITHUB_REF}" NAME) + string(SUBSTRING "${copyq_github_sha}" 0 8 copyq_github_sha) + set(copyq_version "${copyq_version}-g${copyq_github_sha}-${copyq_github_ref}") +else() + find_package(Git) + if(GIT_FOUND) + execute_process(COMMAND + "${GIT_EXECUTABLE}" describe --tags + RESULT_VARIABLE copyq_git_describe_result + OUTPUT_VARIABLE copyq_git_describe_output + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(copyq_git_describe_result EQUAL 0) + set(copyq_version "${copyq_git_describe_output}") + endif() endif() endif()