Skip to content

Commit 58d280f

Browse files
authored
[AINFRA-1149] upload_build_to_apps_cdn: Add Microsoft Store as allowed platforms (#661)
2 parents ebf9752 + aa05da8 commit 58d280f

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ _None_
1010

1111
### New Features
1212

13-
_None_
13+
- `upload_build_to_apps_cdn`: Add support for `Microsoft Store` as an allowed value for the `platform` parameter. [#661]
1414

1515
### Bug Fixes
1616

lib/fastlane/plugin/wpmreleasetoolkit/actions/common/upload_build_to_apps_cdn.rb

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,35 @@ module SharedValues
1515
end
1616

1717
class UploadBuildToAppsCdnAction < Action
18+
# See https://github.a8c.com/Automattic/wpcom/blob/trunk/wp-content/lib/a8c/cdn/src/enums/enum-resource-type.php
1819
RESOURCE_TYPE = 'Build'
20+
# These are from the WordPress.com API, not the Apps CDN plugin
1921
VALID_POST_STATUS = %w[publish draft].freeze
20-
VALID_BUILD_TYPES = %w[Alpha Beta Nightly Production Prototype].freeze
21-
VALID_PLATFORMS = ['Android', 'iOS', 'Mac - Silicon', 'Mac - Intel', 'Mac - Any', 'Windows'].freeze
22-
VALID_INSTALL_TYPES = ['Full Install', 'Update'].freeze
22+
# See https://github.a8c.com/Automattic/wpcom/blob/trunk/wp-content/lib/a8c/cdn/src/enums/enum-build-type.php
23+
VALID_BUILD_TYPES = %w[
24+
Alpha
25+
Beta
26+
Nightly
27+
Production
28+
Prototype
29+
].freeze
30+
# See https://github.a8c.com/Automattic/wpcom/blob/trunk/wp-content/lib/a8c/cdn/src/enums/enum-platform.php
31+
VALID_PLATFORMS = [
32+
'Android',
33+
'iOS',
34+
'Mac - Silicon',
35+
'Mac - Intel',
36+
'Mac - Any',
37+
'Windows',
38+
'Microsoft Store',
39+
].freeze
40+
# See https://github.a8c.com/Automattic/wpcom/blob/trunk/wp-content/lib/a8c/cdn/src/enums/enum-install-type.php
41+
VALID_INSTALL_TYPES = [
42+
'Full Install',
43+
'Update',
44+
].freeze
45+
# See https://github.a8c.com/Automattic/wpcom/blob/trunk/wp-content/lib/a8c/cdn/src/enums/enum-visibility.php
46+
VALID_VISIBILITIES = %i[internal external].freeze
2347

2448
def self.run(params)
2549
UI.message('Uploading build to Apps CDN...')
@@ -179,6 +203,8 @@ def self.available_options
179203
type: String,
180204
verify_block: proc do |value|
181205
UI.user_error!('Product cannot be empty') if value.to_s.empty?
206+
# Unlike for other parameters, we don't validate the product value against a list of valid values because we expect this list of
207+
# supported products to be updated on the backend from time to time and we don't want to have to update the toolkit every time for it.
182208
end
183209
),
184210
FastlaneCore::ConfigItem.new(
@@ -228,7 +254,7 @@ def self.available_options
228254
optional: false,
229255
type: Symbol,
230256
verify_block: proc do |value|
231-
UI.user_error!('Visibility must be either :internal or :external') unless %i[internal external].include?(value)
257+
UI.user_error!("Visibility must be one of: #{VALID_VISIBILITIES.map { "`:#{_1}`" }.join(', ')}") unless VALID_VISIBILITIES.include?(value.to_s.downcase.to_sym)
232258
end
233259
),
234260
FastlaneCore::ConfigItem.new(

spec/upload_build_to_apps_cdn_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def expected_form_part(name:, value:, filename: nil)
387387
version: test_version,
388388
file_path: file_path
389389
)
390-
end.to raise_error(FastlaneCore::Interface::FastlaneError, 'Visibility must be either :internal or :external')
390+
end.to raise_error(FastlaneCore::Interface::FastlaneError, 'Visibility must be one of: `:internal`, `:external`')
391391
end
392392
end
393393

@@ -421,7 +421,7 @@ def expected_form_part(name:, value:, filename: nil)
421421
version: test_version,
422422
file_path: file_path
423423
)
424-
end.to raise_error(FastlaneCore::Interface::FastlaneError, 'Platform must be one of: Android, iOS, Mac - Silicon, Mac - Intel, Mac - Any, Windows')
424+
end.to raise_error(FastlaneCore::Interface::FastlaneError, 'Platform must be one of: Android, iOS, Mac - Silicon, Mac - Intel, Mac - Any, Windows, Microsoft Store')
425425
end
426426
end
427427

0 commit comments

Comments
 (0)