Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run apps created in app-build-verify #69

Merged
merged 2 commits into from
Dec 5, 2023

Conversation

rmartin16
Copy link
Member

@rmartin16 rmartin16 commented Nov 18, 2023

Changes

Notes

  • With some cheats, all frameworks are running on all platforms (where frameworks are supported at all)
  • briefcase run is not called for apps created for Linux via containerization since Briefcase does not support the Run command when --target is specified (and that's because passing the X11 into Docker is convoluted).

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@rmartin16 rmartin16 mentioned this pull request Nov 18, 2023
4 tasks
@rmartin16 rmartin16 force-pushed the build-verify-run branch 20 times, most recently from b361bb8 to e71d064 Compare November 19, 2023 14:39
@rmartin16
Copy link
Member Author

An interesting conundrum.

If another repo, like beeware/briefcase, invokes a version of this workflow that isn't at beeware/.github@main, how do you ensure that subsequent workflows and actions are also from that same non-main branch?

Notably, consider Briefcase's CI calling app-build-verify but from a branch on my fork, i.e. rmartin16/.github-beeware/.github/workflows/app-build-verify@testing-branch. This, of course, works fine but app-build-verify needs to run the app-create action to roll out the Briefcase project for testing. It does this by referencing the app-create action via a local filesystem path to the .github repo.....and hence, where the problem begins: how do you checkout the .github repo for the version of app-build-verify that's currently running?

This will require knowing the repo and branch where the running app-build-verify lives.

@rmartin16 rmartin16 force-pushed the build-verify-run branch 3 times, most recently from 5d24435 to 1ae64c7 Compare November 19, 2023 16:03
@rmartin16
Copy link
Member Author

rmartin16 commented Nov 19, 2023

Another person pointed out this same issue. They did not really come to a reasonable conclusion, though...since their workable solution was a hacky javascript action that manually inspects the environment to derive where the running reusable workflow lives....and using some OIDC context at that.

The core problem is mostly how inheritance works. When the reusable workflow (i.e. app-build-verify) is called, it inherits the environment from the caller; this includes the github context.

Relevant bits of github while app-build-verify is running when Briefcase calls it in a PR:

github.ref_name=1546/merge
github.repository=beeware/briefcase
github.repository_owner=beeware
github.workflow=CI
github.workflow_ref=beeware/briefcase/.github/workflows/ci.yml@refs/pull/1546/merge
github.workflow_sha=37da207f9e010c326f1c0a93730e1fd02209e57c

So, the reusable workflow being called effectively appears to just be a part of the workflow that called it.

This means a naked actions/checkout step in app-build-verify will checkout beeware/briefcase and not the repo for the version of app-build-verify that's running.

There doesn't appear to be a straight-forward way for a reusable workflow on a non-main branch to naturally use other reusable workflows/actions from that same branch. Hell, when they first added reusable workflows, they apparently didn't even have way to specify workflows in the same repo without explicitly specifying the same org/repo....so, this problem initially existed even when trying to test reusable workflow changes on a branch within the same repo. Referencing relative workflows was eventually added.

Anyway, I suppose I'll add inputs to app-build-verify to explicitly declare the repo to use for nested workflows/actions.

@rmartin16 rmartin16 force-pushed the build-verify-run branch 4 times, most recently from 66d32b8 to 098cdb0 Compare November 19, 2023 18:02
@rmartin16
Copy link
Member Author

Testing

@rmartin16 rmartin16 marked this pull request as ready for review November 29, 2023 21:45
Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of questions for clarification purposes, and one minor cosmetic thing - but otherwise, I think this all makes sense, and it's difficult to argue with the success of the example cases you've provided.

I definitely can't see anything that is systematically wrong or will lock us out of a use case that we need to support; my only real concern is the level of complexity... but to some extent, this is just inherently complex.

if: >
startsWith(inputs.runner-os, 'ubuntu')
&& contains(fromJSON('["Linux"]'), inputs.target-platform)
&& 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" ;;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libthai-dev? What's that for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh....this goes back to all our previous AppImage testing; libthai-dev is a deep transitive dependency for Toga but AppImage has excluded it from inclusion....so, this ensures it's available to load from the file system of the runner itself.

For completeness, here's the minimum apt packages to run Toga in an AppImage:

libthai-dev libfribidi0 libfontconfig1 libx11-6 libegl1 libgl1 libharfbuzz0b

All the other packages are already installed.

@@ -229,8 +229,8 @@ jobs:
strategy:
fail-fast: false
matrix:
framework: [ "toga", "ppb" ]
runner-os: [ "macos-latest", "windows-latest", "ubuntu-latest" ]
framework: [ toga, pyside6 ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand this change. Is Pyside a better check?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah; this was a really early change I made when this was still POC. There isn't really a defensible rationale other than it took me a lot longer to get PPB working than PySide. I can change it back, though.

briefcase-template-source: ${{ inputs.briefcase-template-source || steps.template.outputs.path }}
briefcase-template-branch: ${{ inputs.briefcase-template-branch }}
# use the current repo checkout if briefcase-template is being tested
briefcase-template-source: ${{ endsWith(github.repository, 'briefcase-template') && github.workspace || '' }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume the drop of briefcase-template-branch is because we can't support non-main branches any more?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely a little more obscure; so, #68 added the ability to specify the briefcase template as part of the body of the PR; so, manually overriding it in the workflow isn't necessary anymore.


echo "Rolled out project to ${APP_PATH} (${{ inputs.framework }}->${GUI_INPUT})"
echo "Rolled out project to ${APP_PATH} (${{ inputs.framework }}->${BOOTSTRAP})"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minor cosmetic thing, but it took me a couple of tries to work out how to "read" this when it appeared in the logs. It might help to be more explicit about the framework and bootstrap choice.`

@rmartin16
Copy link
Member Author

This is all here now.

I'm not sure where we stand now with any further parameterization of app-build-verify; do you think it'll be worth abstracting these last few bits?

Otherwise, the only other question is CI for backports for templates. I think we'll just need to abandon running CI for such PRs; I definitely do not see any low-effort option to keep it working. Although, once Briefcase 0.3.17 is cut, CI would be able to run for backports to that version and later.

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good to me.

Regarding the potential parameterisation: I think I'm happy for now. It isn't immediately obvious to me that parameterisation will result in something that is obviously better - I think we'd likely end up exchanging some complexity in this project for equal levels of complexity spread across all the templates (... or, straight up more complexity in both 😝).

We can always revisit this if one of us has a bright idea about how to simplify everything, but for now, the perfect is the enemy of the good, and what we've got definitely meets the bar of good (and then some).

@rmartin16
Copy link
Member Author

I just realized that CI for this PR should be re-run without BRIEFCASE_REPO in the PR body. Let me do that.

@freakboy3742 freakboy3742 merged commit fcde700 into beeware:main Dec 5, 2023
68 checks passed
@rmartin16 rmartin16 deleted the build-verify-run branch December 5, 2023 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a "live test" to template CI
2 participants