-
Notifications
You must be signed in to change notification settings - Fork 90
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
ci: Make wheel building workflow reusable #3016
Conversation
@jpivarski @agoose77 I'd like to clean up the commit history on this a bit after this get reviewed, so once we're happy with the state of this I'll do some interactive rebasing to make thing logically easier to read later when looking at the commit messages squash. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are just comments to help guide the reviewer on actions I took.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused. I would have thought that having the building and publishing in the same workflow would be better because the publishing step would only run if the building is successful. As two workflows, the building step might fail and the publishing step would start anyway. There could also be a race condition between them. (I don't see them both having cron-job times, though...)
What's the overall picture here? What gets tested, built, published, and deployed, and when?
(Going through the set of possible Actions, I already have to distinguish between Tests and Tests,
because a different YAML file supplies a workflow of the same name. One of them hasn't run in months; that's how I can tell them apart...)
Ah, sorry no. Look at the graph screenshot that I've included in the PR body. Nothing about the publishing workflow has changed. You can see that the publishing step still requires the wheels to build successfully. The only thing different is that this logic now lives in another file and can be called indepdently of publishing.
You can select the old one and delete it. |
Oh, is one YAML file acting as an include file for the other? (I didn't know you could do that.) (I also looked for a "delete workflow" on Actions and couldn't find it. But now I know that it exists and will look further into GitHub documentation.) |
Yup. That's what build-wheels:
uses: ./.github/workflows/build-wheels.yml or build-wheels:
uses: scikit-hep/awkward/.github/workflows/build-wheels.yml@main does. This is covered in the GitHub Actions docs here: https://docs.github.com/en/actions/using-workflows/reusing-workflows#using-inputs-and-secrets-in-a-reusable-workflow (I think it is less than a year old at this point. Maybe a bit more?)
Ah yeah you have to do it manually for each run until they eventually clean them up. :( |
5bbb310
to
9df4ca1
Compare
(This rebase was just to clean up the PR into more cohrerent commits that should make the logic easier to review in chunks. Nothing was changed from when I last pushed.) |
@matthewfeickert thanks for authoring this! Do you have any feelings on the motivations to use a re-usable workflow vs just adding a new job that is opt-in? Our As I see it, there are two ways of working here:
Right now we have the latter, and I'm not sure whether I'm missing something RE splitting the workflow (is it just preference)? |
@agoose77 In my mind the advantage is simple (and here I mean simple in a (good) boring way), but two-fold:
(This screenshot from the PR body is of a (test)deploy workflow that is using the wheel building workflow as the first 2 columns of the workflow run so those first 2 columns get rigourously tested with use and the only deployment step logic is simply the publishing with the PyPI publish action.) |
@matthewfeickert I'm a little under the weather, so this might be going straight over my head. AFAICT we don't need duplicate logic; the singular build-wheels workflow could have all of cron, release, and workflow_dispatch triggers, with a "push to pypi" job that only runs on release or workflow_dispatch input. Am I missing something? |
Hm, let me try to walk through this as I'm also pretty low on sleep and so might be missing the obvious and making things more complex. This is going to be long and maybe just makes your point, so bear with me. Though I think this will mainly come down to if you want a long and complicated single workflow file, or if you want shorter workflow files that you compose workflows with (both are fine for me btw). Also as I'm low on sleep if things don't make sense let me know and I'll revise it. I think the main thing that differs here is that the deployment of awkward/.github/workflows/deploy.yml Lines 45 to 64 in 26e5e65
Deploying I think the other differences here that might make more sense for separate workflows is that the current The
The main takeaway here is that this works really nicely if all of the wheels were uploaded from the same GitHub Actions workflow, and would require multiple queries if it came from multiple uploads. The current
Okay, yeah the longer I think about this, I think it does just come down to preference on workflow atomicity. |
@agoose77 @jpivarski While this isn't critical (aka, gentle nudge that you should ignore for other pressing work), can we revisit this PR this week? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my (partial) understanding of what's happening here:
So, three workflows all want to build wheels, deploy-cpp.yml, packaging-test.yml, and upload-nightly-wheels.yml, and previously, upload-nightly-wheels.yml called packaging-test.yml to do that.
Now you've introduced build-wheels.yml, which isn't intended to be run by itself; it's a step that both deploy-cpp.yml and upload-nightly-wheels.yml use. This moved a lot of YAML code out of deploy-cpp.yml and into build-wheels.yml. I don't know why packaging-test.yml didn't have to change (apart from no longer needing a cron schedule).
In the end, is it true that the YAML files that are used by other YAML files don't get run directly? In other words, is the current arrangement maintaining a separation between libraries that are called by applications and applications that are directly run?
Only one workflows wants to build all the wheels:
No, it is designed to run by itself to do the wheel building on:
# Run daily at 1:23 UTC
schedule:
- cron: '23 1 * * *'
# Run on demand with workflow dispatch
workflow_dispatch:
... but it can also be called by other workflows ...
# Use from other workflows
workflow_call:
Correct. This is to avoid duplicating the wheel building logic across multiple files or to avoid making the logic of the run conditions on one file very complicated. Having wheel building be totally factored out into a seperate workflow from deployment also means that any other workflow can safely depend on it and building wheels can be done mentally cheaply without ever having to worry about if the correct environment settings have been selected or not (i.e. removes concerns about accidental deployments — though to be fair that is already quite low given how the current deployment system is setup).
As Awkward didn't have a standalone job that would build all the wheels (it currently only builds them on deployment)
No. What ...
# Use from other workflows
workflow_call: is doing is allowing other workflows to basically directly insert the workflow into the calling workflow, which is how the (c.f. https://docs.github.com/en/actions/using-workflows/reusing-workflows#calling-a-reusable-workflow) I'm not sure if this helps, but think of this as reusing steps in a workflow language project. |
Self note:
|
9df4ca1
to
e6dbc2b
Compare
e6dbc2b
to
1a25031
Compare
1a25031
to
b858e6c
Compare
* Factor the wheel building out of deploy-cpp.yml and make a new build-wheels.yml GitHub Actions workflow that runs on a schedule, workflow dispatch, and on workflow call from other workflows. - Use the pattern 'awkward-cpp' and 'awkward-cpp-wheels-*' for naming the upload artifacts so that the upload-nightly-wheels.yml workflow can find and download these artifacts. - Use workflow_call to allow for the workflow to be used by other workflows. c.f. https://docs.github.com/en/actions/using-workflows/reusing-workflows#using-inputs-and-secrets-in-a-reusable-workflow * In the deploy-cpp.yml workflow call the build-wheels workflow using a relative path to pick up the given branch's file. - Use the pattern 'awkward-cpp*' for downloading artifacts so as to not download and then deploy the Awkward wheels and sdist, but only the awkward-cpp. - Add a ls of the downloaded wheel files to have them appear in the action run logs for visual inspection checks. * Remove the schedule cron job from packaging-test.yml as no longer needed as this is now covered in build-wheels.yml as build-wheels will build all the wheels and not just a subset. * Update the workflow target in the nightly wheel uploader to be build-wheels.yml.
* By default build will build a sdist and then a wheel from it, so can remove the --sdist and --wheel flags.
* All the other GitHub Actions workflow files use '-' to seperate names, so use '-' over '_'.
b858e6c
to
5bcc10b
Compare
@jpivarski @agoose77 gentle ping on this so that the full suite of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This refactoring is a good one. Thanks!
@matthewfeickert thanks for pushing this through, and thanks @jpivarski for merging. It's highly appreciated, and a good change ❤️ |
Thanks for your reviews @agoose77 and @jpivarski! If there are questions in the future I am more than happy to help address them or to help fix anything. 👍 |
Resolves #3014
Seperate out the wheel building from
.github/workflows/deploy-cpp.yml
into its own workflow in.github/workflows/build-wheels.yml
that uses theworkflow_call
trigger. This allows for.github/workflows/deploy-cpp.yml
to be able to simply call it withbut also makes the wheel building independent so that it can run on a schedule to build nightly wheels for
.github/workflows/upload-nightly-wheels.yml
to upload.Given that
.github/workflows/deploy.yml
builds a pure-Python sdist and wheel there isn't a strong motivating factor to bother with finding the sdist and wheel built in thedeploy-cpp
stage that will have been run just before it, and so it is left alone to simply rebuild everything.To match the existing search patterns used in
awkward/.github/workflows/upload_nightly_wheels.yml
Line 34 in b7eb8b9
.github/workflows/build-wheels.yml
also uses patterns ofawkward-cpp-wheels-*
andawkward-wheel
as artifact names.I developed this on my fork before pushing it here (with some cleanup of names), so here's an example of this workflow running there:
Instead of actually uploading I had a
ls -lhtra dist/
which gaveAs the
.github/workflows/build-wheels.yml
now exists, then the CRON job added to.github/workflows/packaging-test.yml
in PR #3012awkward/.github/workflows/packaging-test.yml
Lines 5 to 7 in b7eb8b9
can be reverted