google-listings-and-ads icon indicating copy to clipboard operation
google-listings-and-ads copied to clipboard

Automatic check for migration version replace

Open mikkamp opened this issue 2 years ago • 6 comments

When we release a new DB migration we must specify which version the migration applies to. We added a step in our release Wiki to ensure this is replaced upon release:

  1. If there are new database migration classes (under src/DB/Migration/) modify their applicable version set in the get_applicable_version class of each migration class to be the same value as the version that is to be released.

Woorelease doesn't replace this version since it looks specifically for a matching @since or @version tag. So we need to replace it manually as one of the steps to release.

However in the release of version 1.12.0 it was missed (wasn't caught in 1.12.1 either), meaning the migration didn't run for any user updating the plugin. In this case the migration code is minimal so sites should continue functioning without issues and we can have it run for 1.12.2.

However I think we should address this with an automatic check. Maybe a script which runs upon release and detects that Woorelease is being called, which fails if the version hasn't been replaced yet, or auto replaces it.

mikkamp avatar Apr 04 '22 10:04 mikkamp

The other day I was looking into some code in WC Gutenberg blocks and I realize that they have one variable named $version that seems that is replaced automatically. See line.

I am not sure if the replacement is made by Woorelase or if there is something else doing this.

jorgemd24 avatar Apr 04 '22 12:04 jorgemd24

We don't use a -dev suffix in the develop branch, although we could adopt that strategy (WC does the same) since that would give us a specific version to put into the migration script. Either way they seem to use a shell script to replace the version: https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/trunk/bin/version-changes.sh#L19

mikkamp avatar Apr 04 '22 12:04 mikkamp

What do you think about adding a feature to WooRealese, so it will replace x.x.x in other places indicated by something like // WRCS: RELEASED_VERSION, to follow what it does for the "latest" version https://github.com/woocommerce/woorelease/blob/trunk/includes/tools/class-version-bump.php#L165-L183 ?

tomalec avatar Apr 04 '22 13:04 tomalec

I think it's a great suggestion to have an option of using WooRelease to replace the version string. Although we'd have to look a little more at what would be the right way to indicate what to replace in the code.

Using the comment // WRCS: RELEASED_VERSION means WooRelease would have to replace the version and remove the comment, because we don't want it to be detected again in the next release. Unless we specifically only replace x.x.x with a matching comment, but then the remaining comment would seem out of place.

mikkamp avatar Apr 04 '22 13:04 mikkamp

Update

We've added a reminder in the "prepare release" workflow to ensure it isn't forgotten during release.

An improvement but still no automatic replacement so I'm leaving this issue open.

mikkamp avatar Sep 05 '23 14:09 mikkamp

Seems to me a good option for cooldowns/hackathons if it's not anymore high priority

puntope avatar Sep 06 '23 08:09 puntope