Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,25 @@ jobs:
Write-Warning "Defender scan did not complete cleanly (exit $LASTEXITCODE)"
}

# Launches the packaged exe in --smoke mode: it must open the real
# settings child process and sustain IPC polls (checks for crashes and surch)
- name: smoke test exe
shell: pwsh
run: |
$process = Start-Process -FilePath "dist/CheevoPresence.exe" -ArgumentList "--smoke" -PassThru -Wait
if ($process.ExitCode -ne 0) {
Write-Error "Smoke test failed with exit code $($process.ExitCode)"
exit 1
}

- name: upload smoke log
if: failure()
uses: actions/upload-artifact@v7
with:
name: windows-smoke-cheevo.log
path: ~/AppData/Roaming/CheevoPresence/logs/cheevo.log
if-no-files-found: ignore

- name: prepare artifact
shell: pwsh
run: |
Expand Down Expand Up @@ -116,6 +135,18 @@ jobs:
- name: build app
run: ./build_macos.sh

- name: smoke test app
shell: bash
run: dist/CheevoPresence.app/Contents/MacOS/CheevoPresence --smoke

- name: upload smoke log
if: failure()
uses: actions/upload-artifact@v7
with:
name: macos-${{ matrix.arch }}-smoke-cheevo.log
path: ~/Library/Application Support/CheevoPresence/logs/cheevo.log
if-no-files-found: ignore

- name: prepare artifact
shell: bash
run: |
Expand Down Expand Up @@ -159,11 +190,24 @@ jobs:
gir1.2-gtk-3.0 \
gir1.2-webkit2-4.0 \
gir1.2-ayatanaappindicator3-0.1 \
libayatana-appindicator3-1
libayatana-appindicator3-1 \
xvfb

- name: build binary
run: ./build_linux.sh

- name: smoke test binary
shell: bash
run: xvfb-run -a dist/CheevoPresence --smoke

- name: upload smoke log
if: failure()
uses: actions/upload-artifact@v7
with:
name: linux-smoke-cheevo.log
path: ~/.local/state/CheevoPresence/logs/cheevo.log
if-no-files-found: ignore

- name: prepare artifact
shell: bash
run: |
Expand Down
116 changes: 116 additions & 0 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: smoke

# Source-mode smoke test: launches the real app with --smoke on every OS so
# bugs that only appear when the actual settings child process runs
on:
pull_request:
paths:
- "desktop/**"
- "launch_windows.py"
- "launch_macos.py"
- "launch_linux.py"
- "requirements/**"
- ".github/workflows/smoke.yml"

permissions:
contents: read

concurrency:
group: smoke-${{ github.ref }}
cancel-in-progress: true

jobs:
smoke:
name: smoke (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-22.04]

steps:
- name: checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7

- name: setup python
if: runner.os != 'Linux'
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
with:
python-version: "3.12"
cache: pip
cache-dependency-path: |
requirements/base.txt
requirements/windows.txt
requirements/macos.txt

- name: install dependencies (windows)
if: runner.os == 'Windows'
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements/windows.txt

- name: install dependencies (macos)
if: runner.os == 'macOS'
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements/macos.txt

# The Linux GTK/WebKit stack comes from apt, so the venv must see the
# system site-packages (same approach as build_linux.sh).
- name: install dependencies (linux)
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y \
python3-venv \
python3-pip \
python3-tk \
python3-gi \
python3-gi-cairo \
gir1.2-gtk-3.0 \
gir1.2-webkit2-4.0 \
gir1.2-ayatanaappindicator3-0.1 \
libayatana-appindicator3-1 \
xvfb
python3 -m venv --system-site-packages .smoke-venv
.smoke-venv/bin/python -m pip install --upgrade pip
.smoke-venv/bin/python -m pip install -r requirements/linux.txt

- name: run smoke (windows)
if: runner.os == 'Windows'
run: python launch_windows.py --smoke

