Skip to content

Conversation

AliSoftware
Copy link
Contributor

@AliSoftware AliSoftware commented Mar 10, 2025

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I see several green ci/circleci builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.
  • I've added or updated relevant unit tests.

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 explicit release_status: parameter (and it thus defaulted to 'completed'), the new implementation made the API call with release_status: 'completed', user_fraction: rollout instead of using inProgress implicitly for rollout values <1.0

The 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 either inProgress or draft. This is why that part of the implementation / logic was changed to make sure the provided value for the release_status parameter was applied, so that it could be changed from draft to inProgress and vice-versa too if that's what the caller explicitly asked. But that implementation failed to account for the fact that the release_status parameter (ConfigItem) of supply had a default value of 'completed' which means that if the user didn't provide a release_status parameter explicitly, the new code would attempt to set it to 'completed' even if rollout: 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 parameter release_status parameter user_fraction sent to API1 release.status sent to API
nil DRAFT nil DRAFT
nil IN_PROGRESS - Error: "You need to provide a rollout value when release_status is set to 'inProgress'"
nil COMPLETED nil COMPLETED
0.5 DRAFT nil1 DRAFT
0.5 IN_PROGRESS 0.5 IN_PROGRESS
0.5 COMPLETED 0.5 IN_PROGRESS2
1.0 DRAFT nil1 DRAFT
1.0 IN_PROGRESS nil1 COMPLETED3
1.0 COMPLETED nil1 COMPLETED

Testing Steps

  • Point your Gemfile to the branch of this PR
  • Call upload_to_play_store in your Fastfile with the usual parameters you'd call it with, but testing the different use cases provided in the table above for rollout and release_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

  1. The user_fraction parameter is only expected by the API if status is inProgress or halted 2 3 4 5

  2. We intentionally force the status sent to the API to be 'inProgress' even if the user called the action with 'completed', because the rollout parameter was explicitly passed with value 1.0

  3. We intentionally force the status sent to the API to be 'completed' even if the user called the action with 'inProgress', because the rollout parameter was explicitly passed but with a value <1.0

Comment on lines +565 to +572
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
Copy link
Contributor Author

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)

Comment on lines +546 to +553
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
Copy link
Contributor Author

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

@AliSoftware AliSoftware changed the title [supply] Fix #28995 and release_status vs rollout parameters [supply] Fix #28995 and release_status vs rollout parameters Mar 10, 2025
Copy link
Member

@mollyIV mollyIV left a comment

Choose a reason for hiding this comment

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

TDD FTW! 🚀

@AliSoftware AliSoftware merged commit 9905bed into master Mar 12, 2025
7 checks passed
@AliSoftware AliSoftware deleted the alisoftware/supply/fix-28995-release_status branch March 12, 2025 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tool: supply upload_to_playstore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants