-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[supply] Fix #28995 and release_status
vs rollout
parameters
#29484
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
[supply] Fix #28995 and release_status
vs rollout
parameters
#29484
Conversation
context 'when release_status is IN_PROGRESS' do | ||
include_examples 'updates track with correct status and rollout', | ||
rollout: 1.0, | ||
release_status: Supply::ReleaseStatus::IN_PROGRESS, | ||
# We want to ensure the implementation forces status of COMPLETED when explicit rollout = 1.0 is provided | ||
expected_status: Supply::ReleaseStatus::COMPLETED, | ||
expected_user_fraction: nil | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should cover the case / request from @mcfarljw in #28995 (comment)
context 'when release_status is COMPLETED' do | ||
include_examples 'updates track with correct status and rollout', | ||
rollout: 0.5, | ||
release_status: Supply::ReleaseStatus::COMPLETED, | ||
# We want to ensure the implementation forces status of IN_PROGRESS when explicit rollout < 1.0 is provided | ||
expected_status: Supply::ReleaseStatus::IN_PROGRESS, | ||
expected_user_fraction: 0.5 | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the particular case reported in #28995 we want to fix
[The API docs](https://googleapis.dev/ruby/google-api-client/latest/Google/Apis/AndroidpublisherV3/TrackRelease.html#user_fraction-instance_method) explicitly mention that the `user_fraction` parameter is only valid when `status` is `inProgress` or `halted`
release_status
vs rollout
parameters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TDD FTW! 🚀
Checklist
bundle exec rspec
from the root directory to see all new and existing tests passbundle exec rubocop -a
to ensure the code style is validci/circleci
builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)I've updated the documentation if necessary.Motivation and Context
After I introduced this change to supply in
2.226.0
, this broke the behavior for some users in #28995.This is because when they provided a
rollout:
parameter with an <1.0 value, but didn't provide an explicitrelease_status:
parameter (and it thus defaulted to'completed'
), the new implementation made the API call withrelease_status: 'completed', user_fraction: rollout
instead of usinginProgress
implicitly for rollout values <1.0The before/after and history of past implementations
Before https://github.com//issues/28995, it was ok to not change the `release.status` of the existing track and status that was fetched by the API to be modified by `#update_rollout`, because before that PR we only fetched releases that were in `inProgress` state, so we were guaranteed that the `status` property of those `release` objects we got back already had the `release.status = 'inProgress'`, and all the old implementation was doing was thus to update that `release.status` to `'completed'` only if a value of `rollout: '1.0'` was provided, leaving the value unchanged to `'inProgress'` otherwise.But after #28995 landed, the
release
objects we got back from the API could be eitherinProgress
ordraft
. This is why that part of the implementation / logic was changed to make sure the provided value for therelease_status
parameter was applied, so that it could be changed fromdraft
toinProgress
and vice-versa too if that's what the caller explicitly asked. But that implementation failed to account for the fact that therelease_status
parameter (ConfigItem
) of supply had a default value of'completed'
which means that if the user didn't provide arelease_status
parameter explicitly, the new code would attempt to set it to'completed'
even ifrollout:
was provided with a <1.0 value.Description
This new implementation was written by writing the Unit Tests (rspecs) first, to write down all the possible use cases that we could encounter with regards to combinations of
release_status
/rollout
parameter pairs and write down the expectation we have for each of those cases. Then I adjusted the implementation to make sure those tests passed (TDD FTW!)Here's the various use cases covered by the unit tests and the behavior we implemented:
rollout
parameterrelease_status
parameteruser_fraction
sent to API1release.status
sent to APInil
DRAFT
nil
DRAFT
nil
IN_PROGRESS
nil
COMPLETED
nil
COMPLETED
0.5
DRAFT
nil
1DRAFT
0.5
IN_PROGRESS
0.5
IN_PROGRESS
0.5
COMPLETED
0.5
IN_PROGRESS
21.0
DRAFT
nil
1DRAFT
1.0
IN_PROGRESS
nil
1COMPLETED
31.0
COMPLETED
nil
1COMPLETED
Testing Steps
Gemfile
to the branch of this PRupload_to_play_store
in yourFastfile
with the usual parameters you'd call it with, but testing the different use cases provided in the table above forrollout
andrelease_status
In particular, it'd be nice if some of you could test those calls while your tracks in Google Play are in different states, like the track already containing a release but being in draft, or a track containing a release which has started rollout but not at 100% yet, multiple releases in draft in the same track, …
cc @Noorrama @sreejithbnaick @lberaldodev @GiebelGobbler @mcfarljw — who chimed in on the original issue #28995
Footnotes
The
user_fraction
parameter is only expected by the API ifstatus
isinProgress
orhalted
↩ ↩2 ↩3 ↩4 ↩5We intentionally force the status sent to the API to be
'inProgress'
even if the user called the action with'completed'
, because therollout
parameter was explicitly passed with value1.0
↩We intentionally force the status sent to the API to be
'completed'
even if the user called the action with'inProgress'
, because therollout
parameter was explicitly passed but with a value <1.0 ↩