- name: run smoke (macos)
if: runner.os == 'macOS'
run: python launch_macos.py --smoke

- name: run smoke (linux)
if: runner.os == 'Linux'
shell: bash
run: xvfb-run -a .smoke-venv/bin/python launch_linux.py --smoke

- name: upload smoke log (windows)
if: failure() && runner.os == 'Windows'
uses: actions/upload-artifact@v7
with:
name: smoke-windows-cheevo.log
path: ~/AppData/Roaming/CheevoPresence/logs/cheevo.log
if-no-files-found: ignore

- name: upload smoke log (macos)
if: failure() && runner.os == 'macOS'
uses: actions/upload-artifact@v7
with:
name: smoke-macos-cheevo.log
path: ~/Library/Application Support/CheevoPresence/logs/cheevo.log
if-no-files-found: ignore

- name: upload smoke log (linux)
if: failure() && runner.os == 'Linux'
uses: actions/upload-artifact@v7
with:
name: smoke-linux-cheevo.log
path: ~/.local/state/CheevoPresence/logs/cheevo.log
if-no-files-found: ignore
5 changes: 2 additions & 3 deletions desktop/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
RELEASES_LATEST_API_URL = "https://api.github.com/repos/denzi-gh/CheevoPresence/releases/latest"
UPDATE_TEST_FILE_NAME = "update-test.json"

# CLI flags shared across the launchers, platform entrypoints, and adapters.
# Centralised here so a flag string is defined once and platform shells can
# reference it without importing each other (which would be circular).
# CLI flags shared across the launchers, platform entrypoints, and adapters
TRAY_FLAG = "--tray"
EXIT_APP_FLAG = "--exit"
SMOKE_FLAG = "--smoke"
MAC_SETTINGS_CLIENT_FLAG = "--mac-settings-client"
WINDOWS_SETTINGS_CLIENT_FLAG = "--windows-settings-client"
LINUX_SETTINGS_CLIENT_FLAG = "--linux-settings-client"
2 changes: 1 addition & 1 deletion desktop/platform/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def set_autostart(enable):
try:
import winreg

key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, STARTUP_REG_KEY, 0, winreg.KEY_SET_VALUE)
key = winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, STARTUP_REG_KEY, 0, winreg.KEY_SET_VALUE)
try:
if enable:
exe = get_exe_path()
Expand Down
7 changes: 6 additions & 1 deletion desktop/shell/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import logging
import sys

from desktop.core.constants import EXIT_APP_FLAG, TRAY_FLAG
from desktop.core.constants import EXIT_APP_FLAG, SMOKE_FLAG, TRAY_FLAG
from desktop.core.log_events import AREA_STARTUP, log_event
from desktop.platform import get_platform_services
from desktop.runtime.controller import AppController
Expand All @@ -32,6 +32,11 @@ def run_shell(platform_name, run_app):
log_startup_diagnostics(platform)
log_event(logger, AREA_STARTUP, "entrypoint_started", platform=platform_name, mode=mode)

if SMOKE_FLAG in sys.argv:
from desktop.shell.smoke import run_smoke

sys.exit(run_smoke(platform_name, platform))

if platform.handle_special_args(sys.argv):
log_event(logger, AREA_STARTUP, "platform_helper_handled", platform=platform_name)
return
Expand Down
5 changes: 4 additions & 1 deletion desktop/shell/ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ def _format_ipc_error(exc):

class SettingsHostService:

def __init__(self, controller, on_quit=None):
def __init__(self, controller, on_quit=None, on_request=None):
self.controller = controller
self.on_quit = on_quit
self.on_request = on_request
self.address = ""
self.auth_token = secrets.token_hex(32)
self.listener = None
Expand Down Expand Up @@ -236,6 +237,8 @@ def _serve(self):
request = _read_message(conn)
method = request.get("method")
response = {"ok": True, "result": self._dispatch(request)}
if self.on_request:
self.on_request(method)
if self._should_log_request(method, start):
log_event(
logger,
Expand Down
Loading