backdrop-contrib / project

Projects associate a code-based project with releases and power the update server of BackdropCMS.org
2 stars 10 forks source link

Add an API for processing packages #33

Closed jlfranklin closed 4 years ago

jlfranklin commented 5 years ago

Based on a conversation between me and @docwilmot on Gitter, plus some additional brainstorming:

When a contrib module release is cut, there are a number of things that need to be done. The most basic are:

There are some additional things we want to add to the packages:

The existing process is started by a webhook in Github invoking a webservice in backdropcms.org. The Project Github module services the webhook in _project_github_create_package(), performs all the required packaging steps itself, and pushes the final zip file back to Github.

While Project Github is the one used by Backdrop (today), it should be possible to trigger the packaging process from a Gitlab webhook or a simple Git commit hook, or some other external source.

Conceptually, Project should be the real driver of the packaging process, invoking hooks to allow other modules to contribute their thing.

To accomplish the above goals, the following was proposed:

Potential issues:

quicksketch commented 5 years ago

The packaging system right now is a little mysterious where things happen, so arranging the code so that things are in more expected locations sounds generally good. I think it's surprising to me ever time I go hunting for the packager code and find it in the project_github module.

What sort of data structure do you envision passing around as the process of packaging takes place? Looping over files in the filesystem is not a particularly easy bit of code and doing it multiple times (e.g. to modify .info files and to pull out images) seems like something we'd want to avoid.

I don't think we need to overcomplicate things as far as determining execution order. There's no need for a UI or configurable ordering, this code will be run (almost) exclusively on backdropcms.org, I think we should make it as direct as possible for that purpose. So overall I think module weights and hooks should be fine and hook_module_implements_alter() can be used if need to change the order.

I'm not sure what you're suggesting we use S3 for. We could start putting files there, but thus far it seems like attaching the files to the GitHub releases has worked well and we get convenience benefits like the archive being accessible from the GitHub release page, automatic download tracking, and free hosting.

jlfranklin commented 5 years ago

I think it's surprising to me every time I go hunting for the packager code and find it in the project_github module.

When I found that, I thought, "huh, I wouldn't have put this here, except I probably would because this module is used in exactly one site and it just needs to get done. Why build three modules when I can do it all in one function?"

What sort of data structure do you envision passing around as the process of packaging takes place?

I left that part deliberately vague, partly because I wanted to hear other people's ideas, and partly because I figured it would depend on how the process is built.

I've thought about doing everything in hook_node_presave(), hook_insert(), and hook_node_insert() as the Project Release nodes are created, and using the node object as the data structure passed around. The more I think about it, the more I don't like that solution. It avoids creating yet-another-API, but by using Node API in ways it was never intended and with a lot of side-effects.

The next most common pattern in Backdrop is for project_do_process() to create a tagged array of stuff and pass it around. The initial array would have the list of files, the path of the temporary directory where they're extracted, the .info file parsed out, and an array or two that will become the XML metadata. Should we include the Project and/or Project Release nodes in this array? Will project_do_process() create the new Project Release node automatically?

The screenshot module might add the images to the array in an early hook. The digital signatures are added in a late postprocess hook. Project Github adds download links to the Project Release node and XML. Somewhere in there, the .info gets reconstituted, the final module archive is created, the XML is written out, and the Project Release node is saved.

I don't think we need to overcomplicate things as far as determining execution order. [...] and hook_module_implements_alter() can be used [...]

I've never even heard of that hook before now. (What's the emoji for "lucky 10k?")

If we don't need it, then we don't need it. Given what we have in place today and features we want on the horizon (.info tagging, screenshots, digital signatures), it's already clear that processing order will matter and so we have to keep it in mind. In the end, we may just need to add an extra hook or two to project_do_process().

I'm not sure what you're suggesting we use S3 for.

Project defines a pipeline where code is pulled from somewhere (source), modified to make it a release artifact (process), and then put someplace Backdrop sites and site builders can find it (sink.) Right now, nearly everything in that source -> process -> sink pipeline happens in project_gitlab, because that meets Backdrop's needs.

If this were a more generic pipeline, built for more than one (or two) sites, then there would be no assumption that source and sink are the same place and managed by the same module. The mention of S3 as a potential sink is just a plausible example of a separate sink, not a suggestion for how Backdrop should distribute modules.

quicksketch commented 5 years ago

@jlfranklin I merged in https://github.com/backdrop-contrib/project/issues/37 that I think will accomplish the ability to do a some of these tasks (e.g. remove screenshots, modify .info files), but leaves most of the code in place and continues to tie it to the project_github module. I'm definitely open to more comprehensive approaches but I'll be interested to see what situations aren't covered by that approach, where the files about to be included in the archive are just passed around by reference.

jlfranklin commented 5 years ago

The patch in #37 is as clean as it gets. If we need more, we can add more later.

quicksketch commented 4 years ago

Great, let's close this one up as a duplicate of https://github.com/backdrop-contrib/project/issues/37.