From 93526fa73f7260157a1a07b56bdc9ae859ae2786 Mon Sep 17 00:00:00 2001 From: yedpodtrzitko Date: Sun, 12 May 2024 21:58:05 +0800 Subject: [PATCH] run tagstudio in CI --- .github/workflows/apprun.yaml | 50 +++++++++++++++++++++++++++++++++++ requirements-dev.txt | 1 + requirements.txt | 1 - tagstudio/src/qt/ts_qt.py | 10 ++++++- tagstudio/tag_studio.py | 5 ++++ 5 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/apprun.yaml diff --git a/.github/workflows/apprun.yaml b/.github/workflows/apprun.yaml new file mode 100644 index 00000000..a56802af --- /dev/null +++ b/.github/workflows/apprun.yaml @@ -0,0 +1,50 @@ +name: PySide App Test + +on: [ push, pull_request ] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'pip' + + - name: Install system dependencies + run: | + # dont run update, it is slow + # sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + libxkbcommon-x11-0 \ + x11-utils \ + libyaml-dev \ + libegl1-mesa \ + libxcb-icccm4 \ + libxcb-image0 \ + libxcb-keysyms1 \ + libxcb-randr0 \ + libxcb-render-util0 \ + libxcb-xinerama0 \ + libopengl0 \ + libxcb-cursor0 + + - name: Install dependencies + run: | + pip install -r requirements.txt + + - name: Run TagStudio app and check exit code + run: | + xvfb-run --server-args="-screen 0, 1920x1200x24 -ac +extension GLX +render -noreset" python tagstudio/tag_studio.py --ci -o /tmp/ + exit_code=$? + if [ $exit_code -eq 0 ]; then + echo "TagStudio ran successfully" + else + echo "TagStudio failed with exit code $exit_code" + exit 1 + fi diff --git a/requirements-dev.txt b/requirements-dev.txt index 4745ae0c..450ee373 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,2 +1,3 @@ ruff==0.4.2 pre-commit==3.7.0 +Pyinstaller==6.6.0 diff --git a/requirements.txt b/requirements.txt index 7c1b4c35..0456b920 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,3 @@ PySide6_Addons>=6.5.1.1,<=6.6.3.1 PySide6_Essentials>=6.5.1.1,<=6.6.3.1 typing_extensions>=3.10.0.0,<=4.11.0 ujson>=5.8.0,<=5.9.0 -Pyinstaller==6.6.0 diff --git a/tagstudio/src/qt/ts_qt.py b/tagstudio/src/qt/ts_qt.py index 0d27f438..1f2295b4 100644 --- a/tagstudio/src/qt/ts_qt.py +++ b/tagstudio/src/qt/ts_qt.py @@ -193,6 +193,9 @@ class QtDriver(QObject): ) max_threads = os.cpu_count() + if args.ci: + # spawn only single worker in CI environment + max_threads = 1 for i in range(max_threads): # thread = threading.Thread(target=self.consumer, name=f'ThumbRenderer_{i}',args=(), daemon=True) # thread.start() @@ -238,6 +241,7 @@ class QtDriver(QObject): # Handle OS signals self.setup_signals() + # allow to process input from console, eg. SIGTERM timer = QTimer() timer.start(500) timer.timeout.connect(lambda: None) @@ -538,7 +542,11 @@ class QtDriver(QObject): ) self.open_library(lib) - app.exec_() + if self.args.ci: + # gracefully terminate the app in CI environment + self.thumb_job_queue.put((self.SIGTERM.emit, [])) + + app.exec() self.shutdown() diff --git a/tagstudio/tag_studio.py b/tagstudio/tag_studio.py index e98cf8c9..92440160 100644 --- a/tagstudio/tag_studio.py +++ b/tagstudio/tag_studio.py @@ -45,6 +45,11 @@ def main(): type=str, help="User interface option for TagStudio. Options: qt, cli (Default: qt)", ) + parser.add_argument( + "--ci", + action=argparse.BooleanOptionalAction, + help="Exit the application after checking it starts without any problem. Meant for CI check.", + ) args = parser.parse_args() core = TagStudioCore() # The TagStudio Core instance. UI agnostic.