diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a250a602e5..5d7883e288 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,166 +30,176 @@ concurrency: cancel-in-progress: true jobs: - pre-commit: - name: Pre-commit checks - uses: beeware/.github/.github/workflows/pre-commit-run.yml@main - with: - pre-commit-source: "./core[dev]" - - towncrier: - name: Check towncrier - uses: beeware/.github/.github/workflows/towncrier-run.yml@main - with: - tox-source: "./core[dev]" - - package: - name: Package Toga - permissions: - id-token: write - contents: read - attestations: write - strategy: - matrix: - subdir: - - "android" - - "cocoa" - - "core" - - "demo" - - "dummy" - - "gtk" - - "iOS" - - "toga" - - "textual" - - "web" - - "winforms" - uses: beeware/.github/.github/workflows/python-package-create.yml@main - with: - build-subdirectory: ${{ matrix.subdir }} - attest: ${{ inputs.attest-package }} - - core: - name: Test core - runs-on: ${{ matrix.platform }} - needs: [ pre-commit, towncrier, package ] - continue-on-error: ${{ matrix.experimental }} - strategy: - fail-fast: false - matrix: - platform: [ "macos-12", "macos-14", "ubuntu-latest", "windows-latest" ] - python-version: [ "3.8", "3.12", "3.13-dev" ] - include: - - experimental: false - # Test Python 3.9-3.11 on Ubuntu only - - platform: "ubuntu-latest" - python-version: "3.9" - experimental: false - - platform: "ubuntu-latest" - python-version: "3.10" - experimental: false - - platform: "ubuntu-latest" - python-version: "3.11" - experimental: false - # Allow development Python to fail without failing entire job. - - python-version: "3.13-dev" - experimental: true - exclude: - # macos-14 (i.e. arm64) does not support Python 3.8 - - platform: "macos-14" - python-version: "3.8" - # Pillow isn't available for Python 3.13 on Windows - - platform: "windows-latest" - python-version: "3.13-dev" - steps: - - name: Checkout - uses: actions/checkout@v4.1.7 - with: - fetch-depth: 0 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5.2.0 - with: - python-version: ${{ matrix.python-version }} - - - name: Install Tox - uses: beeware/.github/.github/actions/install-requirement@main - with: - requirements: tox - extra: dev - project-root: core - - - name: Get Packages - uses: actions/download-artifact@v4.1.8 - with: - pattern: ${{ format('{0}-*', needs.package.outputs.artifact-basename) }} - merge-multiple: true - path: dist - - - name: Test - run: | - # The $(ls ...) shell expansion is done in the Github environment; - # the value of TOGA_INSTALL_COMMAND will be a literal string without any shell expansions to perform - TOGA_INSTALL_COMMAND="python -m pip install ../$(ls dist/toga_core-*.whl)[dev] ../$(ls dist/toga_dummy-*.whl)" \ - tox -e py-cov - tox -qe coverage$(tr -dc "0-9" <<< "${{ matrix.python-version }}") - mv core/.coverage core/.coverage.${{ matrix.platform }}.${{ matrix.python-version }} - - - name: Store Coverage Data - uses: actions/upload-artifact@v4.4.0 - with: - name: core-coverage-data-${{ matrix.platform }}-${{ matrix.python-version }} - path: "core/.coverage.*" - if-no-files-found: error - include-hidden-files: true - - core-coverage: - name: Coverage - needs: core - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4.1.7 - with: - fetch-depth: 0 - - - name: Set up Python ${{ env.min_python_version }} - uses: actions/setup-python@v5.2.0 - with: - # Use minimum version of python for coverage to avoid phantom branches - # https://github.com/nedbat/coveragepy/issues/1572#issuecomment-1522546425 - python-version: ${{ env.min_python_version }} - - - name: Install Tox - uses: beeware/.github/.github/actions/install-requirement@main - with: - requirements: tox - extra: dev - project-root: core - - - name: Retrieve Coverage Data - uses: actions/download-artifact@v4.1.8 - with: - pattern: core-coverage-data-* - path: core - merge-multiple: true - - - name: Generate Coverage Report - run: tox -e coverage-html-fail-platform - - - name: Upload HTML Coverage Report - uses: actions/upload-artifact@v4.4.0 - if: failure() - with: - name: html-coverage-report - path: core/htmlcov +# pre-commit: +# name: Pre-commit checks +# uses: beeware/.github/.github/workflows/pre-commit-run.yml@main +# with: +# pre-commit-source: "./core[dev]" +# +# towncrier: +# name: Check towncrier +# uses: beeware/.github/.github/workflows/towncrier-run.yml@main +# with: +# tox-source: "./core[dev]" +# +# package: +# name: Package Toga +# permissions: +# id-token: write +# contents: read +# attestations: write +# strategy: +# matrix: +# subdir: +# - "android" +# - "cocoa" +# - "core" +# - "demo" +# - "dummy" +# - "gtk" +# - "iOS" +# - "toga" +# - "textual" +# - "web" +# - "winforms" +# uses: beeware/.github/.github/workflows/python-package-create.yml@main +# with: +# build-subdirectory: ${{ matrix.subdir }} +# attest: ${{ inputs.attest-package }} + +# core: +# name: Test core +# runs-on: ${{ matrix.platform }} +# needs: [ pre-commit, towncrier, package ] +# continue-on-error: ${{ matrix.experimental }} +# strategy: +# fail-fast: false +# matrix: +# platform: [ "macos-12", "macos-14", "ubuntu-latest", "windows-latest" ] +# python-version: [ "3.8", "3.12", "3.13-dev" ] +# include: +# - experimental: false +# # Test Python 3.9-3.11 on Ubuntu only +# - platform: "ubuntu-latest" +# python-version: "3.9" +# experimental: false +# - platform: "ubuntu-latest" +# python-version: "3.10" +# experimental: false +# - platform: "ubuntu-latest" +# python-version: "3.11" +# experimental: false +# # Allow development Python to fail without failing entire job. +# - python-version: "3.13-dev" +# experimental: true +# exclude: +# # macos-14 (i.e. arm64) does not support Python 3.8 +# - platform: "macos-14" +# python-version: "3.8" +# # Pillow isn't available for Python 3.13 on Windows +# - platform: "windows-latest" +# python-version: "3.13-dev" +# steps: +# - name: Checkout +# uses: actions/checkout@v4.1.7 +# with: +# fetch-depth: 0 +# +# - name: Set up Python ${{ matrix.python-version }} +# uses: actions/setup-python@v5.2.0 +# with: +# python-version: ${{ matrix.python-version }} +# +# - name: Install Tox +# uses: beeware/.github/.github/actions/install-requirement@main +# with: +# requirements: tox +# extra: dev +# project-root: core +# +# - name: Get Packages +# uses: actions/download-artifact@v4.1.8 +# with: +# pattern: ${{ format('{0}-*', needs.package.outputs.artifact-basename) }} +# merge-multiple: true +# path: dist +# +# - name: Test +# run: | +# # The $(ls ...) shell expansion is done in the Github environment; +# # the value of TOGA_INSTALL_COMMAND will be a literal string without any shell expansions to perform +# TOGA_INSTALL_COMMAND="python -m pip install ../$(ls dist/toga_core-*.whl)[dev] ../$(ls dist/toga_dummy-*.whl)" \ +# tox -e py-cov +# tox -qe coverage$(tr -dc "0-9" <<< "${{ matrix.python-version }}") +# mv core/.coverage core/.coverage.${{ matrix.platform }}.${{ matrix.python-version }} +# +# - name: Store Coverage Data +# uses: actions/upload-artifact@v4.4.0 +# with: +# name: core-coverage-data-${{ matrix.platform }}-${{ matrix.python-version }} +# path: "core/.coverage.*" +# if-no-files-found: error +# include-hidden-files: true +# +# core-coverage: +# name: Coverage +# needs: core +# runs-on: ubuntu-latest +# steps: +# - name: Checkout +# uses: actions/checkout@v4.1.7 +# with: +# fetch-depth: 0 +# +# - name: Set up Python ${{ env.min_python_version }} +# uses: actions/setup-python@v5.2.0 +# with: +# # Use minimum version of python for coverage to avoid phantom branches +# # https://github.com/nedbat/coveragepy/issues/1572#issuecomment-1522546425 +# python-version: ${{ env.min_python_version }} +# +# - name: Install Tox +# uses: beeware/.github/.github/actions/install-requirement@main +# with: +# requirements: tox +# extra: dev +# project-root: core +# +# - name: Retrieve Coverage Data +# uses: actions/download-artifact@v4.1.8 +# with: +# pattern: core-coverage-data-* +# path: core +# merge-multiple: true +# +# - name: Generate Coverage Report +# run: tox -e coverage-html-fail-platform +# +# - name: Upload HTML Coverage Report +# uses: actions/upload-artifact@v4.4.0 +# if: failure() +# with: +# name: html-coverage-report +# path: core/htmlcov testbed: name: Testbed - needs: core + # needs: core runs-on: ${{ matrix.runs-on }} strategy: fail-fast: false matrix: - backend: [ "macOS-x86_64", "macOS-arm64", "windows", "linux-x11", "linux-wayland","android", "iOS" ] + backend: + - "macOS-x86_64" + - "macOS-arm64" + - "windows" + - "linux-x11" + - "linux-wayland" + - "android" + - "iOS" + - "textual-linux" + - "textual-macOS" + - "textual-windows" include: - pre-command: "" briefcase-run-prefix: "" @@ -265,6 +275,25 @@ jobs: setup-python: false # Use the system Python packages app-user-data-path: "$HOME/.local/share/testbed" + - backend: "textual-linux" + platform: "linux" + runs-on: "ubuntu-22.04" + setup-python: false # Use the system Python packages + briefcase-run-args: --config 'requires=["../core","../textual"]' --config 'console_app=true' + app-user-data-path: "$HOME/.local/share/testbed" + + - backend: "textual-macOS" + platform: "macOS" + runs-on: "macos-14" + briefcase-run-args: --config 'requires=["../core","../textual"]' --config 'console_app=true' + app-user-data-path: "$HOME/Library/Application Support/org.beeware.toga.testbed" + + - backend: "textual-windows" + platform: "windows" + runs-on: "windows-latest" + briefcase-run-args: --config 'requires=["../core","../textual"]' --config 'console_app=true' + app-user-data-path: '$HOME\AppData\Local\Tiberius Yak\Toga Testbed\Data' + - backend: "windows" platform: "windows" runs-on: "windows-latest" @@ -274,7 +303,7 @@ jobs: platform: "iOS" runs-on: "macos-14" # As of early April 2024, the XCode 15/iOS 17 simulator had a performance - # issue that rendered Github Actions testing impossible. The issue didn't + # issue that rendered GitHub Actions testing impossible. The issue didn't # impact iOS 16.4, but that required the use of Xcode 14.3.1. # # Refs #2476, actions/runner-images#9591. @@ -301,7 +330,7 @@ jobs: sudo udevadm control --reload-rules sudo udevadm trigger --name-match=kvm steps: - # Github runners seem to have intermittent connectivity issues. + # GitHub runners seem to have intermittent connectivity issues. # See https://github.com/beeware/toga/issues/2632 - name: Tune GitHub-hosted runner network uses: smorimoto/tune-github-hosted-runner-network@v1.0.0 @@ -328,7 +357,10 @@ jobs: python -m pip install -U pip # python -m pip install git+https://github.com/beeware/briefcase.git # TODO: Use the stable release of Briefcase so that binary packages are available. - python -m pip install briefcase==0.3.19 + # python -m pip install briefcase==0.3.19 + + - name: Install Briefcase + uses: beeware/.github/.github/actions/install-briefcase - name: Test App working-directory: testbed diff --git a/testbed/pyproject.toml b/testbed/pyproject.toml index f00dc908fd..0ca0eac88e 100644 --- a/testbed/pyproject.toml +++ b/testbed/pyproject.toml @@ -59,7 +59,6 @@ requires = [ "../gtk", ] - [tool.briefcase.app.testbed.windows] test_sources = [ "../winforms/tests_backend", diff --git a/testbed/tests/testbed.py b/testbed/tests/testbed.py index 27f79db9cb..31f9c7902c 100644 --- a/testbed/tests/testbed.py +++ b/testbed/tests/testbed.py @@ -37,6 +37,13 @@ def run_tests(app, cov, args, report_coverage, run_slow, running_in_ci): return print("ready.") + + # Textual backend does not yet support testing. + # However, this will verify a Textual app can, at least, start. + if app.factory.__name__.startswith("toga_textual"): + app.returncode = 0 + return + # Control the run speed of the test app. app.run_slow = run_slow @@ -152,6 +159,9 @@ def run_tests(app, cov, args, report_coverage, run_slow, running_in_ci): # Create the test app, starting the test suite as a background task app = main() + # For platforms that support it, disable the app from displaying itself + app.headless = True + # Determine pytest arguments args = sys.argv[1:] diff --git a/textual/src/toga_textual/app.py b/textual/src/toga_textual/app.py index ad1eed2e66..895cb9a033 100644 --- a/textual/src/toga_textual/app.py +++ b/textual/src/toga_textual/app.py @@ -29,6 +29,9 @@ def __init__(self, interface): self.loop = asyncio.new_event_loop() self.native = TogaApp(self) + # whether the app should run without displaying itself + self.interface.headless = False + def create(self): self.interface._startup() self.set_current_window(self.interface.main_window._impl) @@ -51,7 +54,9 @@ def exit(self): self.native.exit() def main_loop(self): - self.loop.run_until_complete(self.native.run_async()) + self.loop.run_until_complete( + self.native.run_async(headless=self.interface.headless) + ) def set_icon(self, icon): pass