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

[pilot] Fix ASC API error when reject_build_waiting_for_review: true #21995

Merged
merged 1 commit into from May 14, 2024

Conversation

AliSoftware
Copy link
Contributor

@AliSoftware AliSoftware commented Apr 30, 2024

Fixes #18408

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

The ASC API to delete TestFlight pending builds doesn't exist, so when fastlane's pilot is trying to reject_build_waiting_for_review, we get this error:

The resource 'betaAppReviewSubmissions' does not allow 'DELETE'. Allowed operations are: GET_COLLECTION, GET_INSTANCE, CREATE

Description

Applying the fix from #18408 (comment) to delete pending submissions properly — kudos to @nid90 for the code of the fix.

Testing Steps

I've just tested the fix with one of our apps which has a TestFlight build still in "Waiting for Review" state.

  • When we tried to submit a new build earlier today, the lane failed with the above error about DELETE not being allowed.
  • After trying to submit another new build while pointing my Gemfile to this branch of the fastlane repo, this time it passed with the following logs in our CI:
[09:37:53 -0700]: Another build is already in review. Going to remove that build and submit the new one.
[09:37:53 -0700]: Canceling beta app review submission for build: 34.5 - 345001
[09:37:55 -0700]: Canceled beta app review submission for previous build: 34.5 - 345001
[09:37:55 -0700]: Distributing new build to testers: 34.5 - 345003

and the previous build 345001 was properly marked as "Expired" in TestFlight after that:
image

@@ -368,12 +368,17 @@ def should_update_localized_build_information?(options)
end

def reject_build_waiting_for_review(build)
waiting_for_review_build = build.app.get_builds(filter: { "betaAppReviewSubmission.betaReviewState" => "WAITING_FOR_REVIEW" }, includes: "betaAppReviewSubmission,preReleaseVersion").first
waiting_for_review_build = build.app.get_builds(
filter: { "betaAppReviewSubmission.betaReviewState" => "WAITING_FOR_REVIEW,IN_REVIEW",
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Not sure if the scope is the same or if the visibility between spaceship and pilot would allow it, but if it is, would you consider DRYing these "magic strings" in favor of

module State
ACCEPTED = "ACCEPTED"
DEVELOPER_REJECTED = "DEVELOPER_REJECTED"
IN_REVIEW = "IN_REVIEW"
PENDING_RELEASE = "PENDING_RELEASE"
PREPARE_FOR_SUBMISSION = "PREPARE_FOR_SUBMISSION"
READY_FOR_DISTRIBUTION = "READY_FOR_DISTRIBUTION"
READY_FOR_REVIEW = "READY_FOR_REVIEW"
REJECTED = "REJECTED"
REPLACED_WITH_NEW_INFO = "REPLACED_WITH_NEW_INFO"
WAITING_FOR_REVIEW = "WAITING_FOR_REVIEW"
end

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if the scope is the same

After looking at the connect_api/models folder, I don't think the scope is the same. It's likely that the words used by the API would not change, but it would not be appropriate to use one for the other.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's likely that the words used by the API would not change

@mokagio You've clearly never worked with Apple's ASC API 😅😁 (they've changed the API without warning—nor updating their doc—at multiple occasions in the past sadly, requiring us to update fastlane in a hurry sometimes to account for the sudden change 😑)

Choose a reason for hiding this comment

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

Can we keep the DRY refactors for another PR? It slows down the adoption of fixes.
We can limit the scope of this PR to the actual fix.
Would love to see this change in, it's been a problem for ages.

@AliSoftware AliSoftware merged commit 806c80c into master May 14, 2024
7 checks passed
@AliSoftware AliSoftware deleted the fix-reject-waiting-for-review branch May 14, 2024 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pilot] The resource 'betaAppReviewSubmissions' does not allow 'DELETE'
4 participants