PurpleTurtleCreative / completionist

Asana integration plugin for WordPress.
https://purpleturtlecreative.com/completionist/
GNU General Public License v3.0
3 stars 0 forks source link

GitHub Action - Published release package should also be uploaded to purpleturtlecreative.com #207

Closed MichelleBlanchette closed 6 months ago

MichelleBlanchette commented 11 months ago

The changelog and other information is parsed from the latest release package and updated at https://purpleturtlecreative.com/completionist/plugin-info/

For now, I'm just downloading the GitHub Action artifact, unzipping it, and then pushing it up to the server from my local machine which is too dependent on my local setup and obviously not completely automated.

Note that this should only happen when the version is successfully deployed to WordPress.org so the published versions always match.

MichelleBlanchette commented 7 months ago

Also need to upgrade how the artifact is uploaded since the current version will soon be deprecated: https://github.com/actions/upload-artifact?tab=readme-ov-file

MichelleBlanchette commented 7 months ago

Didn't work out this release, but I think I committed the fix. I'll just wait until the next release to test again.

However, there is now an issue where PHP's ZipArchive class cannot read the zip file artifact download. I downloaded the generated artifact and manually pushed it up and the file contents are returning empty string despite me manually confirming there is indeed content in those files at those paths. I'm suspecting there's a difference in the encoding from actions/upload-artifact@v4 because I said that wasn't a problem when the artifact was uploaded via v3.

MichelleBlanchette commented 7 months ago

Yeah, look at the size difference here. Top is from npm run bundle (4.8 MB) and bottom is from the GitHub Action artifact (1.7 MB).

Screenshot 2024-04-21 at 7 23 52 PM

I also confirmed that simply swapping out the packages in local staging makes the plugin info webpage work again, too. This was also confirmed in production.

MichelleBlanchette commented 7 months ago

I figured out the problem with the artifact. It's doubly zipped because the artifact itself is a zip file...

% unzip -l /Users/michelle/Downloads/completionist-4.2.1.zip
Archive:  /Users/michelle/Downloads/completionist-4.2.1.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
  1793264  04-21-2024 22:44   completionist-4.2.1.zip
---------                     -------
  1793264                     1 file

When decompressing on a Mac, it automatically extracts a doubly-nested zip file. It's convenient, but it obscures the actual structure/contents of the zip file.

For the actual zip file, the output is like:

% unzip -l /Users/michelle/web/docker/wp-completionist/completionist-4.2.1.zip
# ... too many lines to actually show, but you can see it's just listing the many included files.
     4084  12-10-2023 22:07   completionist/src/public/rest-api/class-tags.php
     9929  12-10-2023 22:07   completionist/src/public/rest-api/class-tasks.php
    10595  12-10-2023 22:07   completionist/src/public/rest-api/class-automations.php
     3344  12-10-2023 22:07   completionist/src/public/rest-api/class-projects.php
---------                     -------
 13560301                     2854 files

This shouldn't actually be relevant, though, because the artifact isn't used to upload to the production server; the actual plugin zip file is uploaded to the production server. The artifact being doubly-zipped just confused me as I downloaded the artifact to then manually upload to the production server myself once the job step failed. I had forgotten that minor detail.

To resolve this, it seems we can disable compression altogether. The default compression level is 6, but setting to 0 disables compression completely. Hopefully the download process in the web browser doesn't simply force a single zip file download regardless. See https://github.com/actions/upload-artifact?tab=readme-ov-file#altering-compressions-level-speed-v-size

MichelleBlanchette commented 7 months ago

Actually, they seem to say artifacts are downloaded as zip files anyways and that there's no way to simply download a single file..? This seems dumb: https://github.com/actions/upload-artifact?tab=readme-ov-file#zip-archives

So I think that I would need to simply run bash build_cleanup.sh instead of using the bash bundle.sh script. The bundle script creates the proper zip file name, though, and the proper file hierarchy for WordPress plugin installation to work. However, I'm sure these are simple problems to solve.

MichelleBlanchette commented 6 months ago

Woohoo! This pipeline was confirmed with Action run https://github.com/PurpleTurtleCreative/completionist/actions/runs/8959770766

We could eventually clear the page cache for the PTC website, but it's nice to manually review the pages beforehand while this process is still somewhat in monitoring. (It's just doing what I had to manually do before, though...)

Also, this DRASTICALLY reduced the file size (of the package served from PTC Resources Server) because no dev dependencies are being accidentally bundled from my local dev environment.