Page MenuHomePhabricator

[EPIC] Generate compiled assets from continuous integration
Open, Stalled, MediumPublic

Description

Background

mediawiki-extensions-Popups currently uses a compilation step (npm run build) to pull together front-end assets and process them before pointing ResourceLoader at them for serving.

Currently...

This allows us to:

  • Keep master updated with the deploy assets
  • Ensure that latest sources will have the latest deploy assets on master (with the CI step)

Cons

Rebase hell

Because of how it is set up, every pending patch on gerrit that touches the frontend assets, needs to be rebased every time master is updated, to get rid of the merge conflict and regenerate the compiled assets on top of it.

This can get very annoying for pending changes as any change merged will force a rebase on all pending changes.
It's so annoying we made a bot to do this for us (see T167181 Create bot that automatically rebases and rebuilds patches to master)

Example:

  1. There are changes A, B and C posted on gerrit based off master. They touch front-end assets and as such generate assets into resources/dist with npm run build
  2. Reviewer goes and +2s patch A.
  3. Goes to review B, wants to +2, but because A is merged to master and changed the resources/dist files, B now Cannot merge.
    • B and C now need to be rebased on top of master, run the build step, and re-submitted with updated compiled assets.

Cannot configure per wiki

When working on T173491 it was raised that because $wgScriptPath is configurable map files compiled from this process cannot be changed on a per wiki basis. A formal build step could potentially allow us to build on deploy and thus provide debugging on these wikis

What do we need

To not submit compiled assets with the patches, but keep the deploy branch (master currently) updated with the compiled assets.

Solutions considered

  1. Keep doing what we are doing
    • Pros: Works, nothing to change
    • Cons: Pretty painful if there is churn in the repo because of the merge conflicts
  2. Don't submit the compiled assets on every patch
    • Manually build and release to the master branch
    • Pros
      • No merge conflicts because of stale compiled assets
      • Control over the front-end source releases
    • Cons
      • Backend and front-end source could be out of sync on a release if assets not compiled appropriately
      • Front-end not auto updated in staging and beta cluster environments
      • Manual step, bound to fail because humans
  3. Make CI run the build step and merge compiled assets
    • With the pros of what we are doing currently, but without the cons
    • Pros
      • Simpler workflow compared to the current one as there's no need to remember to add the compiled assets to the change.
      • Keeps master updated with the deploy assets
      • Ensure that latest sources will have the latest deploy assets on deploy branch (master)
    • Cons
      • Needs work with RelEng team to help us automate this
        • Seems to be a dirty solution, having a separate deploy branch/repo seems to be preferred
      • There are jobs that need change to learn how to build assets, like the selenium jobs, otherwise their results will be moot

Ideally after chatting, option 3. Make CI run the build step and merge compiled assets would be our preferred choice if RelEng deems it feasible and not problematic. We had an initial chat with @hashar about different ways this could be accomplished.

Questions

  • Is this feasible? (amount of work to get it set up)
  • How often do we run the job/script to generate assets and merge to the deploy branch (master)? (hourly? daily? after each commit?)
  • Other repositories under wmf keep the deployable version of the project under a project/deploy branch. Is it worth it to have a separate deploy branch and sync it/submit compiled assets there? (Given this is a mediawiki extension) Or is it better to keep master as the deployable branch and push the assets there?
  • Is this a good chance to define a general CI process to trigger a build step on projects? (for bundling frontend assets, pre-compiling templates, optimizing static assets like images, etc)

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

@hashar As an extension having a separate branch for deployment seems quite controversial. I don't have any preferences though.

Yes. This. Let's please not add more extensions needing custom branching logic--this is something we want to move away from, not encourage more of.

Is this a good chance to define a general CI process to trigger a build step on projects? (for bundling frontend assets, pre-compiling templates, optimizing static assets like images, etc)

+ 1. This does seem to be common and I'd love to free up more of release engineerings time by coming up with a generic solution. The ability to use npm test has been a huge time saver.

@hashar with regards to a MediaWiki standard, we are totally committed to that. Right now we are doing an experiment we feel strongly about with the view to share successes/failures as we discover them. Similar conversations are happening in other places via the frontend standards group.

@hashar with regards to a MediaWiki standard, we are totally committed to that. Right now we are doing an experiment we feel strongly about with the view to share successes/failures as we discover them. Similar conversations are happening in other places via the frontend standards group.

Yup that is 100% my understanding. And I know from experience that you like to generalize solutions to the whole ecosystem. I should have better written my large reply this afternoon in a more neutral sense instead of trying to add some humor tongue-in-cheek to it. Sorry about that!

hey Joaquin, we talked about this in the backlog grooming today. We'd like to get this scheduled for an upcoming sprint. Do you think you could coordinate with @hashar to find a time we could actually dedicate to doing this?

We have a dependency on release engineering here. It would be great to coordinate to come up with a satisfactory solution instead of working on something just for ourselves.

Let's give some more time on the ticket for conversations.

Sure. My ask is that we talk to @greg and see if we can schedule some time in their busy schedule to work on this since this is causing us some problems.

Beside the quick chat early in March and the summary at T158980#3087905 , I do not plan to work on this nor do I have any idle cycles left to commit to it :-(

The main tension here seems to be rebasing at time of merge.

I think the following are probably the best solutions to this problem:

  1. Find some way to hook into the Gerrit rebase function and run npm run build at the end of it (not sure if this is possible)
  2. Bring back everyone's favourite browser bot and get him to watch changes and rebase them himself.
  1. Find some way to hook into the Gerrit rebase function and run npm run build at the end of it (not sure if this is possible)

This is not possible.

Jdlrobson renamed this task from Generate compiled assets from continuous integration to [EPIC] Generate compiled assets from continuous integration.Jun 2 2017, 8:31 PM
Jdlrobson added a project: Epic.

For the record, I sent an email to wikitech-l asking how does a build process look like for extensions to gather feedback: https://lists.wikimedia.org/pipermail/wikitech-l/2017-June/088264.html

Now we have a bot that helps merging how do people feel about compiling assets in other larger extensions..?

Seems like a topic for a different card.

Sure but what would that card look like? Are we ready to work on another extension? Which extension would it be?

I replied to Reading-web-team] Using a bundler in another of our extensions
I suggest we revisit this in about a month.

I replied to Reading-web-team] Using a bundler in another of our extensions
I suggest we revisit this in about a month.

The Reading-Web-Team mailing list is a private forum. This is a public forum. Could you summarise what you said here?

I replied to Reading-web-team] Using a bundler in another of our extensions
I suggest we revisit this in about a month.

The Reading-Web-Team mailing list is a private forum. This is a public forum. Could you summarise what you said here?

Ping :)

@greg sorry, I basically said: we're doing too many things at the task let's revisit this in a month (which is what I said in the comment)

To summarise the conversation that followed:

  • The build step is making the team's life a lot easier - easier to write, refactor and test code and opening up possibilities to innovate (in Popups we are now using ES6)
  • There were concerns MobileFrontend might not be the best extension to try this on next due to its size. RelatedArticles might be better.
  • The bot is a necessary evil. We don't want to rely on this, and are anxious about relying on it more, but we recognise to not rely on this, we need buy-in and support from release engineering to provide a build step and/or we need to skill up on understanding the integration config stack.

I think we're have more bandwidth to work on this later in the month/September.

We discussed this in passing a little today and mentioned that other repos such as the Wikipedia Portal and Wikidata have implemented solutions to this. Joaquin mentioned that these solutions, however, may not work well for MobileFrontend since it's expected to be treated as "just another extension" by CI.

Change 436327 had a related patch set uploaded (by Zfilipin; owner: Jdlrobson):
[mediawiki/extensions/Popups@master] Experiment: Build assets via MediaWiki hook

https://gerrit.wikimedia.org/r/436327

Change 436327 abandoned by Jdlrobson:
Experiment: Build assets via MediaWiki hook

Reason:
Trying https://gerrit.wikimedia.org/r/441515

https://gerrit.wikimedia.org/r/436327

Niedzielski changed the task status from Open to Stalled.Mar 29 2019, 6:50 PM

I believe this is blocked on T199004.

We can't do immediate action to add a build step for Popups or other extension, that entirely depends on a solution that has to be found via the discussions being held as part of the RFC T199004. So dropping Release-Engineering-Team meanwhile.