codemagic-ci-cd / cli-tools

Various utilities to managing Android and iOS app builds, code signing, and deployment.
https://codemagic.io/start/
GNU General Public License v3.0
235 stars 39 forks source link

Request less information from App Store Connect to detect latest build number #382

Closed priitlatt closed 7 months ago

priitlatt commented 7 months ago

As it is now, running app-store-connect actions get-latest-testflight-build-number, get-latest-app-store-build-number and get-latest-build-number will fetch a lot of data for pre-release and App Store versions from from App Store Connect (full object representations and all their references to related objects). With more than just handful of App Store / pre-release versions listing API calls can become very slow, and as we're paginating over those resources, the problem only gets worse. In some extreme cases we've seen app-store-connect get-latest-build-number to run for more than 20 minutes, which is far from ideal.

To speed things up, ask only the bare minimum of information from App Store Connect API when paginating over the resources:

  1. just id and version attribute for pre-release versions,
  2. just id and versionString attribute for pre-release versions,
  3. just id and version attribute for build. By asking only specific attributes, the API does not return any other attributes nor any relationships the object has. By doing so the requests are processed faster and we get the response back with smaller waiting duration. This was achieved by specifying fields[<resourceName>] query parameter for the relevant GET requests.

For that new App Store Connect API Client methods were added:

Action definitions, along with helper methods, were moved away from AppStoreConnect tool main class definition and were (re)implemented in dedicated abstract action classes which are plugged-in to main class as mix-ins.

Updated actions: