Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add upload_build_to_apps_cdn action #636

Merged
merged 19 commits into from
Mar 11, 2025
Merged

Conversation

AliSoftware
Copy link
Contributor

@AliSoftware AliSoftware commented Mar 4, 2025

What does it do?

Implements https://github.com/Automattic/apps-infra-plans/issues/189

This adds a new upload_build_to_apps_cdn action in our release-toolkit to allow us to easily upload builds to our Apps CDN, as documented in PCYsg-15tP-p2

Manual Testing

In addition to the unit tests, this can also be tested manually (as a kind of manual integration test) with the following steps:

  • Be sure to have a dummy file to upload for the test. I for one just picked a random PNG file and zipped it to get a demo.png.zip, we don't really need a real binary/build in practice for this testing.
  • Copy the WP API token from our Secret Store entry ID 12546
  • In your terminal, after having cd into this repo and checked out this PR's branch, call the following command—replacing the API token and file path with the appropriate values
    WPCOM_API_TOKEN='{copy api token here}' \
      bundle exec fastlane run upload_build_to_apps_cdn \
      site_id:239164481 product:'WordPress.com Studio' \
      platform:'Mac - Any' build_type:Alpha visibility:external \
      version:0.1.2 build_number:1338 release_notes:'This is just for testing the CDN API' \
      file_path:$HOME/Desktop/demo.png.zip
  • Verify that the upload of the build succeeds, and that it appears on this page.
  • Click the Download button and verify that the file that gets downloaded is the exact same byte-for-byte (e.g. has the same checksum) as the one you uploaded.

The build available in pgbvBD-8l-p2 is an example of me testing the action with the above manual steps.

Alternatively, you can test the same by calling the action directly from a Fastfile of a test project (e.g. AutoProxxy):

  • Update the Gemfile to point fastlane-plugin-wpmreleasetoolkit to this PR's branch instead of a version
  • Run bundle install
  • Update your Fastfile to either add a dummy test lane that'd call the new action, or to replace the existing call to appcenter_upload in an existing lane with the call to the new upload_build_to_apps_cdn action, providing the proper arguments. Be sure to not provide the api token as part of the parameters, since it's a secret
  • Call export WPCOM_API_TOKEN={copy api token from secret store here} in your Terminal, then run bundle exec fastlane {yourtestlane} to test the action in… action.

Checklist before requesting a review

  • Run bundle exec rubocop to test for code style violations and recommendations.
  • Add Unit Tests (aka specs/*_spec.rb) if applicable.
  • Run bundle exec rspec to run the whole test suite and ensure all your tests pass.
  • Make sure you added an entry in the CHANGELOG.md file to describe your changes under the appropriate existing ### subsection of the existing ## Trunk section.
  • If applicable, add an entry in the MIGRATION.md file to describe how the changes will affect the migration from the previous major version and what the clients will need to change and consider.

The CDN-specific parameters were never supposed to be wrapped inside an `attrs` array
To avoid confusion, as those request parameters are top-level parameters for our customized API CDN endpoint, not sub-keys supposed to be nested under the `attrs` parameter of the official WP API
 - Remove unnecessary comments
 - Reduce valid post status values
 - Improve description to provide valid values for parameters
@AliSoftware AliSoftware added the enhancement New feature or request label Mar 4, 2025
@AliSoftware AliSoftware requested a review from a team March 4, 2025 20:03
@AliSoftware AliSoftware self-assigned this Mar 4, 2025
@dangermattic
Copy link
Collaborator

1 Warning
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

Recently added to the API
Amongst other things, this allows to also return the post_id, and the post page URL (aka the page presenting the build we just uploaded).
@AliSoftware AliSoftware force-pushed the upload_app_to_a8c_cdn branch from beb2940 to 2e22fcf Compare March 6, 2025 17:22
@AliSoftware AliSoftware requested a review from twstokes March 11, 2025 09:30
Copy link
Contributor

@twstokes twstokes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @AliSoftware - testing succeeded and produced this page. 🚀

@AliSoftware AliSoftware merged commit 71d53c6 into trunk Mar 11, 2025
6 checks passed
@AliSoftware AliSoftware deleted the upload_app_to_a8c_cdn branch March 11, 2025 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants