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 e71d064
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 106 deletions.
18 changes: 13 additions & 5 deletions .github/actions/app-create/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
141 changes: 92 additions & 49 deletions .github/workflows/app-build-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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 }}
Expand All @@ -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}
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -167,50 +166,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 +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: >
Expand Down Expand Up @@ -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.
Expand All @@ -280,22 +294,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 +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
Expand All @@ -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
Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/app-create-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -39,6 +31,7 @@ jobs:
verify-app:
name: Verify App Create
runs-on: ${{ inputs.runner-os }}
timeout-minutes: 30
steps:

- name: Checkout ${{ github.repository }}
Expand Down Expand Up @@ -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
Expand All @@ -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 }}
Expand Down
Loading

0 comments on commit e71d064

Please sign in to comment.