Skip to content

Rework implementation of app paths to factor out common implementations. #3250

Rework implementation of app paths to factor out common implementations.

Rework implementation of app paths to factor out common implementations. #3250

Workflow file for this run

name: CI
on:
pull_request:
push:
branches:
- main
workflow_call:
outputs:
artifact-name:
description: "Name of the uploaded artifact; use for artifact retrieval."
value: ${{ jobs.package.outputs.artifact-name }}
env:
min_python_version: "3.7"
max_python_version: "3.11"
defaults:
run:
shell: bash
# Cancel active CI runs for a PR before starting another run
concurrency:
group: ${{ github.ref }}
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: Python Package
uses: beeware/.github/.github/workflows/python-package-create.yml@main
with:
tox-source: "./core[dev]"
build-subdirectory: ${{ matrix.subdir }}
distribution-path: "*/dist/*"
strategy:
matrix:
subdir:
- "android"
- "cocoa"
- "core"
- "demo"
- "dummy"
- "gtk"
- "iOS"
- "toga"
- "web"
- "winforms"
core:
runs-on: ${{ matrix.platform }}-latest
needs: [pre-commit, towncrier, package]
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
platform: [ "macos", "ubuntu", "windows" ]
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev" ]
include:
- experimental: false
- python-version: "3.12-dev"
experimental: true
steps:
- uses: actions/checkout@v3.5.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4.6.1
with:
python-version: ${{ matrix.python-version }}
- name: Install dev dependencies
run: |
# We don't actually want to install toga-core;
# we just want the dev extras so we have a known version of tox and coverage
python -m pip install ./core[dev]
- name: Get packages
uses: actions/download-artifact@v3.0.2
with:
name: ${{ needs.package.outputs.artifact-name }}
- 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 core/dist/toga_core-*.whl)[dev] ../$(ls dummy/dist/toga_dummy-*.whl)" tox -e py-core
cd core
mv .coverage .coverage.${{ matrix.platform }}.${{ matrix.python-version }}
- name: Store coverage data
uses: actions/upload-artifact@v3.1.2
with:
name: core-coverage-data
path: "core/.coverage.*"
if-no-files-found: error
core-coverage:
name: Combine & check core coverage.
runs-on: ubuntu-latest
needs: core
steps:
- uses: actions/checkout@v3.5.2
with:
fetch-depth: 0
- uses: actions/setup-python@v4.6.1
with:
# Use latest, so it understands all syntax.
python-version: ${{ env.max_python_version }}
- name: Install dev dependencies
run: |
# We don't actually want to install toga-core;
# we just want the dev extras so we have a known version of coverage
python -m pip install ./core[dev]
- name: Retrieve coverage data
uses: actions/download-artifact@v3.0.2
with:
name: core-coverage-data
path: core
- name: Generate coverage report
run: |
cd core
python -m coverage combine
python -m coverage html --skip-covered --skip-empty
python -m coverage report --rcfile ../pyproject.toml # --fail-under=100
- name: Upload HTML report if check failed.
uses: actions/upload-artifact@v3.1.2
with:
name: html-coverage-report
path: core/htmlcov
if: ${{ failure() }}
backend:
runs-on: ${{ matrix.runs-on }}
needs: [package, core]
strategy:
matrix:
backend: [ "android", "cocoa", "gtk", "iOS", "web", "winforms" ]
include:
- runs-on: ubuntu-latest
- python-version: "3.7" # Should be env.min_python_version (https://github.com/actions/runner/issues/480)
- pre-command:
- backend: cocoa
runs-on: macos-latest
- backend: gtk
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 libfuse2"
- backend: iOS
runs-on: macos-latest
- backend: winforms
runs-on: windows-latest
# Py3.9 is the first Python version for which
# a wheel of pythonnet isn't available on PyPI.
python-version: "3.9"
steps:
- uses: actions/checkout@v3.5.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4.6.1
with:
python-version: ${{ matrix.python-version }}
- name: Get packages
uses: actions/download-artifact@v3.0.2
with:
name: ${{ needs.package.outputs.artifact-name }}
- name: Install dev dependencies
run: |
${{ matrix.pre-command }}
# We don't actually want to install toga-core;
# we just want the dev extras so we have a known version of tox
python -m pip install ./core[dev]
- 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 core/dist/toga_core-*.whl)[dev] ../$(ls dummy/dist/toga_dummy-*.whl) ../$(ls ${{ matrix.backend }}/dist/toga_${{ matrix.backend }}-*.whl)" tox -e py-${{ matrix.backend }}
testbed:
runs-on: ${{ matrix.runs-on }}
needs: core
strategy:
fail-fast: false
matrix:
backend: [ "macOS", "windows", "linux", "android", "iOS" ]
include:
- pre-command:
briefcase-run-prefix:
briefcase-run-args:
setup-python: true
- backend: macOS
runs-on: macos-12
# We use a fixed Ubuntu version rather than `-latest` because at some point,
# `-latest` will be updated, but it will be a soft changeover, which would cause
# the system Python version to become inconsistent from run to run.
- backend: linux
runs-on: ubuntu-22.04
# The package list should be the same as in tutorial-0.rst, and the BeeWare
# tutorial, plus flwm to provide a window manager
pre-command: |
sudo apt-get update -y && sudo apt-get install -y python3-dev python3-cairo-dev python3-gi-cairo libgirepository1.0-dev libcairo2-dev libpango1.0-dev gir1.2-webkit2-4.0 pkg-config flwm
# Start Virtual X server
echo "Start X server..."
Xvfb :99 -screen 0 2048x1536x24 &
sleep 1
# Start Window manager
echo "Start window manager..."
DISPLAY=:99 flwm &
sleep 1
briefcase-run-prefix: 'DISPLAY=:99'
setup-python: false # Use the system Python packages.
- 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"
steps:
- uses: actions/checkout@v3.5.2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4.6.1
if: ${{ matrix.setup-python }}
with:
python-version: "3.X"
- name: Install dependencies
run: |
${{ matrix.pre-command }}
# Use the development version of Briefcase
python -m pip install git+https://github.com/beeware/briefcase.git
- name: Test App
run: |
cd testbed
${{ matrix.briefcase-run-prefix }} briefcase run ${{ matrix.backend }} --test ${{ matrix.briefcase-run-args }}
- name: Upload logs
uses: actions/upload-artifact@v3.1.2
if: failure()
with:
name: testbed-failure-logs-${{ matrix.backend }}
path: testbed/logs/*