Conversation
…sting CDN builds Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| end.to raise_error(FastlaneCore::Interface::FastlaneError, 'No metadata to update. Provide at least one of: visibility, post_status') | ||
| end | ||
| end | ||
|
|
There was a problem hiding this comment.
| 🚫 | Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body end. |
There was a problem hiding this comment.
Pull request overview
Adds a new Fastlane action to update metadata on an existing Apps CDN build post via the WordPress.com REST API, enabling a two-phase release flow (upload internal → later flip to external without re-upload).
Changes:
- Introduces
update_apps_cdn_build_metadataFastlane action that POSTs updates to an Apps CDN build post (visibility/status). - Adds RSpec coverage for successful updates, validation, and error handling.
- Documents the new action in the Trunk changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| spec/update_apps_cdn_build_metadata_spec.rb | Adds unit tests for the new action’s request shaping, validation, and error cases. |
| lib/fastlane/plugin/wpmreleasetoolkit/actions/common/update_apps_cdn_build_metadata.rb | Implements the new Fastlane action that updates build metadata via WPCOM REST API. |
| CHANGELOG.md | Adds a Trunk “New Features” entry for the new action. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| before do | ||
| WebMock.disable_net_connect! | ||
| end | ||
|
|
||
| after do | ||
| WebMock.allow_net_connect! | ||
| end | ||
|
|
There was a problem hiding this comment.
The after hook calls WebMock.allow_net_connect!, which re-enables real network access for the rest of the test suite (and overrides the global WebMock.disable_net_connect!(allow: 'analytics-api.buildkite.com') configured in spec/spec_helper.rb). This can make later specs flaky and can allow unexpected external calls. Prefer restoring the suite default in after (re-disable net connect with the same allowlist) or remove the per-spec allow entirely.
| before do | |
| WebMock.disable_net_connect! | |
| end | |
| after do | |
| WebMock.allow_net_connect! | |
| end |
| request['Accept'] = 'application/json' | ||
| request['Authorization'] = "Bearer #{params[:api_token]}" | ||
|
|
||
| response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http| |
There was a problem hiding this comment.
Net::HTTP.start is used without setting any timeouts. If the WordPress.com API stalls, Fastlane can hang indefinitely. Consider configuring open_timeout and read_timeout on the Net::HTTP instance to keep CI/release lanes from blocking forever.
| response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http| | |
| response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http| | |
| http.open_timeout = 10 # seconds | |
| http.read_timeout = 30 # seconds |
| response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http| | ||
| http.request(request) | ||
| end | ||
|
|
||
| # Handle the response | ||
| case response | ||
| when Net::HTTPSuccess | ||
| result = JSON.parse(response.body) | ||
| post_id = result['ID'] | ||
|
|
||
| UI.success("Successfully updated Apps CDN build metadata for post #{post_id}") | ||
|
|
||
| { post_id: post_id } | ||
| else | ||
| UI.error("Failed to update Apps CDN build metadata: #{response.code} #{response.message}") | ||
| UI.error(response.body) | ||
| UI.user_error!('Update of Apps CDN build metadata failed') |
There was a problem hiding this comment.
Network/transport errors (e.g. DNS failures, timeouts, TLS errors) from Net::HTTP.start/http.request will currently bubble up as raw Ruby exceptions, which is inconsistent with the action’s stated behavior of raising a FastlaneError on failure. Wrap the request/parse block and convert these exceptions (and JSON parse errors) into UI.user_error! with a clear message (including the endpoint and error class) so lanes fail predictably.
| response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http| | |
| http.request(request) | |
| end | |
| # Handle the response | |
| case response | |
| when Net::HTTPSuccess | |
| result = JSON.parse(response.body) | |
| post_id = result['ID'] | |
| UI.success("Successfully updated Apps CDN build metadata for post #{post_id}") | |
| { post_id: post_id } | |
| else | |
| UI.error("Failed to update Apps CDN build metadata: #{response.code} #{response.message}") | |
| UI.error(response.body) | |
| UI.user_error!('Update of Apps CDN build metadata failed') | |
| begin | |
| response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http| | |
| http.request(request) | |
| end | |
| # Handle the response | |
| case response | |
| when Net::HTTPSuccess | |
| result = JSON.parse(response.body) | |
| post_id = result['ID'] | |
| UI.success("Successfully updated Apps CDN build metadata for post #{post_id}") | |
| { post_id: post_id } | |
| else | |
| UI.error("Failed to update Apps CDN build metadata: #{response.code} #{response.message}") | |
| UI.error(response.body) | |
| UI.user_error!('Update of Apps CDN build metadata failed') | |
| end | |
| rescue JSON::ParserError => e | |
| UI.user_error!("Failed to parse response from #{api_endpoint}: #{e.class} - #{e.message}") | |
| rescue StandardError => e | |
| UI.user_error!("Network error while calling #{api_endpoint}: #{e.class} - #{e.message}") |
| ### New Features | ||
|
|
||
| _None_ | ||
| - Added new `update_apps_cdn_build_metadata` action to update metadata (e.g. visibility) of an existing build on the Apps CDN without re-uploading the file. This enables a two-phase release flow: upload builds as Internal first, then flip to External at publish time. [#TBD] |
There was a problem hiding this comment.
The changelog entry still contains a placeholder reference [#TBD]. Please replace it with the actual PR/issue number (or remove the bracketed reference) before merging so the Trunk section remains publishable.
| - Added new `update_apps_cdn_build_metadata` action to update metadata (e.g. visibility) of an existing build on the Apps CDN without re-uploading the file. This enables a two-phase release flow: upload builds as Internal first, then flip to External at publish time. [#TBD] | |
| - Added new `update_apps_cdn_build_metadata` action to update metadata (e.g. visibility) of an existing build on the Apps CDN without re-uploading the file. This enables a two-phase release flow: upload builds as Internal first, then flip to External at publish time. |
Fixes AINFRA-2102
Summary
update_apps_cdn_build_metadataFastlane action that updates metadata (e.g. visibility) of an existing build on the Apps CDN without re-uploading the filePOST /rest/v1.1/sites/{site_id}/posts/{post_id}) to update taxonomy termsvisibility(:internal/:external) andpost_status(publish/draft)Context
The companion Studio PR uses this action in its
publish_releaselane.The existing
upload_build_to_apps_cdnaction cannot be used to change visibility because visibility is part of the dedup matching criteria in the CDN plugin — re-uploading with a different visibility creates a new build rather than updating the existing one.Test plan
bundle exec rspec spec/update_apps_cdn_build_metadata_spec.rb)terms[visibility]updates🤖 Generated with Claude Code