10up / wpsnapshots

(DEPRECATED) A project sharing tool for WordPress.
MIT License
215 stars 22 forks source link

fix: install nightly version #78

Closed dinhtungdu closed 3 years ago

dinhtungdu commented 3 years ago

Currently, wpsnapshots can't install WP nightly because nightly version is available as zip file, while we only handle gz file for now. This PR fixes this issue by handling zip file for nightly version.

Verification

Create latest/nightly snapshot

(To make it clearer, please downgrade the test WP installation to one major version behind.)

  1. cd to a WP directory, create a snapshot with the flag --wp_version, passing latest or nightly to create snapshot with respective WP version.
    wpsnaphosts create --wp_version=latest
  2. Check the meta.json file, see the version field set to the version in the step above.

Pull newly created snapshot.

  1. cd to the WP directory, pull the snapshot created in the step above.
  2. See the pull process successfully.
  3. Check the WP version to match with the version in the step above.
eugene-manuilov commented 3 years ago

Although this PR looks good from the first glance, I think we should try to use ZipArchive first if it is available, and only then try using unzip.

https://www.php.net/manual/en/ziparchive.extractto.php

dinhtungdu commented 3 years ago

@eugene-manuilov I moved the extract commands to a private method for better readability, can you please give this PR another review?

tlovett1 commented 3 years ago

Is anyone actually requesting to use snapshots with the nightly WP version?

dinhtungdu commented 3 years ago

@tlovett1 Yes, we're planning to run WPAcceptance tests against the latest and nightly version of WordPress for 10up's open source plugins.

jeffpaul commented 3 years ago

Adding to @dinhtungdu's comment, we're doing this to try and proactively catch any conflicts between our plugins and core development before a core release happens and we have to react after-the-fact and with a negative user experience.

jeffpaul commented 3 years ago

@tlovett1 is there anything else you need to unblock merge on this PR? We're aiming for a ClassifAI release this week and this WP Snapshots enhancement will help with our WP core+ClassifAI test coverage to give us a higher level of confidence in the release, so would be ideal to get this Snapshots PR resolved early this week... thanks!

tlovett1 commented 3 years ago

@eugene-manuilov how do I test this? I assume a snapshot would have nightly as the wp_version in meta.json? I'm wondering how that works with snapshot pushing because if you were running a nightly version and you pushed a snapshot, wouldn't it store the actual version number in meta e.g. 5.6beta2323 or whatever?

dinhtungdu commented 3 years ago

@tlovett1 @eugene-manuilov to set nightly version, I create a snapshot locally first, then update the wp version in the meta.json file to nightly. After that I push the snapshot by id to AWS.

eugene-manuilov commented 3 years ago

@dinhtungdu can you update your pull request to make sure that the version for nightly snapshots is set correctly when we run the push command?

tlovett1 commented 3 years ago

Updating meta.json manually to me isn't an acceptable workflow for creating a snapshot. I think this needs to be rethought a bit. Ideally, WP Snapshots would allow you somehow to set the version as latest or nightly. Maybe this happens in the CLI as a prompt.

dinhtungdu commented 3 years ago

@eugene-manuilov @tlovett1 I'm sorry for the late reply. I will add a flag to push/create command to handle the latest/nightly version.

Edit: I added wp_version flag to override WP version in meta.json. It can be latest, nightly, or specific WP versions.

tlovett1 commented 3 years ago

Can you give me instructions on testing this?

dinhtungdu commented 3 years ago

@tlovett1 I add the verification steps to the PR description.