Skip to content

Commit

Permalink
Experiment with running testbed with Textual
Browse files Browse the repository at this point in the history
  • Loading branch information
rmartin16 committed Sep 8, 2024
1 parent 02bbfc8 commit 4a63acb
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 157 deletions.
325 changes: 170 additions & 155 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,166 +30,174 @@ 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"
include:
- pre-command: ""
briefcase-run-prefix: ""
Expand Down Expand Up @@ -265,6 +273,13 @@ jobs:
setup-python: false # Use the system Python packages
app-user-data-path: "$HOME/.local/share/testbed"

- backend: "textual"
platform: "macOS"
runs-on: "macos-14"
briefcase-run-args: --config 'requires=["../core","../textual"]' --config 'test_sources=[]'
app-user-data-path: "$HOME/Library/Application Support/org.beeware.toga.testbed"
# app-user-data-path: "$HOME/.local/share/testbed"

- backend: "windows"
platform: "windows"
runs-on: "windows-latest"
Expand All @@ -274,7 +289,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.
Expand All @@ -301,7 +316,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
Expand Down
1 change: 0 additions & 1 deletion testbed/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ requires = [
"../gtk",
]


[tool.briefcase.app.testbed.windows]
test_sources = [
"../winforms/tests_backend",
Expand Down
10 changes: 10 additions & 0 deletions testbed/tests/testbed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:]

Expand Down
Loading

0 comments on commit 4a63acb

Please sign in to comment.