Skip to content

Commit

Permalink
Use github.workspace as the path to the current template
Browse files Browse the repository at this point in the history
  • Loading branch information
rmartin16 committed Nov 17, 2023
1 parent c0647cb commit ee00f93
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 25 deletions.
8 changes: 8 additions & 0 deletions .github/actions/app-create/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ runs:
TEMPLATE_REPO=$(printf "%s" "${PR_BODY}" | perl -wlne '/BRIEFCASE[-_]*TEMPLATE[-_]*REPO:\s*\K\S+/i and print $&')
TEMPLATE_REF=$(printf "%s" "${PR_BODY}" | perl -wlne '/BRIEFCASE[-_]*TEMPLATE[-_]*REF:\s*\K\S+/i and print $&')
# If a template is not in the PR, use inputs specified in CI workflow
if [ -z "${TEMPLATE_REPO}" ]; then
TEMPLATE_REPO="${{ inputs.briefcase-template-source }}"
fi
if [ -z "${TEMPLATE_REF}" ]; then
TEMPLATE_REF="${{ inputs.briefcase-template-branch }}"
fi
# Expose template repo and branch via outputs
echo "repo=${TEMPLATE_REPO}" | tee -a ${GITHUB_OUTPUT}
echo "ref=${TEMPLATE_REF}" | tee -a ${GITHUB_OUTPUT}
Expand Down
54 changes: 36 additions & 18 deletions .github/workflows/app-build-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,18 @@ jobs:
# 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
id: template
if: endsWith(inputs.repository, 'briefcase-template')
run: echo "path=${{ github.workspace }}" | tee -a ${GITHUB_OUTPUT}

- name: Create Briefcase Project
id: create
uses: ./beeware-.github/.github/actions/app-create
with:
framework: ${{ inputs.framework }}
briefcase-template-source: ${{ inputs.briefcase-template-source }}
briefcase-template-source: ${{ inputs.briefcase-template-source || steps.template.outputs.path }}
briefcase-template-branch: ${{ inputs.briefcase-template-branch }}

- name: Determine Output Format Configuration
Expand All @@ -134,9 +140,9 @@ jobs:
if: endsWith(inputs.repository, '-template') && inputs.repository != 'beeware/briefcase-template'
id: output-format
run: |
# The current repo is cloned in to the current directory; that will
# be up levels up in the file system from the root of the app project
echo "template-override=--config 'template=\"../../\"'" | tee -a ${GITHUB_OUTPUT}
# Since the current repo is cloned in to the workspace, use it for the template
# echo "template-override=$(printf -- "--config template=%q" "'${{ github.workspace }}'")" | tee -a ${GITHUB_OUTPUT}
echo "template-override=--config template='${{ github.workspace }}'" | tee -a ${GITHUB_OUTPUT}
# In the steps below, using the builtin functions for comparison (instead of ==)
# allows for case-insensitivity to the inputs for the workflow.
Expand All @@ -148,7 +154,8 @@ jobs:
&& contains(fromJSON('["", "app"]'), inputs.target-format)
working-directory: ${{ steps.create.outputs.project-path }}
run: |
briefcase create macOS app ${{ steps.output-format.outputs.template-override }}
briefcase create macOS app \
${{ steps.output-format.outputs.template-override }}
briefcase build macOS app
briefcase package macOS app --adhoc-sign
Expand All @@ -159,7 +166,8 @@ jobs:
&& contains(fromJSON('["", "Xcode"]'), inputs.target-format)
working-directory: ${{ steps.create.outputs.project-path }}
run: |
briefcase create macOS Xcode ${{ steps.output-format.outputs.template-override }}
briefcase create macOS Xcode \
${{ steps.output-format.outputs.template-override }}
briefcase build macOS Xcode
briefcase package macOS Xcode --adhoc-sign
Expand All @@ -172,7 +180,8 @@ jobs:
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 create windows app \
${{ steps.output-format.outputs.template-override }}
briefcase build windows app
briefcase package windows app --adhoc-sign
Expand All @@ -185,7 +194,8 @@ jobs:
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 create windows VisualStudio \
${{ steps.output-format.outputs.template-override }}
briefcase build windows VisualStudio
briefcase package windows VisualStudio --adhoc-sign
Expand All @@ -200,7 +210,8 @@ jobs:
sudo apt update -y
sudo apt install -y --no-install-recommends python3-dev python3-pip libcairo2-dev libgirepository1.0-dev
briefcase create linux system ${{ steps.output-format.outputs.template-override }}
briefcase create linux system \
${{ steps.output-format.outputs.template-override }}
briefcase build linux system
briefcase package linux system --adhoc-sign
Expand All @@ -211,7 +222,8 @@ jobs:
&& contains(fromJSON('["", "system"]'), inputs.target-format)
working-directory: ${{ steps.create.outputs.project-path }}
run: |
briefcase create linux system --target debian:bullseye ${{ steps.output-format.outputs.template-override }}
briefcase create linux system --target debian:bullseye \
${{ steps.output-format.outputs.template-override }}
briefcase build linux system --target debian:bullseye
briefcase package linux system --target debian:bullseye --adhoc-sign
Expand All @@ -222,7 +234,8 @@ jobs:
&& contains(fromJSON('["", "system"]'), inputs.target-format)
working-directory: ${{ steps.create.outputs.project-path }}
run: |
briefcase create linux system --target fedora:37 ${{ steps.output-format.outputs.template-override }}
briefcase create linux system --target fedora:37 \
${{ steps.output-format.outputs.template-override }}
briefcase build linux system --target fedora:37
briefcase package linux system --target fedora:37 --adhoc-sign
Expand All @@ -233,7 +246,8 @@ jobs:
&& contains(fromJSON('["", "system"]'), inputs.target-format)
working-directory: ${{ steps.create.outputs.project-path }}
run: |
briefcase create linux system --target archlinux:latest ${{ steps.output-format.outputs.template-override }}
briefcase create linux system --target archlinux:latest \
${{ steps.output-format.outputs.template-override }}
briefcase build linux system --target archlinux:latest
briefcase package linux system --target archlinux:latest --adhoc-sign
Expand Down Expand Up @@ -261,12 +275,12 @@ jobs:
# 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.
if [ "${{ startsWith(inputs.framework, 'toga') }}" = "true" ]; then
CONFIG_OVERRIDE_REQUIRES='requires=["toga-gtk==0.3.1", "PyGobject<3.46.0"]'
CONFIG_OVERRIDE_REQUIRES='--config requires=["toga-gtk==0.3.1","PyGobject<3.46.0"]'
fi
briefcase create linux AppImage \
${{ steps.output-format.outputs.template-override }} \
--config $(printf '%s' $CONFIG_OVERRIDE_REQUIRES)
${CONFIG_OVERRIDE_REQUIRES}
briefcase build linux AppImage
briefcase package linux AppImage --adhoc-sign
Expand All @@ -281,7 +295,8 @@ jobs:
sudo apt update -y
sudo apt install -y --no-install-recommends flatpak flatpak-builder elfutils
briefcase create linux flatpak ${{ steps.output-format.outputs.template-override }}
briefcase create linux flatpak \
${{ steps.output-format.outputs.template-override }}
briefcase build linux flatpak
briefcase package linux flatpak --adhoc-sign
Expand All @@ -292,7 +307,8 @@ jobs:
&& startsWith(inputs.framework, 'toga')
working-directory: ${{ steps.create.outputs.project-path }}
run: |
briefcase create android gradle ${{ steps.output-format.outputs.template-override }}
briefcase create android gradle \
${{ steps.output-format.outputs.template-override }}
briefcase build android gradle
briefcase package android gradle --adhoc-sign
Expand All @@ -304,7 +320,8 @@ jobs:
&& startsWith(inputs.framework, 'toga')
working-directory: ${{ steps.create.outputs.project-path }}
run: |
briefcase create iOS xcode ${{ steps.output-format.outputs.template-override }}
briefcase create iOS xcode \
${{ steps.output-format.outputs.template-override }}
briefcase build iOS xcode
briefcase package iOS xcode --adhoc-sign
Expand All @@ -315,7 +332,8 @@ jobs:
&& startsWith(inputs.framework, 'toga')
working-directory: ${{ steps.create.outputs.project-path }}
run: |
briefcase create web static ${{ steps.output-format.outputs.template-override }}
briefcase create web static \
${{ steps.output-format.outputs.template-override }}
briefcase build web static
briefcase package web static
Expand Down
24 changes: 18 additions & 6 deletions .github/workflows/app-create-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ jobs:
runs-on: ${{ inputs.runner-os }}
steps:

- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4.1.1
with:
repository: ${{ github.repository }}
fetch-depth: 0

- name: Checkout beeware/.github
uses: actions/checkout@v4.1.1
with:
Expand All @@ -57,20 +63,20 @@ jobs:

- name: Package Name
id: package
run: echo "name=$(basename '${{ inputs.repository }}')" >> ${GITHUB_OUTPUT}
run: echo "name=$(basename '${{ github.repository }}')" >> ${GITHUB_OUTPUT}

- name: Set up Python
uses: actions/setup-python@v4.7.1
with:
python-version: ${{ inputs.python-version }}
cache: "pip"
cache: pip
cache-dependency-path: |
**/setup.cfg
**/pyproject.toml
- name: Get Packages
# Briefcase will build and package itself in a previous step in its CI
if: endsWith(inputs.repository, 'briefcase')
if: endsWith(github.repository, 'briefcase')
uses: actions/download-artifact@v3.0.2
with:
name: packages-${{ steps.package.outputs.name }}
Expand All @@ -80,19 +86,25 @@ jobs:
run: python -m pip install -Ur ./briefcase-template/requirements.txt

- name: Install Briefcase Artefact
if: endsWith(inputs.repository, 'briefcase')
if: endsWith(github.repository, 'briefcase')
run: python -m pip install dist/briefcase-*.whl

- name: Install Briefcase
if: ${{ !endsWith(inputs.repository, 'briefcase') }}
if: ${{ !endsWith(github.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
id: template
if: endsWith(github.repository, 'briefcase-template')
run: echo "path=${{ github.workspace }}" | tee -a ${GITHUB_OUTPUT}

- name: Create Briefcase project
id: create
uses: ./beeware-.github/.github/actions/app-create
with:
framework: ${{ inputs.framework }}
briefcase-template-source: ${{ inputs.briefcase-template-source }}
briefcase-template-source: ${{ inputs.briefcase-template-source || steps.template.outputs.path }}
briefcase-template-branch: ${{ inputs.briefcase-template-branch }}

- name: Run Flake8
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ jobs:
python-version: "3.10" # must match system python for ubuntu version
runner-os: ${{ matrix.runner-os }}
framework: ${{ matrix.framework }}
briefcase-template-source: ${{ github.workspace }}
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -224,9 +225,9 @@ jobs:
with:
python-version: "3.11"
repository: beeware/briefcase-template
briefcase-template-source: "../../"
runner-os: ${{ matrix.runner-os }}
framework: ${{ matrix.framework }}
briefcase-template-source: ${{ github.workspace }}
strategy:
fail-fast: false
matrix:
Expand Down

0 comments on commit ee00f93

Please sign in to comment.