From e71d06494149a62cac99af89732cc2ac8206c486 Mon Sep 17 00:00:00 2001 From: Russell Martin Date: Sat, 18 Nov 2023 04:01:57 -0500 Subject: [PATCH] Run apps created in `app-build-verify` --- .github/actions/app-create/action.yml | 18 ++- .github/workflows/app-build-verify.yml | 141 ++++++++++++++++-------- .github/workflows/app-create-verify.yml | 13 +-- .github/workflows/ci.yml | 95 +++++++++------- 4 files changed, 161 insertions(+), 106 deletions(-) diff --git a/.github/actions/app-create/action.yml b/.github/actions/app-create/action.yml index 13922c83..0dbcbbe2 100644 --- a/.github/actions/app-create/action.yml +++ b/.github/actions/app-create/action.yml @@ -52,6 +52,10 @@ runs: echo "repo=${TEMPLATE_REPO}" | tee -a ${GITHUB_OUTPUT} echo "ref=${TEMPLATE_REF}" | tee -a ${GITHUB_OUTPUT} + - name: Install Briefcase Automation Plugin + shell: bash + run: python -m pip install git+https://github.com/rmartin16/briefcase-plugin-test + - name: Create Briefcase Project id: create shell: bash @@ -66,11 +70,15 @@ runs: # Map the requested GUI toolkit to the input that Briefcase expects # Default to the input to accommodate arbitrary toolkits installed as plugins case "$(tr '[:upper:]' '[:lower:]' <<< '${{ inputs.framework }}')" in - toga ) GUI_INPUT=1 ;; - pyside6 ) GUI_INPUT=2 ;; - ppb ) GUI_INPUT=3 ;; - pygame ) GUI_INPUT=4 ;; - * ) GUI_INPUT=${{ inputs.framework }} ;; + toga ) GUI_INPUT=1 ;; + toga-auto ) GUI_INPUT=8 ;; + pyside6 ) GUI_INPUT=2 ;; + pyside6-auto ) GUI_INPUT=6 ;; + ppb ) GUI_INPUT=3 ;; + ppb-auto ) GUI_INPUT=5 ;; + pygame ) GUI_INPUT=4 ;; + pygame-auto ) GUI_INPUT=7 ;; + * ) GUI_INPUT=${{ inputs.framework }} ;; esac ROOT_DIR="apps" diff --git a/.github/workflows/app-build-verify.yml b/.github/workflows/app-build-verify.yml index a21679bd..7de26d6c 100644 --- a/.github/workflows/app-build-verify.yml +++ b/.github/workflows/app-build-verify.yml @@ -32,14 +32,6 @@ on: description: "The target format for the app, e.g. appimage, xcode, app, etc. Leave blank all supported formats." default: "" type: string - briefcase-template-source: - description: "Path to use for --template for `briefcase new` to create app." - default: "" - type: string - briefcase-template-branch: - description: "Git branch to use for --template-branch for `briefcase new` to create app." - default: "" - type: string defaults: run: @@ -52,8 +44,27 @@ jobs: verify-app: name: Verify App Build runs-on: ${{ inputs.runner-os }} + timeout-minutes: 30 + env: + QT_QPA_PLATFORM: offscreen # set window for PySide6 + SDL_AUDIODRIVER: dummy # disable audio for SDL + SDL_VIDEODRIVER: dummy # disable display for SDL steps: + - name: Workflow Constants + id: constants + run: | + case "$(tr '[:upper:]' '[:lower:]' <<< '${{ inputs.runner-os }}')" in + ubuntu* ) BRIEFCASE_DIR="$HOME/.cache/briefcase" ;; + macos* ) BRIEFCASE_DIR="$HOME/Library/Caches/org.beeware.briefcase" ;; + windows* ) BRIEFCASE_DIR="$HOME/AppData/Local/BeeWare/briefcase/Cache" ;; + * ) echo "::error::Failed to determine the Briefcase data directory path" ;; + esac + echo "briefcase-data-dir=${BRIEFCASE_DIR}" | tee -a ${GITHUB_OUTPUT} + + SYSTEM_PYTHON_VER=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")') + echo "system-python-version=${SYSTEM_PYTHON_VER}" | tee -a ${GITHUB_OUTPUT} + - name: Checkout ${{ inputs.repository }} uses: actions/checkout@v4.1.1 with: @@ -63,37 +74,25 @@ jobs: - name: Checkout beeware/.github uses: actions/checkout@v4.1.1 with: - repository: beeware/.github +# repository: beeware/.github +# # If this workflow is running from a branch other than main, then any other +# # workflows/actions subsequently invoked should also be from that .github branch. +# ref: ${{ github.workflow_sha }} path: beeware-.github - - name: Package Name - id: package - run: echo "name=$(basename '${{ inputs.repository }}')" | tee -a ${GITHUB_OUTPUT} - - - name: Determine Cache Directory - id: dirs - run: | - case "$(tr '[:upper:]' '[:lower:]' <<< '${{ inputs.runner-os }}')" in - ubuntu* ) BRIEFCASE_DIR="~/.cache/briefcase" ;; - macos* ) BRIEFCASE_DIR="~/Library/Caches/org.beeware.briefcase" ;; - windows* ) BRIEFCASE_DIR="~/AppData/Local/BeeWare/briefcase/Cache" ;; - * ) echo "::error::Failed to determine the Briefcase data directory path" ;; - esac - echo "briefcase-data-dir=${BRIEFCASE_DIR}" | tee -a ${GITHUB_OUTPUT} + - name: Update Package Manager + if: startsWith(inputs.runner-os, 'ubuntu') + run: sudo apt --assume-yes update - name: Cache Briefcase Tools uses: actions/cache@v3.3.2 with: key: briefcase-data|${{ inputs.runner-os }}|${{ inputs.repository }}|${{ inputs.framework }}|${{ inputs.target-platform }}|${{ inputs.target-format }} - path: ${{ steps.dirs.outputs.briefcase-data-dir }} - - - name: Determine System python3 Version - id: system-python - run: | - SYSTEM_PYTHON_VER=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")') - echo "version=${SYSTEM_PYTHON_VER}" | tee -a ${GITHUB_OUTPUT} + path: ${{ steps.constants.outputs.briefcase-data-dir }} - name: Set Up Python + # Linux System requires python is System Python to run the app + if: ${{ !startsWith(inputs.runner-os, 'ubuntu') }} uses: actions/setup-python@v4.7.1 with: python-version: ${{ inputs.python-version }} @@ -103,24 +102,24 @@ jobs: **/pyproject.toml .pre-commit-config.yaml - - name: Get Packages + - name: Get Briefcase Package # Briefcase will build and package itself in a previous step in its CI if: endsWith(inputs.repository, 'briefcase') uses: actions/download-artifact@v3.0.2 with: - name: packages-${{ steps.package.outputs.name }} + name: packages-briefcase path: dist - name: Install Briefcase Artefact if: endsWith(inputs.repository, 'briefcase') - run: python -m pip install dist/briefcase-*.whl + run: python3 -m pip install dist/briefcase-*.whl - name: Install Briefcase if: ${{ !endsWith(inputs.repository, 'briefcase') }} uses: ./beeware-.github/.github/actions/install-briefcase - name: Determine Briefcase Template Path - # If the briefcase-template repo is being tested, use the current checkout + # If the briefcase-template repo is being tested, use its current checkout id: template if: endsWith(inputs.repository, 'briefcase-template') run: echo "path=${{ github.workspace }}" | tee -a ${GITHUB_OUTPUT} @@ -130,8 +129,7 @@ jobs: uses: ./beeware-.github/.github/actions/app-create with: framework: ${{ inputs.framework }} - briefcase-template-source: ${{ inputs.briefcase-template-source || steps.template.outputs.path }} - briefcase-template-branch: ${{ inputs.briefcase-template-branch }} + briefcase-template-source: ${{ steps.template.outputs.path }} - name: Determine Output Format Configuration # only used for the template repos so apps are built with the PR version of the template; @@ -155,6 +153,7 @@ jobs: briefcase create macOS app \ ${{ steps.output-format.outputs.template-override }} briefcase build macOS app + briefcase run macOS app briefcase package macOS app --adhoc-sign - name: Build macOS Xcode Project @@ -167,6 +166,7 @@ jobs: briefcase create macOS Xcode \ ${{ steps.output-format.outputs.template-override }} briefcase build macOS Xcode + briefcase run macOS Xcode briefcase package macOS Xcode --adhoc-sign - name: Build Windows App @@ -174,13 +174,12 @@ jobs: startsWith(inputs.runner-os, 'Windows') && contains(fromJSON('["", "Windows"]'), inputs.target-platform) && contains(fromJSON('["", "app"]'), inputs.target-format) - env: - WIX: "" # force Briefcase to install and use its own version of WiX working-directory: ${{ steps.create.outputs.project-path }} run: | briefcase create windows app \ ${{ steps.output-format.outputs.template-override }} briefcase build windows app + briefcase run windows app briefcase package windows app --adhoc-sign - name: Build Windows Visual Studio Project @@ -188,29 +187,35 @@ jobs: startsWith(inputs.runner-os, 'Windows') && contains(fromJSON('["", "Windows"]'), inputs.target-platform) && contains(fromJSON('["", "VisualStudio"]'), inputs.target-format) - env: - WIX: "" # force Briefcase to install and use its own version of WiX working-directory: ${{ steps.create.outputs.project-path }} run: | briefcase create windows VisualStudio \ ${{ steps.output-format.outputs.template-override }} briefcase build windows VisualStudio + briefcase run windows VisualStudio briefcase package windows VisualStudio --adhoc-sign - name: Build Linux System Project (Ubuntu, local) if: > startsWith(inputs.runner-os, 'ubuntu') - && startsWith(inputs.python-version, steps.system-python.outputs.version) + && startsWith(inputs.python-version, steps.constants.outputs.system-python-version) && contains(fromJSON('["", "Linux"]'), inputs.target-platform) && contains(fromJSON('["", "system"]'), inputs.target-format) working-directory: ${{ steps.create.outputs.project-path }} run: | - sudo apt update -y - sudo apt install -y --no-install-recommends python3-dev python3-pip libcairo2-dev libgirepository1.0-dev + PACKAGES="python3-dev python3-pip" + case "$(tr '[:upper:]' '[:lower:]' <<< '${{ inputs.framework }}')" in + toga* ) PACKAGES="${PACKAGES} libcairo2-dev libgirepository1.0-dev gir1.2-gtk-3.0" ;; + pyside6* ) PACKAGES="${PACKAGES} libegl1" ;; + ppb* ) PACKAGES="${PACKAGES} libsdl2-2.0-0 libsdl2-mixer-2.0-0 libsdl2-image-2.0-0 libsdl2-gfx-1.0-0 libsdl2-ttf-2.0-0" ;; + esac + + sudo apt --assume-yes install --no-install-recommends ${PACKAGES} briefcase create linux system \ ${{ steps.output-format.outputs.template-override }} briefcase build linux system + xvfb-run briefcase run linux system briefcase package linux system --adhoc-sign - name: Build Linux System Project (Debian, Dockerized) @@ -232,10 +237,10 @@ jobs: && contains(fromJSON('["", "system"]'), inputs.target-format) working-directory: ${{ steps.create.outputs.project-path }} run: | - briefcase create linux system --target fedora:37 \ + briefcase create linux system --target fedora:39 \ ${{ steps.output-format.outputs.template-override }} - briefcase build linux system --target fedora:37 - briefcase package linux system --target fedora:37 --adhoc-sign + briefcase build linux system --target fedora:39 + briefcase package linux system --target fedora:39 --adhoc-sign - name: Build Linux System Project (Arch, Dockerized) if: > @@ -269,6 +274,15 @@ jobs: && contains(fromJSON('["AppImage"]'), inputs.target-format) working-directory: ${{ steps.create.outputs.project-path }} run: | + PACKAGES="libfuse2" + case "$(tr '[:upper:]' '[:lower:]' <<< '${{ inputs.framework }}')" in + toga* ) PACKAGES="${PACKAGES} libthai-dev libegl1" ;; + pyside6* ) PACKAGES="${PACKAGES} libegl1" ;; + ppb* ) PACKAGES="${PACKAGES} libsdl2-2.0-0 libsdl2-mixer-2.0-0 libsdl2-image-2.0-0 libsdl2-gfx-1.0-0 libsdl2-ttf-2.0-0" ;; + esac + + sudo apt --assume-yes install --no-install-recommends ${PACKAGES} + # PyGObject>=3.46.0 requires a version of glibc that isn't available in manylinux images; # so, the version will need to be constrained to successfully build an AppImage with Toga. # Furthermore, Toga>0.3.1 requires PyGObject>=3.46.0 so its version is constrained as well. @@ -280,6 +294,7 @@ jobs: ${{ steps.output-format.outputs.template-override }} \ ${CONFIG_OVERRIDE_REQUIRES} briefcase build linux AppImage + xvfb-run briefcase run linux AppImage briefcase package linux AppImage --adhoc-sign - name: Build Flatpak Project @@ -287,15 +302,17 @@ jobs: startsWith(inputs.runner-os, 'ubuntu') && contains(fromJSON('["", "Linux"]'), inputs.target-platform) && contains(fromJSON('["", "Flatpak"]'), inputs.target-format) - && contains(fromJSON('["Toga", "PyGame"]'), inputs.framework) working-directory: ${{ steps.create.outputs.project-path }} run: | - sudo apt update -y - sudo apt install -y --no-install-recommends flatpak flatpak-builder elfutils + sudo apt --assume-yes install --no-install-recommends flatpak flatpak-builder elfutils briefcase create linux flatpak \ ${{ steps.output-format.outputs.template-override }} + # enable OpenGL rendering + sed -i 's/ - --socket=session-bus/ - --socket=session-bus\n - --device=dri/g' \ + build/verifyapp/linux/flatpak/manifest.yml briefcase build linux flatpak + xvfb-run briefcase run linux flatpak briefcase package linux flatpak --adhoc-sign - name: Build Android App @@ -305,9 +322,34 @@ jobs: && startsWith(inputs.framework, 'toga') working-directory: ${{ steps.create.outputs.project-path }} run: | + export JAVA_HOME=${JAVA_HOME_17_X64} + briefcase create android gradle \ ${{ steps.output-format.outputs.template-override }} briefcase build android gradle + + # On Linux, enable hardware acceleration for virtualization + if [ "${{ startsWith(inputs.runner-os, 'ubuntu') }}" = "true" ]; then + # check if virtualization is supported... + sudo apt --assume-yes install --no-install-recommends cpu-checker coreutils && echo "CPUs=$(nproc --all)" && kvm-ok + # allow access to KVM to run the emulator + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \ + | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + fi + + # Skipping on Windows since emulator doesn't start + if [ "${{ startsWith(inputs.runner-os, 'windows') }}" = "false" ]; then + briefcase run android gradle \ + -d '{"avd":"beePhone"}' \ + --Xemulator=-no-window \ + --Xemulator=-no-snapshot \ + --Xemulator=-no-audio \ + --Xemulator=-no-boot-anim \ + --shutdown-on-exit + fi + briefcase package android gradle --adhoc-sign - name: Build iOS App @@ -321,6 +363,7 @@ jobs: briefcase create iOS xcode \ ${{ steps.output-format.outputs.template-override }} briefcase build iOS xcode + briefcase run iOS xcode -d "iPhone SE (3rd generation)" briefcase package iOS xcode --adhoc-sign - name: Build Web App diff --git a/.github/workflows/app-create-verify.yml b/.github/workflows/app-create-verify.yml index b332e8b4..7d9c2260 100644 --- a/.github/workflows/app-create-verify.yml +++ b/.github/workflows/app-create-verify.yml @@ -19,14 +19,6 @@ on: description: "Framework to use to build the App, e.g. toga." required: true type: string - briefcase-template-source: - description: "Path to use for --template for `briefcase new` to create app." - default: "" - type: string - briefcase-template-branch: - description: "Git branch to use for --template-branch for `briefcase new` to create app." - default: "" - type: string defaults: run: @@ -39,6 +31,7 @@ jobs: verify-app: name: Verify App Create runs-on: ${{ inputs.runner-os }} + timeout-minutes: 30 steps: - name: Checkout ${{ github.repository }} @@ -82,6 +75,7 @@ jobs: path: dist - name: Install Dependencies + # must install before Briefcase below since requirements.txt contains an entry for Briefcase run: python -m pip install -Ur ./briefcase-template/requirements.txt - name: Install Briefcase Artefact @@ -103,8 +97,7 @@ jobs: uses: ./beeware-.github/.github/actions/app-create with: framework: ${{ inputs.framework }} - briefcase-template-source: ${{ inputs.briefcase-template-source || steps.template.outputs.path }} - briefcase-template-branch: ${{ inputs.briefcase-template-branch }} + briefcase-template-source: ${{ steps.template.outputs.path }} - name: Run Flake8 working-directory: ${{ steps.create.outputs.project-path }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30b24212..d48fe1da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: test-docs-build-verify: name: Verify Docs Build needs: pre-commit - # inheriting secrets does not work for forked repos + # inheriting secrets are not exposed to forked repos if: ${{ github.event.pull_request.head.repo.owner.login == 'beeware' }} uses: ./.github/workflows/docs-build-verify.yml secrets: inherit @@ -36,12 +36,12 @@ jobs: project-version: ${{ matrix.version }} strategy: matrix: - name: [ "briefcase", "toga" ] + name: [ briefcase, toga ] include: - - name: "briefcase" - version: "v0.3.13" - - name: "toga" - version: "v0.3.1" + - name: briefcase + version: v0.3.13 + - name: toga + version: v0.3.1 test-install-briefcase: name: Install Briefcase @@ -154,15 +154,15 @@ jobs: strategy: fail-fast: false matrix: - repo: [ "briefcase", "gbulb", "Python-support-testbed", "rubicon-objc", "toga" ] + repo: [ briefcase, gbulb, Python-support-testbed, rubicon-objc, toga ] include: - - pre-commit-source: ".[dev]" + - pre-commit-source: .[dev] - repo: gbulb - pre-commit-source: "pre-commit" + pre-commit-source: pre-commit - repo: Python-support-testbed - pre-commit-source: "pre-commit" + pre-commit-source: pre-commit - repo: toga - pre-commit-source: "./core[dev]" + pre-commit-source: ./core[dev] test-package-python: name: Create Package @@ -176,20 +176,20 @@ jobs: strategy: fail-fast: false matrix: - repo: [ "briefcase", "gbulb", "rubicon-objc", "toga" ] + repo: [ briefcase, gbulb, rubicon-objc, toga ] include: - - tox-source: ".[dev]" - - dist-path: "dist" - - repo: "gbulb" - tox-source: "tox" - dist-path: "dist" - - repo: "toga" - tox-source: "./core[dev]" + - tox-source: .[dev] + - dist-path: dist + - repo: gbulb + tox-source: tox + dist-path: dist + - repo: toga + tox-source: ./core[dev] dist-path: "*/dist/*" - build-subdir: "core" + build-subdir: core test-create-apps-briefcase: - name: Create Apps + name: Verify Project needs: [ pre-commit, test-package-python ] uses: ./.github/workflows/app-create-verify.yml with: @@ -199,8 +199,8 @@ jobs: strategy: fail-fast: false matrix: - framework: [ "toga", "pyside6" ] - runner-os: [ "macos-latest", "windows-latest", "ubuntu-22.04" ] + framework: [ toga, pyside6 ] + runner-os: [ macos-latest, windows-latest, ubuntu-22.04 ] test-verify-apps-briefcase: name: Verify Briefcase @@ -214,8 +214,8 @@ jobs: strategy: fail-fast: false matrix: - framework: [ "toga", "ppb" ] - runner-os: [ "macos-latest", "windows-latest", "ubuntu-22.04" ] + framework: [ toga-auto, ppb-auto ] + runner-os: [ macos-latest, windows-latest, ubuntu-22.04 ] test-verify-apps-briefcase-template: name: Verify Briefcase Template @@ -229,8 +229,8 @@ jobs: strategy: fail-fast: false matrix: - framework: [ "toga", "ppb" ] - runner-os: [ "macos-latest", "windows-latest", "ubuntu-latest" ] + framework: [ toga-auto, pyside6-auto ] + runner-os: [ macos-latest, windows-latest, ubuntu-latest ] test-verify-apps-android-templates: name: Verify Android @@ -242,11 +242,12 @@ jobs: runner-os: ${{ matrix.runner-os }} target-platform: android target-format: gradle - framework: toga + framework: ${{ matrix.framework }} strategy: fail-fast: false matrix: - runner-os: [ "macos-latest", "windows-latest", "ubuntu-latest" ] + framework: [ toga-auto ] # toga only + runner-os: [ macos-latest, windows-latest, ubuntu-latest ] test-verify-apps-iOS-templates: name: Verify iOS @@ -258,16 +259,18 @@ jobs: runner-os: macos-latest target-platform: iOS target-format: xcode - framework: toga + framework: ${{ matrix.framework }} + strategy: + fail-fast: false + matrix: + framework: [ toga-auto ] # toga only test-verify-apps-linux-system-templates: - name: Verify Linux System + name: Verify Linux needs: pre-commit uses: ./.github/workflows/app-build-verify.yml with: - # This *must* be the version of Python that is the system Python on ubuntu-22.04. - # Otherwise native system package builds won't be included. - python-version: "3.10" + python-version: "3.10" # must match system python for ubuntu version repository: beeware/briefcase-linux-system-template runner-os: ubuntu-22.04 target-platform: linux @@ -276,7 +279,7 @@ jobs: strategy: fail-fast: false matrix: - framework: [ "toga", "ppb" ] + framework: [ toga-auto, pyside6-auto, ppb-auto, pygame-auto ] test-verify-apps-appimage-templates: name: Verify AppImage @@ -288,7 +291,11 @@ jobs: runner-os: ubuntu-latest target-platform: linux target-format: appimage - framework: toga + framework: ${{ matrix.framework }} + strategy: + fail-fast: false + matrix: + framework: [ toga-auto, pyside6-auto, ppb-auto, pygame-auto ] test-verify-apps-flatpak-templates: name: Verify Flatpak @@ -304,7 +311,7 @@ jobs: strategy: fail-fast: false matrix: - framework: [ "toga", "pygame" ] + framework: [ toga-auto, pyside6-auto, ppb-auto, pygame-auto ] test-verify-apps-macOS-templates: name: Verify macOS @@ -320,8 +327,8 @@ jobs: strategy: fail-fast: false matrix: - format: [ "app", "Xcode" ] - framework: [ "toga", "ppb" ] + framework: [ toga-auto, pyside6-auto, ppb-auto, pygame-auto ] + format: [ app, Xcode ] test-verify-apps-web-templates: name: Verify Web @@ -333,7 +340,11 @@ jobs: runner-os: ubuntu-latest target-platform: web target-format: static - framework: toga + framework: ${{ matrix.framework }} + strategy: + fail-fast: false + matrix: + framework: [ toga-auto ] # toga only test-verify-apps-windows-templates: name: Verify Windows @@ -349,5 +360,5 @@ jobs: strategy: fail-fast: false matrix: - format: [ "app", "VisualStudio" ] - framework: [ "toga", "ppb" ] + framework: [ toga-auto, pyside6-auto, ppb-auto, pygame-auto ] + format: [ app, VisualStudio ]