From f0e36db4f6a4861c8beb57000b63684387d06e53 Mon Sep 17 00:00:00 2001 From: "U. Bruhin" Date: Sun, 3 Mar 2024 21:47:46 +0100 Subject: [PATCH] CI: Migrate to GitHub Actions --- .github/workflows/main.yml | 183 +++++++++++++++++++++++++ ci/install_dependencies.sh | 56 -------- client/funq/tests/test_aliases.py | 2 +- client/funq/tests/test_client.py | 4 +- client/funq/tests/test_screenshoter.py | 5 +- server/funq_server/runner_win.py | 4 +- 6 files changed, 191 insertions(+), 63 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100755 ci/install_dependencies.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..5a367f4 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,183 @@ +name: CI +on: [push, pull_request] + +env: + MAKEFLAGS: "-j8" + +jobs: + + linux: + name: "qt:${{ matrix.qt }} py:${{ matrix.py }} on ${{ matrix.container }}" + runs-on: ubuntu-22.04 + container: "${{ matrix.container }}" + strategy: + matrix: + include: + - qt: "5.9" + py: "3.6" + container: "ubuntu:18.04" + packages: "qt5-default qttools5-dev-tools qtdeclarative5-dev qml-module-qtquick2" + nosetests: 1 + - qt: "5.12" + py: "3.8" + container: "ubuntu:20.04" + packages: "qt5-default qttools5-dev-tools qtdeclarative5-dev qml-module-qtquick2" + nosetests: 1 + - qt: "5.15" + py: "3.10" + container: "ubuntu:22.04" + packages: "qtbase5-dev qttools5-dev-tools qtdeclarative5-dev qml-module-qtquick2" + nosetests: 0 # Nosetest not working anymore + env: + DEBIAN_FRONTEND: noninteractive + steps: + - uses: actions/checkout@v2 + - name: Install requirements + run: | + apt-get update + apt-get install -y --no-install-recommends \ + build-essential cmake xvfb libglu1-mesa-dev \ + python3 python3-pip python3-flake8 \ + ${{ matrix.packages }} + + # Stylecheck + - name: Flake8 + run: python3 -m flake8 client/funq server/funq_server + + # Build & test C++ modules + - name: Build libFunq + run: | + mkdir build + cd build + cmake ../server -DBUILD_TESTS=1 -DBUILD_DISALLOW_WARNINGS=1 + make + - name: Run libFunq tests + run: xvfb-run -a build/tests/libFunq/testLibFunq + - name: Run protocole tests + run: xvfb-run -a build/tests/protocole/testProtocole + + # Server + - name: Install server + run: cd server && python3 setup.py develop + + # Client + - name: Install client + run: cd client && python3 setup.py develop + - name: Test client + run: cd client && python3 setup.py test + if: ${{ matrix.nosetests != 0 }} + + # Functional tests + - name: Build test app + run: cd tests-functionnal/funq-test-app && cmake . && make + - name: Test functional + run: cd tests-functionnal && xvfb-run -a nosetests + if: ${{ matrix.nosetests != 0}} + + macos: + name: "qt:${{ matrix.qt }} on ${{ matrix.runner }}" + runs-on: "${{ matrix.runner }}" + strategy: + matrix: + include: + # Note: Nosetest doesn't work anymore with recent Python versions! + - {qt: "5", runner: "macos-12", nosetests: 0} + - {qt: "5", runner: "macos-14", nosetests: 0} + steps: + - uses: actions/checkout@v2 + - name: Install requirements + run: | + brew install cmake qt@${{ matrix.qt }} + brew link --force qt@${{ matrix.qt }} + echo "$(brew --prefix qt${{ matrix.qt }})/bin" >> $GITHUB_PATH + pip3 install setuptools flake8 + + # Stylecheck + - name: Flake8 + run: python3 -m flake8 client/funq server/funq_server + + # Build & test C++ modules + - name: Build libFunq + run: | + mkdir build + cd build + cmake ../server -DBUILD_TESTS=1 -DBUILD_DISALLOW_WARNINGS=1 + make + - name: Run libFunq tests + run: build/tests/libFunq/testLibFunq + - name: Run protocole tests + run: build/tests/protocole/testProtocole + + # Server + - name: Install server + run: cd server && python3 setup.py develop + + # Client + - name: Install client + run: cd client && python3 setup.py develop + - name: Test client + run: cd client && python3 setup.py test + if: ${{ matrix.nosetests != 0 }} + + # Functional tests + - name: Build test app + run: cd tests-functionnal/funq-test-app && cmake . && make + - name: Test functional + run: cd tests-functionnal && xvfb-run -a nosetests + if: ${{ matrix.nosetests != 0}} + + windows: + name: "qt:${{ matrix.qt }} on windows" + runs-on: windows-2022 + strategy: + matrix: + include: + - {qt: "5.15", nosetests: 0} + env: + CMAKE_GENERATOR: "MinGW Makefiles" + CC: "D:/a/funq/Qt/Tools/mingw810_32/bin/gcc.exe" + CXX: "D:/a/funq/Qt/Tools/mingw810_32/bin/g++.exe" + defaults: + run: + shell: cmd + steps: + - uses: actions/checkout@v2 + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + version: "${{ matrix.qt }}.*" + tools: "tools_mingw,qt.tools.win32_mingw810" + arch: win32_mingw81 + cache: true + + # Build & test C++ modules + - name: Build libFunq + run: | + mkdir build + cd build + cmake ../server -DBUILD_TESTS=1 -DBUILD_DISALLOW_WARNINGS=1 + make + + # Note: The executables don't run yet, don't know why :-/ + # - name: Run libFunq tests + # run: build/tests/libFunq/testLibFunq.exe + # - name: Run protocole tests + # run: build/tests/protocole/testProtocole.exe + + # Server + - name: Install server + run: cd server && python3 setup.py develop + + # Client + - name: Install client + run: cd client && python3 setup.py develop + - name: Test client + run: cd client && python3 setup.py test + if: ${{ matrix.nosetests != 0 }} + + # Functional tests + - name: Build test app + run: cd tests-functionnal/funq-test-app && cmake . && make + - name: Test functional + run: cd tests-functionnal && xvfb-run -a nosetests + if: ${{ matrix.nosetests != 0}} diff --git a/ci/install_dependencies.sh b/ci/install_dependencies.sh deleted file mode 100755 index 42ed22a..0000000 --- a/ci/install_dependencies.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bash - -# use multiple cores for building -export MAKEFLAGS="-j8" - -# Install dependencies on Linux -if [[ "${TRAVIS_OS_NAME-}" == "linux" ]] -then - - # common - sudo apt-get update -q - sudo apt-get install -q build-essential xvfb - - # qt - # Add corresponding PPA from https://launchpad.net/~beineri - MAJOR=`echo "$QT_SELECT" | cut -d'.' -f 1` - MINOR=`echo "$QT_SELECT" | cut -d'.' -f 2` - PATCH=`echo "$QT_SELECT" | cut -d'.' -f 3` - PREFIX="" && [[ "$MINOR" -ge 10 ]] && PREFIX="-" - SEPARATOR="" && [[ "$MINOR" -ge 10 ]] && SEPARATOR="." - CODENAME=`lsb_release -sc` - sudo add-apt-repository "ppa:beineri/opt-qt${PREFIX}${MAJOR}${SEPARATOR}${MINOR}${SEPARATOR}${PATCH}-$CODENAME" -y - sudo apt-get update -q - sudo apt-get install -q "qt${MAJOR}${MINOR}base" "qt${MAJOR}${MINOR}tools" "qt${MAJOR}${MINOR}declarative" libglu1-mesa-dev - source "/opt/qt${MAJOR}${MINOR}/bin/qt${MAJOR}${MINOR}-env.sh" - - # python packages - pip install flake8 - - # xvfb is only needed on Trusty, see deteils here: - # https://docs.travis-ci.com/user/gui-and-headless-browsers/#using-xvfb-to-run-tests-that-require-a-gui - if [[ "`lsb_release -sc`" == "trusty" ]] - then - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start - fi - - -# Install dependencies on OS X -elif [[ "${TRAVIS_OS_NAME-}" == "osx" ]] -then - - # ccache - brew update - brew install ccache - export PATH="/usr/local/opt/ccache/libexec:$PATH" - - # qt - brew install qt5 - brew link --force qt5 - - # python packages - pip${PYTHON/python/} install --user flake8 - export PATH="$PATH:`$PYTHON -m site --user-base`/bin" - -fi diff --git a/client/funq/tests/test_aliases.py b/client/funq/tests/test_aliases.py index 78b3a0a..6ce9772 100644 --- a/client/funq/tests/test_aliases.py +++ b/client/funq/tests/test_aliases.py @@ -33,7 +33,7 @@ # knowledge of the CeCILL v2.1 license and that you accept its terms. from nose.tools import assert_equals, raises -from funq.aliases import HooqAliases, HooqAliasesInvalidLineError,\ +from funq.aliases import HooqAliases, HooqAliasesInvalidLineError, \ HooqAliasesKeyError from tempfile import NamedTemporaryFile import os diff --git a/client/funq/tests/test_client.py b/client/funq/tests/test_client.py index 106c78b..b527f98 100644 --- a/client/funq/tests/test_client.py +++ b/client/funq/tests/test_client.py @@ -37,7 +37,7 @@ import os import subprocess -from ConfigParser import ConfigParser, NoOptionError +from configparser import ConfigParser, NoOptionError class ApplicationConfig(client.ApplicationConfig): @@ -47,7 +47,7 @@ class ApplicationConfig(client.ApplicationConfig): class GlobalOptions(object): def __init__(self, **kwds): - for k, v in kwds.iteritems(): + for k, v in kwds.items(): setattr(self, k, v) diff --git a/client/funq/tests/test_screenshoter.py b/client/funq/tests/test_screenshoter.py index f31f2d5..e09253c 100644 --- a/client/funq/tests/test_screenshoter.py +++ b/client/funq/tests/test_screenshoter.py @@ -64,7 +64,7 @@ def test_take_one_screenshot(): funq = FakeFunqClient() with ScreenShoterCtx() as ctx: ctx.take_screenshot(funq, "hello") - assert_equals(map(os.path.basename, funq.screens), ["0.png"]) + assert_equals(list(map(os.path.basename, funq.screens)), ["0.png"]) assert_true("0.png: hello" in open( os.path.join(ctx.working_folder, 'images.txt')).read()) @@ -76,7 +76,8 @@ def test_take_screenshots(): ctx.take_screenshot(funq, "thisisit") - assert_equals(map(os.path.basename, funq.screens), ["0.png", "1.png"]) + assert_equals(list(map(os.path.basename, funq.screens)), + ["0.png", "1.png"]) content = open(os.path.join(ctx.working_folder, 'images.txt')).read() assert_true("0.png: hello" in content) assert_true("1.png: thisisit" in content) diff --git a/server/funq_server/runner_win.py b/server/funq_server/runner_win.py index 4a4acf1..bf176c9 100644 --- a/server/funq_server/runner_win.py +++ b/server/funq_server/runner_win.py @@ -38,9 +38,9 @@ # Useful resources regarding DLL injection: # -# - https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-best-practices +# - https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-best-practices # noqa: E501 # - https://blog.nettitude.com/uk/dll-injection-part-two -# - https://stackoverflow.com/questions/27332509/createremotethread-on-loadlibrary-and-get-the-hmodule-back +# - https://stackoverflow.com/questions/27332509/createremotethread-on-loadlibrary-and-get-the-hmodule-back # noqa: E501 # - https://github.com/numaru/injector # Constants from Windows API documentation.