Skip to content

Commit

Permalink
Run apps created in app-build-verify
Browse files Browse the repository at this point in the history
  • Loading branch information
rmartin16 committed Nov 19, 2023
1 parent 67c0adb commit 098cdb0
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 104 deletions.
27 changes: 21 additions & 6 deletions .github/actions/app-create/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ inputs:
briefcase-template-branch:
description: "The git branch for the template to use to roll out the project."
required: false
enable-automation:
description: "Whether to create a project using the Briefcase Automation plugin."
default: "false" # all composite workflow inputs are of type string
testing-pr-body:
description: "Override value for body of PR; only for testing."
required: false
Expand Down Expand Up @@ -52,6 +55,12 @@ runs:
echo "repo=${TEMPLATE_REPO}" | tee -a ${GITHUB_OUTPUT}
echo "ref=${TEMPLATE_REF}" | tee -a ${GITHUB_OUTPUT}
- name: Install Briefcase Automation Plugin
if: inputs.enable-automation != 'false'
shell: bash
# !!!! TODO:PR: establish permanent home for this package !!!!
run: python -m pip install git+https://github.com/rmartin16/briefcase-plugin-test

- name: Create Briefcase Project
id: create
shell: bash
Expand All @@ -65,12 +74,18 @@ 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 }} ;;
GUI_TOOLKIT="${{ inputs.framework }}"
[ "${{ inputs.enable-automation }}" != "false" ] && GUI_TOOLKIT="${GUI_TOOLKIT}-auto"
case "$(tr '[:upper:]' '[:lower:]' <<< "${GUI_TOOLKIT}")" in
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"
Expand Down
146 changes: 99 additions & 47 deletions .github/workflows/app-build-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ 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: ""
workflow-repo:
# Only needed for PRs in other repos wanting to test new workflow changes before they are merged.
# These inputs should not be specified by another repo on their main branch.
description: "The repo to use to run additional workflows and actions."
default: "beeware/.github"
type: string
briefcase-template-branch:
description: "Git branch to use for --template-branch for `briefcase new` to create app."
workflow-repo-ref:
description: "The repo ref to use to run additional workflows and actions."
default: ""
type: string

Expand All @@ -52,48 +54,53 @@ jobs:
verify-app:
name: Verify App Build
runs-on: ${{ inputs.runner-os }}
timeout-minutes: 30
env:
QT_QPA_PLATFORM: offscreen # disable display for Qt
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/[email protected]
with:
repository: ${{ inputs.repository }}
fetch-depth: 0

- name: Checkout beeware/.github
- name: Checkout ${{ inputs.workflow-repo }}${{ inputs.workflow-repo-ref && format('@{0}', inputs.workflow-repo-ref) || '' }}
uses: actions/[email protected]
with:
repository: beeware/.github
repository: ${{ inputs.workflow-repo }}
ref: ${{ inputs.workflow-repo-ref }}
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/[email protected]
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/[email protected]
with:
python-version: ${{ inputs.python-version }}
Expand All @@ -103,24 +110,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/[email protected]
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}
Expand All @@ -130,8 +137,8 @@ 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 }}
enable-automation: true

- name: Determine Output Format Configuration
# only used for the template repos so apps are built with the PR version of the template;
Expand All @@ -155,6 +162,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
Expand All @@ -167,50 +175,56 @@ 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
if: >
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
if: >
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)
Expand All @@ -232,10 +246,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: >
Expand Down Expand Up @@ -269,6 +283,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.
Expand All @@ -280,22 +303,25 @@ 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
if: >
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
Expand All @@ -305,9 +331,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 running 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
Expand All @@ -321,6 +372,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
Expand Down
Loading

0 comments on commit 098cdb0

Please sign in to comment.