Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a CI configuration for the testbed app #1

Merged
merged 8 commits into from
Dec 6, 2022
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
54 changes: 54 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,57 @@ jobs:
TOGA_INSTALL_COMMAND: 'bash -c "pip install ../{core,dummy,${{ matrix.backend }}}/dist/*.whl"'
run: |
tox -e py-${{ matrix.backend }}

testbed:
needs: core
strategy:
fail-fast: false
matrix:
backend: ["macOS", "windows", "linux", "android", "iOS"]
include:
- runs-on: ubuntu-latest
- pre-command:
- briefcase-run-args:

- backend: macOS
runs-on: macos-12

- backend: linux
runs-on: ubuntu-latest
pre-command: "sudo apt-get update -y && sudo apt-get install -y python3-gi python3-gi-cairo gir1.2-gtk-3.0 python3-dev libgirepository1.0-dev libcairo2-dev pkg-config"

- backend: windows
runs-on: windows-latest

- backend: iOS
runs-on: macos-12
briefcase-run-args: ' -d "iPhone SE (3rd generation)"'

- backend: android
runs-on: macos-12
briefcase-run-args: " -d '{\"avd\":\"beePhone\"}' --Xemulator=-no-window --Xemulator=-no-snapshot --Xemulator=-no-audio --Xemulator=-no-boot-anim --shutdown-on-exit"

runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v3.1.0
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4.3.0
with:
python-version: "3.X"
- name: Install dependencies
run: |
${{ matrix.pre-command }}
# Use the development version of Briefcase
pip install git+https://github.com/beeware/briefcase.git
- name: Test App
run: |
cd testbed
briefcase run ${{ matrix.backend }} --test ${{ matrix.briefcase-run-args }}
- uses: actions/upload-artifact@v3
name: Upload logs
if: failure()
with:
name: testbed-failure-logs-${{ matrix.backend }}
path: testbed/logs/*
6 changes: 4 additions & 2 deletions iOS/src/toga_iOS/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ def open_document(self, fileURL):
pass

def main_loop(self):
# Main loop is a no-op on iOS; the app loop is integrated with the
# main iOS event loop.
# Main loop is non-blocking on iOS. The app loop is integrated with the
# main iOS event loop, so this call will return; however, it will leave
# the app in a state such that asyncio events will be scheduled on the
# iOS event loop.
self.loop.run_forever_cooperatively(lifecycle=iOSLifecycle())

def set_main_window(self, window):
Expand Down
12 changes: 0 additions & 12 deletions test/src/toga_test/app.py

This file was deleted.

Binary file removed test/src/toga_test/resources/toga_test.icns
Binary file not shown.
Binary file removed test/src/toga_test/resources/toga_test.ico
Binary file not shown.
Binary file removed test/src/toga_test/resources/toga_test.png
Binary file not shown.
File renamed without changes.
30 changes: 15 additions & 15 deletions test/pyproject.toml → testbed/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# This project was generated using template: https://github.com/beeware/briefcase-template and branch: v0.3.12
[tool.briefcase]
project_name = "Toga test"
bundle = "org.beeware"
project_name = "Toga Testbed"
bundle = "org.beeware.toga"
version = "0.0.1"
url = "https://beeware.org"
license = "BSD license"
author = 'Tiberius Yak'
author_email = "tiberius@beeware.org"

[tool.briefcase.app.toga-test]
formal_name = "Toga test"
description = "Toga test"
icon = "src/toga_test/resources/toga_test"
[tool.briefcase.app.testbed]
formal_name = "Toga Testbed"
description = "A testbed for Toga visual tests"
icon = "src/testbed/resources/testbed"
sources = [
'src/toga_test',
'src/testbed',
]
test_sources = [
'tests',
Expand All @@ -27,18 +27,18 @@ test_requires = [
]


[tool.briefcase.app.toga-test.macOS]
[tool.briefcase.app.testbed.macOS]
requires = [
'../cocoa',
'std-nslog~=1.0.0'
]

[tool.briefcase.app.toga-test.linux]
[tool.briefcase.app.testbed.linux]
requires = [
'../gtk',
]

[tool.briefcase.app.toga-test.linux.appimage]
[tool.briefcase.app.testbed.linux.appimage]
system_requires = [
'gir1.2-webkit-3.0',
'libcairo2-dev',
Expand All @@ -52,12 +52,12 @@ linuxdeploy_plugins = [
'DEPLOY_GTK_VERSION=3 gtk',
]

[tool.briefcase.app.toga-test.linux.flatpak]
[tool.briefcase.app.testbed.linux.flatpak]
flatpak_runtime = 'org.gnome.Platform'
flatpak_runtime_version = '42'
flatpak_sdk = 'org.gnome.Sdk'

[tool.briefcase.app.toga-test.windows]
[tool.briefcase.app.testbed.windows]
test_sources = [
'../winforms/tests_backend',
]
Expand All @@ -66,13 +66,13 @@ requires = [
]

# Mobile deployments
[tool.briefcase.app.toga-test.iOS]
[tool.briefcase.app.testbed.iOS]
requires = [
'../iOS',
'std-nslog~=1.0.0'
]

[tool.briefcase.app.toga-test.android]
[tool.briefcase.app.testbed.android]
test_sources = [
'../android/tests_backend',
]
Expand All @@ -83,7 +83,7 @@ requires = [
# TODO: replace with extractPackages
build_gradle_extra_content = "android.defaultConfig.python.pyc.src false"

[tool.briefcase.app.toga-test.web]
[tool.briefcase.app.testbed.web]
requires = [
'../web'
]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from toga_test.app import main
from testbed.app import main

if __name__ == "__main__":
main().main_loop()
27 changes: 27 additions & 0 deletions testbed/src/testbed/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import toga


class Testbed(toga.App):
def startup(self):
self.main_window = toga.MainWindow(title=self.formal_name)
self.main_window.content = toga.Box(
children=[
toga.Label("Did you forget to use --test?"),
]
)
self.main_window.show()

# FIXME: workaround for https://github.com/beeware/rubicon-objc/issues/228
if toga.platform.current_platform == "iOS":
import asyncio

async def heartbeat(*args, **kwargs):
while True:
await asyncio.sleep(0.0001)

self.add_background_task(heartbeat)
# END FIXME


def main():
return Testbed(app_name="testbed")
Binary file added testbed/src/testbed/resources/testbed-1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testbed/src/testbed/resources/testbed-120.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testbed/src/testbed/resources/testbed-152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testbed/src/testbed/resources/testbed-167.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testbed/src/testbed/resources/testbed-180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testbed/src/testbed/resources/testbed-20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testbed/src/testbed/resources/testbed-29.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testbed/src/testbed/resources/testbed-40.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testbed/src/testbed/resources/testbed-58.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testbed/src/testbed/resources/testbed-60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testbed/src/testbed/resources/testbed-76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testbed/src/testbed/resources/testbed-80.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testbed/src/testbed/resources/testbed-87.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testbed/src/testbed/resources/testbed.icns
Binary file not shown.
Binary file added testbed/src/testbed/resources/testbed.ico
Binary file not shown.
Binary file added testbed/src/testbed/resources/testbed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 9 additions & 3 deletions test/tests/toga_test.py → testbed/tests/testbed.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import os
import sys
import tempfile
from functools import partial
from pathlib import Path
from threading import Thread

import pytest
import tests

from toga_test.app import main
from testbed.app import main


def run_tests(app):
project_path = Path(__file__).parent.parent
os.chdir(project_path)

# TODO: replace with extractPackages.
if hasattr(sys, "getandroidapilevel"):
import tests

chaquopy_extract_package(tests)

pytest.main(
Expand All @@ -27,8 +33,8 @@ def run_tests(app):
# Override the cache directory to be somewhere known writable
"-o",
f"cache_dir={tempfile.gettempdir()}/.pytest_cache",
project_path / "tests",
]
+ tests.__path__
)
app.add_background_task(lambda app: app.exit())

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.